From 221838cc7eb178370ff62aa05920a582e12ac322 Mon Sep 17 00:00:00 2001 From: Jason Jin Date: Tue, 10 Jul 2007 09:03:22 +0800 Subject: [PATCH] Remove the bios emulator from MAI board. The bios emulator in the MAI board can not pass compile and have a lot of crap in it. remove it and will have a clean and small bios emulator in the drivers directory which can be uesed for every board. Signed-off-by: Jason Jin --- board/MAI/bios_emulator/bios.c | 335 - board/MAI/bios_emulator/glue.c | 515 - board/MAI/bios_emulator/glue.h | 57 - .../bios_emulator/scitech/bin/bc31-d16.bat | 28 - .../bios_emulator/scitech/bin/bc45-c32.bat | 37 - .../bios_emulator/scitech/bin/bc45-d16.bat | 32 - .../bios_emulator/scitech/bin/bc45-d32.bat | 33 - .../bios_emulator/scitech/bin/bc45-snp.bat | 32 - .../bios_emulator/scitech/bin/bc45-tnt.bat | 46 - .../bios_emulator/scitech/bin/bc45-vxd.bat | 32 - .../bios_emulator/scitech/bin/bc45-w16.bat | 32 - .../bios_emulator/scitech/bin/bc45-w32.bat | 37 - .../bios_emulator/scitech/bin/bc50-c32.bat | 40 - .../bios_emulator/scitech/bin/bc50-d16.bat | 34 - .../bios_emulator/scitech/bin/bc50-d32.bat | 35 - .../bios_emulator/scitech/bin/bc50-smx.bat | 35 - .../bios_emulator/scitech/bin/bc50-snp.bat | 34 - .../bios_emulator/scitech/bin/bc50-tnt.bat | 48 - .../bios_emulator/scitech/bin/bc50-vxd.bat | 34 - .../bios_emulator/scitech/bin/bc50-w16.bat | 34 - .../bios_emulator/scitech/bin/bc50-w32.bat | 40 - .../bios_emulator/scitech/bin/bc50-x11.bat | 34 - .../bios_emulator/scitech/bin/bcb5-c32.bat | 40 - .../bios_emulator/scitech/bin/bcb5-d16.bat | 34 - .../bios_emulator/scitech/bin/bcb5-d32.bat | 35 - .../bios_emulator/scitech/bin/bcb5-smx.bat | 35 - .../bios_emulator/scitech/bin/bcb5-snp.bat | 34 - .../bios_emulator/scitech/bin/bcb5-tnt.bat | 48 - .../bios_emulator/scitech/bin/bcb5-vxd.bat | 34 - .../bios_emulator/scitech/bin/bcb5-w16.bat | 34 - .../bios_emulator/scitech/bin/bcb5-w32.bat | 40 - .../bios_emulator/scitech/bin/bcb5-x11.bat | 34 - board/MAI/bios_emulator/scitech/bin/build | 22 - board/MAI/bios_emulator/scitech/bin/build.bat | 4 - .../bios_emulator/scitech/bin/build_db.bat | 4 - .../bios_emulator/scitech/bin/build_it.bat | 432 - board/MAI/bios_emulator/scitech/bin/cddrv.bat | 6 - board/MAI/bios_emulator/scitech/bin/cdit | 10 - board/MAI/bios_emulator/scitech/bin/cdit.bat | 5 - board/MAI/bios_emulator/scitech/bin/djgpp.env | 46 - .../bios_emulator/scitech/bin/djgpp_db.env | 46 - .../bios_emulator/scitech/bin/findint3.bat | 1 - .../MAI/bios_emulator/scitech/bin/gcc-beos.sh | 16 - .../bios_emulator/scitech/bin/gcc-freebsd.sh | 16 - .../bios_emulator/scitech/bin/gcc-linux.sh | 19 - .../bios_emulator/scitech/bin/gcc2-c32.bat | 26 - .../bios_emulator/scitech/bin/gcc2-dos.bat | 28 - .../bios_emulator/scitech/bin/gcc2-linux.bat | 26 - .../bios_emulator/scitech/bin/gcc2-w32.bat | 26 - .../MAI/bios_emulator/scitech/bin/makelib.bat | 97 - .../MAI/bios_emulator/scitech/bin/meltobjs.sh | 23 - board/MAI/bios_emulator/scitech/bin/ntddk.bat | 42 - board/MAI/bios_emulator/scitech/bin/qnx4.sh | 18 - board/MAI/bios_emulator/scitech/bin/qnxnto.sh | 21 - .../scitech/bin/set-vars-beos.sh | 42 - .../scitech/bin/set-vars-freebsd.sh | 37 - .../scitech/bin/set-vars-linux.sh | 43 - .../bios_emulator/scitech/bin/set-vars-qnx.sh | 37 - .../bios_emulator/scitech/bin/set-vars.bat | 110 - .../bios_emulator/scitech/bin/vc40-c32.bat | 36 - .../bios_emulator/scitech/bin/vc40-d16.bat | 27 - .../bios_emulator/scitech/bin/vc40-drv9x.bat | 21 - .../bios_emulator/scitech/bin/vc40-drvnt.bat | 18 - .../bios_emulator/scitech/bin/vc40-snp.bat | 31 - .../bios_emulator/scitech/bin/vc40-tnt.bat | 42 - .../bios_emulator/scitech/bin/vc40-w16.bat | 26 - .../bios_emulator/scitech/bin/vc40-w32.bat | 37 - .../bios_emulator/scitech/bin/vc40-x11.bat | 20 - .../bios_emulator/scitech/bin/vc50-c32.bat | 39 - .../bios_emulator/scitech/bin/vc50-d16.bat | 26 - .../bios_emulator/scitech/bin/vc50-drv9x.bat | 21 - .../bios_emulator/scitech/bin/vc50-drvnt.bat | 17 - .../bios_emulator/scitech/bin/vc50-rtt.bat | 30 - .../bios_emulator/scitech/bin/vc50-snp.bat | 33 - .../bios_emulator/scitech/bin/vc50-tnt.bat | 42 - .../bios_emulator/scitech/bin/vc50-w16.bat | 27 - .../bios_emulator/scitech/bin/vc50-w32.bat | 39 - .../bios_emulator/scitech/bin/vc50-x11.bat | 20 - .../bios_emulator/scitech/bin/vc60-c32.bat | 39 - .../bios_emulator/scitech/bin/vc60-d16.bat | 26 - .../bios_emulator/scitech/bin/vc60-drv9x.bat | 21 - .../bios_emulator/scitech/bin/vc60-drvnt.bat | 17 - .../bios_emulator/scitech/bin/vc60-drvw2k.bat | 17 - .../bios_emulator/scitech/bin/vc60-snp.bat | 33 - .../bios_emulator/scitech/bin/vc60-tnt.bat | 42 - .../bios_emulator/scitech/bin/vc60-w16.bat | 27 - .../bios_emulator/scitech/bin/vc60-w32.bat | 39 - .../bios_emulator/scitech/bin/vc60-x11.bat | 20 - .../MAI/bios_emulator/scitech/bin/w2kddk.bat | 42 - .../bios_emulator/scitech/bin/wc10-c32.bat | 34 - .../bios_emulator/scitech/bin/wc10-d16.bat | 30 - .../bios_emulator/scitech/bin/wc10-d32.bat | 34 - .../bios_emulator/scitech/bin/wc10-o16.bat | 31 - .../bios_emulator/scitech/bin/wc10-o32.bat | 31 - .../bios_emulator/scitech/bin/wc10-p32.bat | 31 - .../bios_emulator/scitech/bin/wc10-qnx.bat | 34 - .../bios_emulator/scitech/bin/wc10-snp.bat | 34 - .../bios_emulator/scitech/bin/wc10-tnt.bat | 46 - .../bios_emulator/scitech/bin/wc10-w16.bat | 32 - .../bios_emulator/scitech/bin/wc10-w32.bat | 34 - .../bios_emulator/scitech/bin/wc10-x11.bat | 24 - .../bios_emulator/scitech/bin/wc10ac32.bat | 33 - .../bios_emulator/scitech/bin/wc10ad16.bat | 29 - .../bios_emulator/scitech/bin/wc10ad32.bat | 32 - .../bios_emulator/scitech/bin/wc10ao16.bat | 30 - .../bios_emulator/scitech/bin/wc10ao32.bat | 30 - .../bios_emulator/scitech/bin/wc10ap32.bat | 30 - .../bios_emulator/scitech/bin/wc10asnp.bat | 33 - .../bios_emulator/scitech/bin/wc10atnt.bat | 45 - .../bios_emulator/scitech/bin/wc10aw16.bat | 31 - .../bios_emulator/scitech/bin/wc10aw32.bat | 33 - .../bios_emulator/scitech/bin/wc11-c32.bat | 40 - .../bios_emulator/scitech/bin/wc11-d16.bat | 30 - .../bios_emulator/scitech/bin/wc11-d32.bat | 33 - .../bios_emulator/scitech/bin/wc11-o16.bat | 31 - .../bios_emulator/scitech/bin/wc11-o32.bat | 31 - .../bios_emulator/scitech/bin/wc11-p32.bat | 31 - .../bios_emulator/scitech/bin/wc11-qnx.bat | 34 - .../bios_emulator/scitech/bin/wc11-snp.bat | 34 - .../bios_emulator/scitech/bin/wc11-tnt.bat | 46 - .../bios_emulator/scitech/bin/wc11-w16.bat | 31 - .../bios_emulator/scitech/bin/wc11-w32.bat | 40 - .../bios_emulator/scitech/bin/wc11-x11.bat | 34 - .../bios_emulator/scitech/bin/win32sdk.bat | 20 - .../bios_emulator/scitech/include/biosemu.h | 154 - .../MAI/bios_emulator/scitech/include/event.h | 696 - .../MAI/bios_emulator/scitech/include/mtrr.h | 72 - .../bios_emulator/scitech/include/pcilib.h | 413 - .../bios_emulator/scitech/include/pm_help.h | 166 - .../bios_emulator/scitech/include/pm_wctl.h | 75 - .../MAI/bios_emulator/scitech/include/pmapi.h | 1148 -- .../MAI/bios_emulator/scitech/include/pmimp.h | 193 - .../MAI/bios_emulator/scitech/include/pmint.h | 211 - .../bios_emulator/scitech/include/scitech.h | 712 - .../bios_emulator/scitech/include/scitech.mac | 1321 -- .../bios_emulator/scitech/include/x86emu.h | 194 - .../scitech/include/x86emu/fpu_regs.h | 115 - .../scitech/include/x86emu/regs.h | 331 - .../scitech/include/x86emu/types.h | 70 - .../lib/debug/linux/gcc/glibc.so/readme.txt | 1 - .../lib/debug/linux/gcc/glibc/readme.txt | 1 - .../lib/debug/linux/gcc/libc.so/readme.txt | 1 - .../lib/debug/linux/gcc/libc/readme.txt | 1 - .../lib/release/linux/gcc/glibc.so/readme.txt | 1 - .../lib/release/linux/gcc/glibc/readme.txt | 1 - .../lib/release/linux/gcc/libc.so/readme.txt | 1 - .../lib/release/linux/gcc/libc/readme.txt | 1 - .../bios_emulator/scitech/makedefs/bc16.mk | 137 - .../MAI/bios_emulator/scitech/makedefs/bc3.mk | 102 - .../bios_emulator/scitech/makedefs/bc32.mk | 201 - .../bios_emulator/scitech/makedefs/bcos2.mk | 137 - .../bios_emulator/scitech/makedefs/cl16.mk | 132 - .../bios_emulator/scitech/makedefs/cl386.mk | 120 - .../bios_emulator/scitech/makedefs/common.mk | 180 - .../MAI/bios_emulator/scitech/makedefs/emx.mk | 194 - .../scitech/makedefs/gcc_beos.mk | 161 - .../bios_emulator/scitech/makedefs/gcc_dos.mk | 112 - .../scitech/makedefs/gcc_freebsd.mk | 174 - .../scitech/makedefs/gcc_linux.mk | 180 - .../scitech/makedefs/gcc_win32.mk | 135 - .../bios_emulator/scitech/makedefs/hc32.mk | 113 - .../bios_emulator/scitech/makedefs/qnx4.mk | 164 - .../bios_emulator/scitech/makedefs/qnxnto.mk | 157 - .../scitech/makedefs/rules/bc16.mk | 69 - .../scitech/makedefs/rules/bc3.mk | 43 - .../scitech/makedefs/rules/bc32.mk | 151 - .../scitech/makedefs/rules/bcos2.mk | 70 - .../scitech/makedefs/rules/cl16.mk | 67 - .../scitech/makedefs/rules/cl386.mk | 69 - .../scitech/makedefs/rules/dj32.mk | 47 - .../scitech/makedefs/rules/emx.mk | 91 - .../scitech/makedefs/rules/gcc_beos.mk | 47 - .../scitech/makedefs/rules/gcc_freebsd.mk | 47 - .../scitech/makedefs/rules/gcc_linux.mk | 93 - .../scitech/makedefs/rules/gcc_win32.mk | 90 - .../scitech/makedefs/rules/hc32.mk | 51 - .../scitech/makedefs/rules/qnx4.mk | 94 - .../scitech/makedefs/rules/qnxnto.mk | 55 - .../scitech/makedefs/rules/sc16.mk | 63 - .../scitech/makedefs/rules/sc32.mk | 69 - .../scitech/makedefs/rules/va32.mk | 82 - .../scitech/makedefs/rules/va365.mk | 79 - .../scitech/makedefs/rules/vc16.mk | 70 - .../scitech/makedefs/rules/vc32.mk | 122 - .../scitech/makedefs/rules/wc16.mk | 79 - .../scitech/makedefs/rules/wc32.mk | 264 - .../bios_emulator/scitech/makedefs/sc16.mk | 128 - .../bios_emulator/scitech/makedefs/sc32.mk | 178 - .../bios_emulator/scitech/makedefs/startup.mk | 161 - .../bios_emulator/scitech/makedefs/va32.mk | 163 - .../bios_emulator/scitech/makedefs/va365.mk | 151 - .../bios_emulator/scitech/makedefs/vc16.mk | 128 - .../bios_emulator/scitech/makedefs/vc32.mk | 226 - .../bios_emulator/scitech/makedefs/wc16.mk | 141 - .../bios_emulator/scitech/makedefs/wc32.mk | 353 - .../bios_emulator/scitech/src/biosemu/besys.c | 408 - .../bios_emulator/scitech/src/biosemu/bios.c | 250 - .../scitech/src/biosemu/biosemu.c | 445 - .../scitech/src/biosemu/biosemui.h | 79 - .../scitech/src/biosemu/makefile | 99 - .../scitech/src/biosemu/makefile.cross | 10 - .../scitech/src/biosemu/warmboot.c | 569 - .../scitech/src/common/_aa_imp.asm | 51 - .../scitech/src/common/_ga_imp.asm | 136 - .../scitech/src/common/_gatimer.asm | 248 - .../scitech/src/common/_pm_imp.asm | 195 - .../bios_emulator/scitech/src/common/aabeos.c | 92 - .../bios_emulator/scitech/src/common/aados.c | 64 - .../bios_emulator/scitech/src/common/aalib.c | 225 - .../scitech/src/common/aalinux.c | 94 - .../bios_emulator/scitech/src/common/aaos2.c | 124 - .../bios_emulator/scitech/src/common/aaqnx.c | 95 - .../bios_emulator/scitech/src/common/aartt.c | 89 - .../bios_emulator/scitech/src/common/aasmx.c | 83 - .../bios_emulator/scitech/src/common/aavxd.c | 90 - .../scitech/src/common/aawin32.c | 264 - .../bios_emulator/scitech/src/common/agplib.c | 219 - .../bios_emulator/scitech/src/common/center.c | 122 - .../scitech/src/common/cmdline.c | 428 - .../bios_emulator/scitech/src/common/gabeos.c | 146 - .../bios_emulator/scitech/src/common/gados.c | 135 - .../bios_emulator/scitech/src/common/galib.c | 268 - .../scitech/src/common/galinux.c | 148 - .../scitech/src/common/gantdrv.c | 136 - .../bios_emulator/scitech/src/common/gaos2.c | 248 - .../bios_emulator/scitech/src/common/gaqnx.c | 149 - .../bios_emulator/scitech/src/common/gartt.c | 139 - .../bios_emulator/scitech/src/common/gasmx.c | 133 - .../bios_emulator/scitech/src/common/gavxd.c | 136 - .../scitech/src/common/gawin32.c | 255 - .../scitech/src/common/gtfcalc.c | 436 - .../scitech/src/common/libcimp.c | 827 -- .../bios_emulator/scitech/src/common/makefile | 18 - .../scitech/src/common/peloader.c | 586 - .../scitech/src/common/vesavbe.c | 1214 -- .../scitech/src/pm/beos/cpuinfo.c | 80 - .../bios_emulator/scitech/src/pm/beos/event.c | 199 - .../bios_emulator/scitech/src/pm/beos/oshdr.h | 32 - .../bios_emulator/scitech/src/pm/beos/pm.c | 539 - .../bios_emulator/scitech/src/pm/beos/vflat.c | 49 - .../scitech/src/pm/beos/ztimer.c | 111 - .../scitech/src/pm/codepage/us_eng.c | 285 - .../MAI/bios_emulator/scitech/src/pm/common.c | 480 - .../scitech/src/pm/common/_cpuinfo.asm | 600 - .../scitech/src/pm/common/_dma.asm | 246 - .../scitech/src/pm/common/_int64.asm | 309 - .../scitech/src/pm/common/_joy.asm | 230 - .../scitech/src/pm/common/_mtrr.asm | 272 - .../scitech/src/pm/common/_pcihelp.asm | 358 - .../bios_emulator/scitech/src/pm/common/agp.c | 189 - .../scitech/src/pm/common/keyboard.c | 449 - .../scitech/src/pm/common/malloc.c | 205 - .../scitech/src/pm/common/mtrr.c | 867 -- .../scitech/src/pm/common/pcilib.c | 747 - .../scitech/src/pm/common/unixio.c | 306 - .../scitech/src/pm/common/vgastate.c | 377 - .../bios_emulator/scitech/src/pm/cpuinfo.c | 808 -- .../MAI/bios_emulator/scitech/src/pm/debug.c | 107 - .../scitech/src/pm/dos/_event.asm | 194 - .../scitech/src/pm/dos/_lztimer.asm | 438 - .../bios_emulator/scitech/src/pm/dos/_pm.asm | 656 - .../scitech/src/pm/dos/_pmdos.asm | 1105 -- .../scitech/src/pm/dos/_vflat.asm | 652 - .../scitech/src/pm/dos/cpuinfo.c | 72 - .../bios_emulator/scitech/src/pm/dos/event.c | 494 - .../bios_emulator/scitech/src/pm/dos/oshdr.h | 29 - .../MAI/bios_emulator/scitech/src/pm/dos/pm.c | 2243 --- .../bios_emulator/scitech/src/pm/dos/pmdos.c | 1637 --- .../bios_emulator/scitech/src/pm/dos/vflat.c | 251 - .../bios_emulator/scitech/src/pm/dos/ztimer.c | 111 - .../MAI/bios_emulator/scitech/src/pm/event.c | 1115 -- .../scitech/src/pm/linux/cpuinfo.c | 68 - .../scitech/src/pm/linux/event.c | 1360 -- .../scitech/src/pm/linux/event.svga | 1058 -- .../scitech/src/pm/linux/oshdr.h | 60 - .../bios_emulator/scitech/src/pm/linux/pm.c | 1809 --- .../scitech/src/pm/linux/vflat.c | 49 - .../scitech/src/pm/linux/ztimer.c | 95 - .../MAI/bios_emulator/scitech/src/pm/makefile | 290 - .../scitech/src/pm/ntdrv/_irq.asm | 288 - .../scitech/src/pm/ntdrv/_pm.asm | 281 - .../scitech/src/pm/ntdrv/cpuinfo.c | 64 - .../scitech/src/pm/ntdrv/int86.c | 251 - .../bios_emulator/scitech/src/pm/ntdrv/irq.c | 142 - .../bios_emulator/scitech/src/pm/ntdrv/mem.c | 518 - .../scitech/src/pm/ntdrv/oshdr.h | 45 - .../bios_emulator/scitech/src/pm/ntdrv/pm.c | 933 -- .../scitech/src/pm/ntdrv/stdio.c | 330 - .../scitech/src/pm/ntdrv/stdlib.c | 139 - .../scitech/src/pm/ntdrv/vflat.c | 45 - .../scitech/src/pm/ntdrv/ztimer.c | 123 - .../scitech/src/pm/os2/_pmos2.asm | 180 - .../scitech/src/pm/os2/cpuinfo.c | 66 - .../bios_emulator/scitech/src/pm/os2/event.c | 565 - .../bios_emulator/scitech/src/pm/os2/mon.h | 165 - .../bios_emulator/scitech/src/pm/os2/oshdr.h | 41 - .../MAI/bios_emulator/scitech/src/pm/os2/pm.c | 2008 --- .../bios_emulator/scitech/src/pm/os2/vflat.c | 49 - .../bios_emulator/scitech/src/pm/os2/ztimer.c | 110 - .../scitech/src/pm/os2pm/event.c | 170 - .../scitech/src/pm/os2pm/oshdr.h | 36 - .../MAI/bios_emulator/scitech/src/pm/oshdr.h | 70 - .../scitech/src/pm/photon/event.c | 268 - .../scitech/src/pm/photon/oshdr.h | 38 - board/MAI/bios_emulator/scitech/src/pm/pm.vpw | 43 - .../bios_emulator/scitech/src/pm/pmcommon.vpj | 45 - .../bios_emulator/scitech/src/pm/pmdos.vpj | 41 - .../bios_emulator/scitech/src/pm/pmlinux.vpj | 35 - .../bios_emulator/scitech/src/pm/pmntdrv.vpj | 39 - .../bios_emulator/scitech/src/pm/pmqnx.vpj | 35 - .../bios_emulator/scitech/src/pm/pmvxd.vpj | 34 - .../bios_emulator/scitech/src/pm/pmwin32.vpj | 35 - .../scitech/src/pm/qnx/_mtrrqnx.asm | 226 - .../scitech/src/pm/qnx/cpuinfo.c | 64 - .../bios_emulator/scitech/src/pm/qnx/event.c | 601 - .../scitech/src/pm/qnx/mtrrqnx.c | 182 - .../bios_emulator/scitech/src/pm/qnx/oshdr.h | 103 - .../MAI/bios_emulator/scitech/src/pm/qnx/pm.c | 891 -- .../bios_emulator/scitech/src/pm/qnx/vflat.c | 49 - .../bios_emulator/scitech/src/pm/qnx/ztimer.c | 91 - .../scitech/src/pm/rttarget/cpuinfo.c | 94 - .../scitech/src/pm/rttarget/event.c | 287 - .../scitech/src/pm/rttarget/oshdr.h | 34 - .../scitech/src/pm/rttarget/pm.c | 701 - .../scitech/src/pm/rttarget/vflat.c | 48 - .../scitech/src/pm/rttarget/ztimer.c | 136 - .../scitech/src/pm/smx/_event.asm | 175 - .../scitech/src/pm/smx/_lztimer.asm | 58 - .../bios_emulator/scitech/src/pm/smx/_pm.asm | 448 - .../scitech/src/pm/smx/_pmsmx.asm | 933 -- .../scitech/src/pm/smx/_vflat.asm | 652 - .../scitech/src/pm/smx/cpuinfo.c | 72 - .../bios_emulator/scitech/src/pm/smx/event.c | 368 - .../bios_emulator/scitech/src/pm/smx/oshdr.h | 29 - .../MAI/bios_emulator/scitech/src/pm/smx/pm.c | 1187 -- .../bios_emulator/scitech/src/pm/smx/pmsmx.c | 471 - .../bios_emulator/scitech/src/pm/smx/vflat.c | 49 - .../bios_emulator/scitech/src/pm/smx/ztimer.c | 115 - .../scitech/src/pm/stub/cpuinfo.c | 79 - .../bios_emulator/scitech/src/pm/stub/event.c | 199 - .../bios_emulator/scitech/src/pm/stub/oshdr.h | 33 - .../bios_emulator/scitech/src/pm/stub/pm.c | 980 -- .../bios_emulator/scitech/src/pm/stub/vflat.c | 49 - .../scitech/src/pm/stub/ztimer.c | 111 - .../scitech/src/pm/tests/altbrk.c | 90 - .../scitech/src/pm/tests/altcrit.c | 85 - .../scitech/src/pm/tests/biosptr.c | 92 - .../scitech/src/pm/tests/block.c | 69 - .../bios_emulator/scitech/src/pm/tests/brk.c | 78 - .../scitech/src/pm/tests/callreal.c | 107 - .../scitech/src/pm/tests/checks.c | 100 - .../bios_emulator/scitech/src/pm/tests/cpu.c | 46 - .../scitech/src/pm/tests/critical.c | 70 - .../scitech/src/pm/tests/getch.c | 501 - .../scitech/src/pm/tests/isvesa.c | 110 - .../bios_emulator/scitech/src/pm/tests/key.c | 92 - .../scitech/src/pm/tests/key15.c | 96 - .../scitech/src/pm/tests/memtest.c | 106 - .../scitech/src/pm/tests/mouse.c | 109 - .../scitech/src/pm/tests/restore.c | 81 - .../bios_emulator/scitech/src/pm/tests/rtc.c | 92 - .../bios_emulator/scitech/src/pm/tests/save.c | 69 - .../scitech/src/pm/tests/showpci.c | 253 - .../bios_emulator/scitech/src/pm/tests/tick.c | 94 - .../scitech/src/pm/tests/timerc.c | 87 - .../scitech/src/pm/tests/timercpp.cpp | 107 - .../bios_emulator/scitech/src/pm/tests/uswc.c | 311 - .../scitech/src/pm/tests/vftest.c | 78 - .../scitech/src/pm/tests/video.c | 199 - .../scitech/src/pm/vdd/cpuinfo.c | 66 - .../bios_emulator/scitech/src/pm/vdd/fileio.c | 359 - .../bios_emulator/scitech/src/pm/vdd/oshdr.h | 29 - .../MAI/bios_emulator/scitech/src/pm/vdd/pm.c | 1050 -- .../bios_emulator/scitech/src/pm/vdd/vflat.c | 45 - .../bios_emulator/scitech/src/pm/vdd/ztimer.c | 103 - .../bios_emulator/scitech/src/pm/vxd/_pm.asm | 299 - .../scitech/src/pm/vxd/cpuinfo.c | 66 - .../bios_emulator/scitech/src/pm/vxd/fileio.c | 304 - .../bios_emulator/scitech/src/pm/vxd/oshdr.h | 29 - .../MAI/bios_emulator/scitech/src/pm/vxd/pm.c | 1359 -- .../bios_emulator/scitech/src/pm/vxd/vflat.c | 45 - .../bios_emulator/scitech/src/pm/vxd/ztimer.c | 105 - .../scitech/src/pm/win32/_pmwin32.asm | 78 - .../scitech/src/pm/win32/cpuinfo.c | 94 - .../scitech/src/pm/win32/ddraw.c | 582 - .../scitech/src/pm/win32/event.c | 459 - .../scitech/src/pm/win32/ntservc.c | 258 - .../scitech/src/pm/win32/oshdr.h | 79 - .../bios_emulator/scitech/src/pm/win32/pm.c | 1459 -- .../scitech/src/pm/win32/vflat.c | 53 - .../scitech/src/pm/win32/ztimer.c | 136 - .../bios_emulator/scitech/src/pm/x11/event.c | 307 - .../bios_emulator/scitech/src/pm/x11/oshdr.h | 38 - .../scitech/src/pm/z_samples.vpj | 74 - .../MAI/bios_emulator/scitech/src/pm/ztimer.c | 516 - .../scitech/src/v86bios/AsmMacros.h | 450 - .../bios_emulator/scitech/src/v86bios/README | 32 - .../bios_emulator/scitech/src/v86bios/awk.scr | 15 - .../bios_emulator/scitech/src/v86bios/cbios.c | 415 - .../scitech/src/v86bios/command.c | 38 - .../scitech/src/v86bios/console.c | 95 - .../bios_emulator/scitech/src/v86bios/debug.h | 60 - .../scitech/src/v86bios/happy_cards | 76 - .../bios_emulator/scitech/src/v86bios/hexdump | 3 - .../bios_emulator/scitech/src/v86bios/int.c | 238 - .../bios_emulator/scitech/src/v86bios/io.c | 257 - .../bios_emulator/scitech/src/v86bios/lex.l | 79 - .../bios_emulator/scitech/src/v86bios/main.c | 616 - .../scitech/src/v86bios/makefile.linux | 59 - .../bios_emulator/scitech/src/v86bios/mem.c | 124 - .../scitech/src/v86bios/parser.y | 498 - .../bios_emulator/scitech/src/v86bios/pci.c | 902 -- .../bios_emulator/scitech/src/v86bios/pci.h | 127 - .../bios_emulator/scitech/src/v86bios/v86.c | 562 - .../scitech/src/v86bios/v86bios.c | 933 -- .../scitech/src/v86bios/v86bios.h | 214 - .../scitech/src/v86bios/working_cards | 7 - .../scitech/src/v86bios/x86emu.c | 316 - .../bios_emulator/scitech/src/x86emu/LICENSE | 17 - .../bios_emulator/scitech/src/x86emu/debug.c | 443 - .../bios_emulator/scitech/src/x86emu/decode.c | 970 -- .../bios_emulator/scitech/src/x86emu/fpu.c | 945 -- .../bios_emulator/scitech/src/x86emu/makefile | 63 - .../scitech/src/x86emu/makefile.cross | 82 - .../scitech/src/x86emu/makefile.linux | 81 - .../scitech/src/x86emu/makefile.uboot | 80 - .../bios_emulator/scitech/src/x86emu/ops.c | 11701 ---------------- .../bios_emulator/scitech/src/x86emu/ops2.c | 2800 ---- .../scitech/src/x86emu/prim_ops.c | 2914 ---- .../bios_emulator/scitech/src/x86emu/sys.c | 658 - .../scitech/src/x86emu/validate.c | 765 - .../scitech/src/x86emu/x86emu/debug.h | 210 - .../scitech/src/x86emu/x86emu/decode.h | 87 - .../scitech/src/x86emu/x86emu/fpu.h | 61 - .../scitech/src/x86emu/x86emu/ops.h | 45 - .../scitech/src/x86emu/x86emu/prim_asm.h | 970 -- .../scitech/src/x86emu/x86emu/prim_ops.h | 231 - .../scitech/src/x86emu/x86emu/x86emui.h | 98 - board/MAI/bios_emulator/x86interface.c | 814 -- 439 files changed, 106101 deletions(-) delete mode 100644 board/MAI/bios_emulator/bios.c delete mode 100644 board/MAI/bios_emulator/glue.c delete mode 100644 board/MAI/bios_emulator/glue.h delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc31-d16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc45-c32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc45-d16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc45-d32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc45-snp.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc45-tnt.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc45-vxd.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc45-w16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc45-w32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc50-c32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc50-d16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc50-d32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc50-smx.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc50-snp.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc50-tnt.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc50-vxd.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc50-w16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc50-w32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bc50-x11.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bcb5-c32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bcb5-d16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bcb5-d32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bcb5-smx.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bcb5-snp.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bcb5-tnt.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bcb5-vxd.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bcb5-w16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bcb5-w32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/bcb5-x11.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/build delete mode 100755 board/MAI/bios_emulator/scitech/bin/build.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/build_db.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/build_it.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/cddrv.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/cdit delete mode 100755 board/MAI/bios_emulator/scitech/bin/cdit.bat delete mode 100644 board/MAI/bios_emulator/scitech/bin/djgpp.env delete mode 100644 board/MAI/bios_emulator/scitech/bin/djgpp_db.env delete mode 100755 board/MAI/bios_emulator/scitech/bin/findint3.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/gcc-beos.sh delete mode 100755 board/MAI/bios_emulator/scitech/bin/gcc-freebsd.sh delete mode 100755 board/MAI/bios_emulator/scitech/bin/gcc-linux.sh delete mode 100755 board/MAI/bios_emulator/scitech/bin/gcc2-c32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/gcc2-dos.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/gcc2-linux.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/gcc2-w32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/makelib.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/meltobjs.sh delete mode 100755 board/MAI/bios_emulator/scitech/bin/ntddk.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/qnx4.sh delete mode 100755 board/MAI/bios_emulator/scitech/bin/qnxnto.sh delete mode 100755 board/MAI/bios_emulator/scitech/bin/set-vars-beos.sh delete mode 100755 board/MAI/bios_emulator/scitech/bin/set-vars-freebsd.sh delete mode 100755 board/MAI/bios_emulator/scitech/bin/set-vars-linux.sh delete mode 100755 board/MAI/bios_emulator/scitech/bin/set-vars-qnx.sh delete mode 100755 board/MAI/bios_emulator/scitech/bin/set-vars.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc40-c32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc40-d16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc40-drv9x.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc40-drvnt.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc40-snp.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc40-tnt.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc40-w16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc40-w32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc40-x11.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc50-c32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc50-d16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc50-drv9x.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc50-drvnt.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc50-rtt.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc50-snp.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc50-tnt.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc50-w16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc50-w32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc50-x11.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc60-c32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc60-d16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc60-drv9x.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc60-drvnt.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc60-drvw2k.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc60-snp.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc60-tnt.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc60-w16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc60-w32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/vc60-x11.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/w2kddk.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10-c32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10-d16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10-d32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10-o16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10-o32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10-p32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10-qnx.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10-snp.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10-tnt.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10-w16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10-w32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10-x11.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10ac32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10ad16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10ad32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10ao16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10ao32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10ap32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10asnp.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10atnt.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10aw16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc10aw32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc11-c32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc11-d16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc11-d32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc11-o16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc11-o32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc11-p32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc11-qnx.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc11-snp.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc11-tnt.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc11-w16.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc11-w32.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/wc11-x11.bat delete mode 100755 board/MAI/bios_emulator/scitech/bin/win32sdk.bat delete mode 100644 board/MAI/bios_emulator/scitech/include/biosemu.h delete mode 100644 board/MAI/bios_emulator/scitech/include/event.h delete mode 100644 board/MAI/bios_emulator/scitech/include/mtrr.h delete mode 100644 board/MAI/bios_emulator/scitech/include/pcilib.h delete mode 100644 board/MAI/bios_emulator/scitech/include/pm_help.h delete mode 100644 board/MAI/bios_emulator/scitech/include/pm_wctl.h delete mode 100644 board/MAI/bios_emulator/scitech/include/pmapi.h delete mode 100644 board/MAI/bios_emulator/scitech/include/pmimp.h delete mode 100644 board/MAI/bios_emulator/scitech/include/pmint.h delete mode 100644 board/MAI/bios_emulator/scitech/include/scitech.h delete mode 100644 board/MAI/bios_emulator/scitech/include/scitech.mac delete mode 100644 board/MAI/bios_emulator/scitech/include/x86emu.h delete mode 100644 board/MAI/bios_emulator/scitech/include/x86emu/fpu_regs.h delete mode 100644 board/MAI/bios_emulator/scitech/include/x86emu/regs.h delete mode 100644 board/MAI/bios_emulator/scitech/include/x86emu/types.h delete mode 100644 board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/glibc.so/readme.txt delete mode 100644 board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/glibc/readme.txt delete mode 100644 board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/libc.so/readme.txt delete mode 100644 board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/libc/readme.txt delete mode 100644 board/MAI/bios_emulator/scitech/lib/release/linux/gcc/glibc.so/readme.txt delete mode 100644 board/MAI/bios_emulator/scitech/lib/release/linux/gcc/glibc/readme.txt delete mode 100644 board/MAI/bios_emulator/scitech/lib/release/linux/gcc/libc.so/readme.txt delete mode 100644 board/MAI/bios_emulator/scitech/lib/release/linux/gcc/libc/readme.txt delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/bc16.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/bc3.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/bc32.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/bcos2.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/cl16.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/cl386.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/common.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/emx.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/gcc_beos.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/gcc_dos.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/gcc_freebsd.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/gcc_linux.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/gcc_win32.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/hc32.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/qnx4.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/qnxnto.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/bc16.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/bc3.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/bc32.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/bcos2.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/cl16.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/cl386.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/dj32.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/emx.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/gcc_beos.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/gcc_freebsd.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/gcc_linux.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/gcc_win32.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/hc32.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/qnx4.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/qnxnto.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/sc16.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/sc32.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/va32.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/va365.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/vc16.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/vc32.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/wc16.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/wc32.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/sc16.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/sc32.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/startup.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/va32.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/va365.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/vc16.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/vc32.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/wc16.mk delete mode 100644 board/MAI/bios_emulator/scitech/makedefs/wc32.mk delete mode 100644 board/MAI/bios_emulator/scitech/src/biosemu/besys.c delete mode 100644 board/MAI/bios_emulator/scitech/src/biosemu/bios.c delete mode 100644 board/MAI/bios_emulator/scitech/src/biosemu/biosemu.c delete mode 100644 board/MAI/bios_emulator/scitech/src/biosemu/biosemui.h delete mode 100644 board/MAI/bios_emulator/scitech/src/biosemu/makefile delete mode 100644 board/MAI/bios_emulator/scitech/src/biosemu/makefile.cross delete mode 100644 board/MAI/bios_emulator/scitech/src/biosemu/warmboot.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/_aa_imp.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/common/_ga_imp.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/common/_gatimer.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/common/_pm_imp.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/common/aabeos.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/aados.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/aalib.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/aalinux.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/aaos2.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/aaqnx.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/aartt.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/aasmx.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/aavxd.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/aawin32.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/agplib.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/center.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/cmdline.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/gabeos.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/gados.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/galib.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/galinux.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/gantdrv.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/gaos2.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/gaqnx.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/gartt.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/gasmx.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/gavxd.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/gawin32.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/gtfcalc.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/libcimp.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/makefile delete mode 100644 board/MAI/bios_emulator/scitech/src/common/peloader.c delete mode 100644 board/MAI/bios_emulator/scitech/src/common/vesavbe.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/beos/cpuinfo.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/beos/event.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/beos/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/beos/pm.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/beos/vflat.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/beos/ztimer.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/codepage/us_eng.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/common.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/_cpuinfo.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/_dma.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/_int64.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/_joy.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/_mtrr.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/_pcihelp.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/agp.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/keyboard.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/malloc.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/mtrr.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/pcilib.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/unixio.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/vgastate.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/cpuinfo.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/debug.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/_event.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/_lztimer.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/_pm.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/_pmdos.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/_vflat.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/cpuinfo.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/event.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/pm.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/pmdos.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/vflat.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/ztimer.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/event.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/linux/cpuinfo.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/linux/event.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/linux/event.svga delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/linux/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/linux/pm.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/linux/vflat.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/linux/ztimer.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/makefile delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/_irq.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/_pm.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/cpuinfo.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/int86.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/irq.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/mem.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/pm.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdio.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdlib.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/vflat.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/ztimer.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/_pmos2.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/cpuinfo.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/event.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/mon.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/pm.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/vflat.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/ztimer.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2pm/event.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2pm/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/photon/event.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/photon/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/pm.vpw delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/pmcommon.vpj delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/pmdos.vpj delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/pmlinux.vpj delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/pmntdrv.vpj delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/pmqnx.vpj delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/pmvxd.vpj delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/pmwin32.vpj delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/_mtrrqnx.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/cpuinfo.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/event.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/mtrrqnx.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/pm.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/vflat.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/ztimer.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/rttarget/cpuinfo.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/rttarget/event.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/rttarget/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/rttarget/pm.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/rttarget/vflat.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/rttarget/ztimer.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/_event.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/_lztimer.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/_pm.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/_pmsmx.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/_vflat.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/cpuinfo.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/event.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/pm.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/pmsmx.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/vflat.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/ztimer.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/stub/cpuinfo.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/stub/event.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/stub/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/stub/pm.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/stub/vflat.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/stub/ztimer.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/altbrk.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/altcrit.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/biosptr.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/block.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/brk.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/callreal.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/checks.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/cpu.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/critical.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/getch.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/isvesa.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/key.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/key15.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/memtest.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/mouse.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/restore.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/rtc.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/save.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/showpci.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/tick.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/timerc.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/timercpp.cpp delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/uswc.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/vftest.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/video.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/vdd/cpuinfo.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/vdd/fileio.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/vdd/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/vdd/pm.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/vdd/vflat.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/vdd/ztimer.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/vxd/_pm.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/vxd/cpuinfo.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/vxd/fileio.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/vxd/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/vxd/pm.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/vxd/vflat.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/vxd/ztimer.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/_pmwin32.asm delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/cpuinfo.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/ddraw.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/event.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/ntservc.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/pm.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/vflat.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/ztimer.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/x11/event.c delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/x11/oshdr.h delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/z_samples.vpj delete mode 100644 board/MAI/bios_emulator/scitech/src/pm/ztimer.c delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/AsmMacros.h delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/README delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/awk.scr delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/cbios.c delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/command.c delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/console.c delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/debug.h delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/happy_cards delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/hexdump delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/int.c delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/io.c delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/lex.l delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/main.c delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/makefile.linux delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/mem.c delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/parser.y delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/pci.c delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/pci.h delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/v86.c delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/v86bios.c delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/v86bios.h delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/working_cards delete mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/x86emu.c delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/LICENSE delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/debug.c delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/decode.c delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/fpu.c delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/makefile delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/makefile.cross delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/makefile.linux delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/makefile.uboot delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/ops.c delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/ops2.c delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/prim_ops.c delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/sys.c delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/validate.c delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/x86emu/debug.h delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/x86emu/decode.h delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/x86emu/fpu.h delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/x86emu/ops.h delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/x86emu/prim_asm.h delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/x86emu/prim_ops.h delete mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/x86emu/x86emui.h delete mode 100644 board/MAI/bios_emulator/x86interface.c diff --git a/board/MAI/bios_emulator/bios.c b/board/MAI/bios_emulator/bios.c deleted file mode 100644 index d51eb64692..0000000000 --- a/board/MAI/bios_emulator/bios.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Mostly done after the Scitech Bios emulation - * Written by Hans-Jörg Frieden - * Hyperion Entertainment - */ -#include "x86emu.h" -#include "glue.h" - -#undef DEBUG -#ifdef DEBUG -#define PRINTF(fmt, args...) printf(fmt, ## args) -#else -#define PRINTF(fmt, args...) -#endif - -#define BIOS_SEG 0xFFF0 -#define PCIBIOS_SUCCESSFUL 0 -#define PCIBIOS_DEVICE_NOT_FOUND 0x86 - -typedef unsigned char UBYTE; -typedef unsigned short UWORD; -typedef unsigned long ULONG; - -typedef char BYTE; -typedef short WORT; -typedef long LONG; - -static inline UBYTE read_byte(volatile UBYTE* from) -{ - int x; - asm volatile ("lbz %0,%1\n eieio" : "=r" (x) : "m" (*from)); - return (UBYTE)x; -} - -static inline void write_byte(volatile UBYTE *to, int x) -{ - asm volatile ("stb %1,%0\n eieio" : "=m" (*to) : "r" (x)); -} - -static inline UWORD read_word_little(volatile UWORD *from) -{ - int x; - asm volatile ("lhbrx %0,0,%1\n eieio" : "=r" (x) : "r" (from), "m" (*from)); - return (UWORD)x; -} - -static inline UWORD read_word_big(volatile UWORD *from) -{ - int x; - asm volatile ("lhz %0,%1\n eieio" : "=r" (x) : "m" (*from)); - return (UWORD)x; -} - -static inline void write_word_little(volatile UWORD *to, int x) -{ - asm volatile ("sthbrx %1,0,%2\n eieio" : "=m" (*to) : "r" (x), "r" (to)); -} - -static inline void write_word_big(volatile UWORD *to, int x) -{ - asm volatile ("sth %1,%0\n eieio" : "=m" (*to) : "r" (x)); -} - -static inline ULONG read_long_little(volatile ULONG *from) -{ - unsigned long x; - asm volatile ("lwbrx %0,0,%1\n eieio" : "=r" (x) : "r" (from), "m"(*from)); - return (ULONG)x; -} - -static inline ULONG read_long_big(volatile ULONG *from) -{ - unsigned long x; - asm volatile ("lwz %0,%1\n eieio" : "=r" (x) : "m" (*from)); - return (ULONG)x; -} - -static inline void write_long_little(volatile ULONG *to, ULONG x) -{ - asm volatile ("stwbrx %1,0,%2\n eieio" : "=m" (*to) : "r" (x), "r" (to)); -} - -static inline void write_long_big(volatile ULONG *to, ULONG x) -{ - asm volatile ("stw %1,%0\n eieio" : "=m" (*to) : "r" (x)); -} - -#define port_to_mem(from) (0xFE000000|(from)) -#define in_byte(from) read_byte( (UBYTE *)port_to_mem(from)) -#define in_word(from) read_word_little((UWORD *)port_to_mem(from)) -#define in_long(from) read_long_little((ULONG *)port_to_mem(from)) -#define out_byte(to, val) write_byte((UBYTE *)port_to_mem(to), val) -#define out_word(to, val) write_word_little((UWORD *)port_to_mem(to), val) -#define out_long(to, val) write_long_little((ULONG *)port_to_mem(to), val) - -static void X86API undefined_intr(int intno) -{ - extern u16 A1_rdw(u32 addr); - if (A1_rdw(intno * 4 + 2) == BIOS_SEG) - { - PRINTF("Undefined interrupt %xh called AX = %xh, BX = %xh, CX = %xh, DX = %xh\n", - intno, M.x86.R_AX, M.x86.R_BX, M.x86.R_CX, M.x86.R_DX); - X86EMU_halt_sys(); - } - else - { - PRINTF("Calling interrupt %xh, AL=%xh, AH=%xh\n", intno, M.x86.R_AL, M.x86.R_AH); - X86EMU_prepareForInt(intno); - } -} - -static void X86API int42(int intno); -static void X86API int15(int intno); - -static void X86API int10(int intno) -{ - if (A1_rdw(intno*4+2) == BIOS_SEG) - int42(intno); - else - { - PRINTF("int10: branching to %04X:%04X, AL=%xh, AH=%xh\n", A1_rdw(intno*4+2), A1_rdw(intno*4), - M.x86.R_AL, M.x86.R_AH); - X86EMU_prepareForInt(intno); - } -} - -static void X86API int1A(int intno) -{ - int device; - - switch(M.x86.R_AX) - { - case 0xB101: /* PCI Bios Present? */ - M.x86.R_AL = 0x00; - M.x86.R_EDX = 0x20494350; - M.x86.R_BX = 0x0210; - M.x86.R_CL = 3; - CLEAR_FLAG(F_CF); - break; - case 0xB102: /* Find device */ - device = mypci_find_device(M.x86.R_DX, M.x86.R_CX, M.x86.R_SI); - if (device != -1) - { - M.x86.R_AH = PCIBIOS_SUCCESSFUL; - M.x86.R_BH = mypci_bus(device); - M.x86.R_BL = mypci_devfn(device); - } - else - { - M.x86.R_AH = PCIBIOS_DEVICE_NOT_FOUND; - } - CONDITIONAL_SET_FLAG((M.x86.R_AH != PCIBIOS_SUCCESSFUL), F_CF); - break; - case 0xB103: /* Find PCI class code */ - M.x86.R_AH = PCIBIOS_DEVICE_NOT_FOUND; - /*printf("Find by class not yet implmented"); */ - CONDITIONAL_SET_FLAG((M.x86.R_AH != PCIBIOS_SUCCESSFUL), F_CF); - break; - case 0xB108: /* read config byte */ - M.x86.R_CL = mypci_read_cfg_byte(M.x86.R_BH, M.x86.R_BL, M.x86.R_DI); - M.x86.R_AH = PCIBIOS_SUCCESSFUL; - CONDITIONAL_SET_FLAG((M.x86.R_AH != PCIBIOS_SUCCESSFUL), F_CF); - /*printf("read_config_byte %x,%x,%x -> %x\n", M.x86.R_BH, M.x86.R_BL, M.x86.R_DI, */ - /* M.x86.R_CL); */ - break; - case 0xB109: /* read config word */ - M.x86.R_CX = mypci_read_cfg_word(M.x86.R_BH, M.x86.R_BL, M.x86.R_DI); - M.x86.R_AH = PCIBIOS_SUCCESSFUL; - CONDITIONAL_SET_FLAG((M.x86.R_AH != PCIBIOS_SUCCESSFUL), F_CF); - /*printf("read_config_word %x,%x,%x -> %x\n", M.x86.R_BH, M.x86.R_BL, M.x86.R_DI, */ - /* M.x86.R_CX); */ - break; - case 0xB10A: /* read config dword */ - M.x86.R_ECX = mypci_read_cfg_long(M.x86.R_BH, M.x86.R_BL, M.x86.R_DI); - M.x86.R_AH = PCIBIOS_SUCCESSFUL; - CONDITIONAL_SET_FLAG((M.x86.R_AH != PCIBIOS_SUCCESSFUL), F_CF); - /*printf("read_config_long %x,%x,%x -> %x\n", M.x86.R_BH, M.x86.R_BL, M.x86.R_DI, */ - /* M.x86.R_ECX); */ - break; - case 0xB10B: /* write config byte */ - mypci_write_cfg_byte(M.x86.R_BH, M.x86.R_BL, M.x86.R_DI, M.x86.R_CL); - M.x86.R_AH = PCIBIOS_SUCCESSFUL; - CONDITIONAL_SET_FLAG((M.x86.R_AH != PCIBIOS_SUCCESSFUL), F_CF); - /*printf("write_config_byte %x,%x,%x <- %x\n", M.x86.R_BH, M.x86.R_BL, M.x86.R_DI, */ - /* M.x86.R_CL); */ - break; - case 0xB10C: /* write config word */ - mypci_write_cfg_word(M.x86.R_BH, M.x86.R_BL, M.x86.R_DI, M.x86.R_CX); - M.x86.R_AH = PCIBIOS_SUCCESSFUL; - CONDITIONAL_SET_FLAG((M.x86.R_AH != PCIBIOS_SUCCESSFUL), F_CF); - /*printf("write_config_word %x,%x,%x <- %x\n", M.x86.R_BH, M.x86.R_BL, M.x86.R_DI, */ - /* M.x86.R_CX); */ - break; - case 0xB10D: /* write config dword */ - mypci_write_cfg_long(M.x86.R_BH, M.x86.R_BL, M.x86.R_DI, M.x86.R_ECX); - M.x86.R_AH = PCIBIOS_SUCCESSFUL; - CONDITIONAL_SET_FLAG((M.x86.R_AH != PCIBIOS_SUCCESSFUL), F_CF); - /*printf("write_config_long %x,%x,%x <- %x\n", M.x86.R_BH, M.x86.R_BL, M.x86.R_DI, */ - /* M.x86.R_ECX); */ - break; - default: - PRINTF("BIOS int %xh: Unknown function AX=%04xh\n", intno, M.x86.R_AX); - - } -} - -void bios_init(void) -{ - int i; - X86EMU_intrFuncs bios_intr_tab[256]; - - for (i=0; i<256; i++) - { - write_long_little(M.mem_base+i*4, BIOS_SEG<<16); - bios_intr_tab[i] = undefined_intr; - } - - bios_intr_tab[0x10] = int10; - bios_intr_tab[0x1A] = int1A; - bios_intr_tab[0x42] = int42; - bios_intr_tab[0x15] = int15; - - bios_intr_tab[0x6D] = int42; - - X86EMU_setupIntrFuncs(bios_intr_tab); - video_init(); -} - -unsigned char setup_40x25[] = -{ - 0x38, 0x28, 0x2d, 0x0a, 0x1f, 6, 0x19, - 0x1c, 2, 7, 6, 7, 0, 0, 0, 0 -}; - -unsigned char setup_80x25[] = -{ - 0x71, 0x50, 0x5a, 0x0a, 0x1f, 6, 0x19, - 0x1c, 2, 7, 6, 7, 0, 0, 0, 0 -}; - -unsigned char setup_graphics[] = -{ - 0x38, 0x28, 0x20, 0x0a, 0x7f, 6, 0x64, - 0x70, 2, 1, 6, 7, 0, 0, 0, 0 -}; - -unsigned char setup_bw[] = -{ - 0x61, 0x50, 0x52, 0x0f, 0x19, 6, 0x19, - 0x19, 2, 0x0d, 0x0b, 0x0c, 0, 0, 0, 0 -}; - -unsigned char * setup_modes[] = -{ - setup_40x25, /* mode 0: 40x25 bw text */ - setup_40x25, /* mode 1: 40x25 col text */ - setup_80x25, /* mode 2: 80x25 bw text */ - setup_80x25, /* mode 3: 80x25 col text */ - setup_graphics, /* mode 4: 320x200 col graphics */ - setup_graphics, /* mode 5: 320x200 bw graphics */ - setup_graphics, /* mode 6: 640x200 bw graphics */ - setup_bw /* mode 7: 80x25 mono text */ -}; - -unsigned int setup_cols[] = -{ - 40, 40, 80, 80, 40, 40, 80, 80 -}; - -unsigned char setup_modesets[] = -{ - 0x2C, 0x28, 0x2D, 0x29, 0x2A, 0x2E, 0x1E, 0x29 -}; - -unsigned int setup_bufsize[] = -{ - 2048, 2048, 4096, 2096, 16384, 16384, 16384, 4096 -}; - -void bios_set_mode(int mode) -{ - int i; - unsigned char mode_set = setup_modesets[mode]; /* Control register value */ - unsigned char *setup_regs = setup_modes[mode]; /* Register 3D4 Array */ - - /* Switch video off */ - out_byte(0x3D8, mode_set & 0x37); - - /* Set up parameters at 3D4h */ - for (i=0; i<16; i++) - { - out_byte(0x3D4, (unsigned char)i); - out_byte(0x3D5, *setup_regs); - setup_regs++; - } - - /* Enable video */ - out_byte(0x3D8, mode_set); - - /* Set overscan */ - if (mode == 6) out_byte(0x3D9, 0x3F); - else out_byte(0x3D9, 0x30); -} - -static void bios_print_string(void) -{ - extern void video_bios_print_string(char *string, int x, int y, int attr, int count); - char *s = (char *)(M.x86.R_ES<<4) + M.x86.R_BP; - int attr; - if (M.x86.R_AL & 0x02) attr = - 1; - else attr = M.x86.R_BL; - video_bios_print_string(s, M.x86.R_DH, M.x86.R_DL, attr, M.x86.R_CX); -} - -static void X86API int42(int intno) -{ - switch (M.x86.R_AH) - { - case 0x00: - bios_set_mode(M.x86.R_AL); - break; - case 0x13: - bios_print_string(); - break; - default: - PRINTF("Warning: VIDEO BIOS interrupt %xh unimplemented function %xh, AL = %xh\n", - intno, M.x86.R_AH, M.x86.R_AL); - } -} - -static void X86API int15(int intno) -{ - PRINTF("Called interrupt 15h: AX = %xh, BX = %xh, CX = %xh, DX = %xh\n", - M.x86.R_AX, M.x86.R_BX, M.x86.R_CX, M.x86.R_DX); -} diff --git a/board/MAI/bios_emulator/glue.c b/board/MAI/bios_emulator/glue.c deleted file mode 100644 index b380f0dfe8..0000000000 --- a/board/MAI/bios_emulator/glue.c +++ /dev/null @@ -1,515 +0,0 @@ -#include -#include -#include <74xx_7xx.h> - - -#ifdef DEBUG -#undef DEBUG -#endif - -#ifdef DEBUG -#define PRINTF(format, args...) _printf(format , ## args) -#else -#define PRINTF(format, argc...) -#endif - -static pci_dev_t to_pci(int bus, int devfn) -{ - return PCI_BDF(bus, (devfn>>3), devfn&3); -} - -int mypci_find_device(int vendor, int product, int index) -{ - return pci_find_device(vendor, product, index); -} - -int mypci_bus(int device) -{ - return PCI_BUS(device); -} - -int mypci_devfn(int device) -{ - return (PCI_DEV(device)<<3) | PCI_FUNC(device); -} - - -#define mypci_read_func(type, size) \ -type mypci_read_cfg_##size##(int bus, int devfn, int offset) \ -{ \ - type c; \ - pci_read_config_##size##(to_pci(bus, devfn), offset, &c); \ - return c; \ -} - -#define mypci_write_func(type, size) \ -void mypci_write_cfg_##size##(int bus, int devfn, int offset, int value) \ -{ \ - pci_write_config_##size##(to_pci(bus, devfn), offset, value); \ -} - -mypci_read_func(u8,byte); -mypci_read_func(u16,word); - -mypci_write_func(u8,byte); -mypci_write_func(u16,word); - -u32 mypci_read_cfg_long(int bus, int devfn, int offset) -{ - u32 c; - pci_read_config_dword(to_pci(bus, devfn), offset, &c); - return c; -} - -void mypci_write_cfg_long(int bus, int devfn, int offset, int value) -{ - pci_write_config_dword(to_pci(bus, devfn), offset, value); -} - -void _printf(const char *fmt, ...) -{ - va_list args; - char buf[CFG_PBSIZE]; - - va_start(args, fmt); - (void)vsprintf(buf, fmt, args); - va_end(args); - - printf(buf); -} - -char *_getenv(char *name) -{ - return getenv(name); -} - -unsigned long get_bar_size(pci_dev_t dev, int offset) -{ - u32 bar_back, bar_value; - - /* Save old BAR value */ - pci_read_config_dword(dev, offset, &bar_back); - - /* Write all 1's. */ - pci_write_config_dword(dev, offset, ~0); - - /* Now read back the relevant bits */ - pci_read_config_dword(dev, offset, &bar_value); - - /* Restore original value */ - pci_write_config_dword(dev, offset, bar_back); - - if (bar_value == 0) return 0xFFFFFFFF; /* This BAR is disabled */ - - if ((bar_value & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY) - { - /* This is a memory space BAR. Mask it out so we get the size of it */ - return ~(bar_value & PCI_BASE_ADDRESS_MEM_MASK) + 1; - } - - /* Not suitable */ - return 0xFFFFFFFF; -} - -void enable_compatibility_hole(void) -{ - u8 cfg; - pci_dev_t art = PCI_BDF(0,0,0); - - pci_read_config_byte(art, 0x54, &cfg); - /* cfg |= 0x08; */ - cfg |= 0x20; - pci_write_config_byte(art, 0x54, cfg); -} - -void disable_compatibility_hole(void) -{ - u8 cfg; - pci_dev_t art = PCI_BDF(0,0,0); - - pci_read_config_byte(art, 0x54, &cfg); - /* cfg &= ~0x08; */ - cfg &= ~0x20; - pci_write_config_byte(art, 0x54, cfg); -} - -void map_rom(pci_dev_t dev, u32 address) -{ - pci_write_config_dword(dev, PCI_ROM_ADDRESS, address|PCI_ROM_ADDRESS_ENABLE); -} - -void unmap_rom(pci_dev_t dev) -{ - pci_write_config_dword(dev, PCI_ROM_ADDRESS, 0); -} - -void bat_map(u8 batnum, u32 address, u32 length) -{ - u32 temp = address; - address &= 0xFFFE0000; - temp &= 0x0001FFFF; - length = (length - 1 ) >> 17; - length <<= 2; - - switch (batnum) - { - case 0: - __asm volatile ("mtdbatu 0, %0" : : "r" (address | length | 3)); - __asm volatile ("mtdbatl 0, %0" : : "r" (address | 0x22)); - break; - case 1: - __asm volatile ("mtdbatu 1, %0" : : "r" (address | length | 3)); - __asm volatile ("mtdbatl 1, %0" : : "r" (address | 0x22)); - break; - case 2: - __asm volatile ("mtdbatu 2, %0" : : "r" (address | length | 3)); - __asm volatile ("mtdbatl 2, %0" : : "r" (address | 0x22)); - break; - case 3: - __asm volatile ("mtdbatu 3, %0" : : "r" (address | length | 3)); - __asm volatile ("mtdbatl 3, %0" : : "r" (address | 0x22)); - break; - } -} - -int find_image(u32 rom_address, u32 rom_size, void **image, u32 *image_size); - -int attempt_map_rom(pci_dev_t dev, void *copy_address) -{ - u32 rom_size = 0; - u32 rom_address = 0; - u32 bar_size = 0; - u32 bar_backup = 0; - int i,j; - void *image = 0; - u32 image_size = 0; - int did_correct = 0; - u32 prefetch_addr = 0; - u32 prefetch_size = 0; - u32 prefetch_idx = 0; - - /* Get the size of the expansion rom */ - pci_write_config_dword(dev, PCI_ROM_ADDRESS, 0xFFFFFFFF); - pci_read_config_dword(dev, PCI_ROM_ADDRESS, &rom_size); - if ((rom_size & 0x01) == 0) - { - PRINTF("No ROM\n"); - return 0; - } - - rom_size &= 0xFFFFF800; - rom_size = (~rom_size)+1; - - PRINTF("ROM Size is %dK\n", rom_size/1024); - - /* - * Try to find a place for the ROM. We always attempt to use - * one of the card's bases for this, as this will be in any - * bridge's resource range as well as being free of conflicts - * with other cards. In a graphics card it is very unlikely - * that there won't be any base address that is large enough to - * hold the rom. - * - * FIXME: To work around this, theoretically the largest base - * could be used if none is found in the loop below. - */ - - for (i = PCI_BASE_ADDRESS_0; i <= PCI_BASE_ADDRESS_5; i += 4) - { - bar_size = get_bar_size(dev, i); - PRINTF("PCI_BASE_ADDRESS_%d is %dK large\n", - (i - PCI_BASE_ADDRESS_0)/4, - bar_size/1024); - if (bar_size != 0xFFFFFFFF && bar_size >= rom_size) - { - PRINTF("Found a match for rom size\n"); - pci_read_config_dword(dev, i, &rom_address); - rom_address &= 0xFFFFFFF0; - if (rom_address != 0 && rom_address != 0xFFFFFFF0) break; - } - } - - if (rom_address == 0 || rom_address == 0xFFFFFFF0) - { - PRINTF("No suitable rom address found\n"); - return 0; - } - - /* Disable the BAR */ - pci_read_config_dword(dev, i, &bar_backup); - pci_write_config_dword(dev, i, 0); - - /* Map ROM */ - pci_write_config_dword(dev, PCI_ROM_ADDRESS, rom_address | PCI_ROM_ADDRESS_ENABLE); - - /* Copy the rom to a place in the emulator space */ - PRINTF("Claiming BAT 2\n"); - bat_map(2, rom_address, rom_size); - /* show_bat_mapping(); */ - - if (0 == find_image(rom_address, rom_size, &image, &image_size)) - { - PRINTF("No x86 BIOS image found\n"); - return 0; - } - - PRINTF("Copying %ld bytes from 0x%lx to 0x%lx\n", (long)image_size, (long)image, (long)copy_address); - - /* memcpy(copy_address, rom_address, rom_size); */ - { - unsigned char *from = (unsigned char *)image; /* rom_address; */ - unsigned char *to = (unsigned char *)copy_address; - for (j=0; j>16, (prefetch_addr+prefetch_size)>>16); */ -/* pci_write_config_word(bridge, PCI_PREF_MEMORY_BASE, (prefetch_addr>>16)); */ -/* pci_write_config_word(bridge, PCI_PREF_MEMORY_LIMIT, (prefetch_addr+prefetch_size)>>16); */ - } - - pci_write_config_word(bridge, PCI_PREF_MEMORY_BASE, 0x1000); - pci_write_config_word(bridge, PCI_PREF_MEMORY_LIMIT, 0x0000); - - pci_write_config_byte(bridge, 0xD0, 0x0A); - pci_write_config_byte(bridge, 0xD3, 0x04); - - /* - * Set the interrupt pin to 0 - */ -#if 0 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 0); - pci_write_config_byte(dev, PCI_INTERRUPT_PIN, 0); -#endif - pci_write_config_byte(bridge, PCI_INTERRUPT_LINE, 0); - pci_write_config_byte(bridge, PCI_INTERRUPT_PIN, 0); - - } - } - - /* Finally, enable the card's IO and memory response */ - pci_write_config_dword(dev, PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_IO); - pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0); - pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0); - - return 1; -} - -int find_image(u32 rom_address, u32 rom_size, void **image, u32 *image_size) -{ - int i = 0; - unsigned char *rom = (unsigned char *)rom_address; - /* if (*rom != 0x55 || *(rom+1) != 0xAA) return 0; /* No bios rom this is, yes. */ */ - - for (;;) - { - unsigned short pci_data_offset = *(rom+0x18) + 256 * *(rom+0x19); - unsigned short pci_image_length = (*(rom+pci_data_offset+0x10) + 256 * *(rom+pci_data_offset+0x11)) * 512; - unsigned char pci_image_type = *(rom+pci_data_offset+0x14); - if (*rom != 0x55 || *(rom+1) != 0xAA) - { - PRINTF("Invalid header this is\n"); - return 0; - } - PRINTF("Image %i: Type %d (%s)\n", i++, pci_image_type, - pci_image_type==0 ? "x86" : - pci_image_type==1 ? "OpenFirmware" : - "Unknown"); - if (pci_image_type == 0) - { - *image = rom; - *image_size = pci_image_length; - return 1; - } - - if (*(rom+pci_data_offset+0x15) & 0x80) - { - PRINTF("LAST image encountered, no image found\n"); - return 0; - } - - rom += pci_image_length; - } -} - -void show_bat_mapping(void) -{ - u32 dbat0u, dbat0l, ibat0u, ibat0l; - u32 dbat1u, dbat1l, ibat1u, ibat1l; - u32 dbat2u, dbat2l, ibat2u, ibat2l; - u32 dbat3u, dbat3l, ibat3u, ibat3l; - u32 msr, hid0, l2cr_reg; - - __asm volatile ("mfdbatu %0,0" : "=r" (dbat0u)); - __asm volatile ("mfdbatl %0,0" : "=r" (dbat0l)); - __asm volatile ("mfibatu %0,0" : "=r" (ibat0u)); - __asm volatile ("mfibatl %0,0" : "=r" (ibat0l)); - - __asm volatile ("mfdbatu %0,1" : "=r" (dbat1u)); - __asm volatile ("mfdbatl %0,1" : "=r" (dbat1l)); - __asm volatile ("mfibatu %0,1" : "=r" (ibat1u)); - __asm volatile ("mfibatl %0,1" : "=r" (ibat1l)); - - __asm volatile ("mfdbatu %0,2" : "=r" (dbat2u)); - __asm volatile ("mfdbatl %0,2" : "=r" (dbat2l)); - __asm volatile ("mfibatu %0,2" : "=r" (ibat2u)); - __asm volatile ("mfibatl %0,2" : "=r" (ibat2l)); - - __asm volatile ("mfdbatu %0,3" : "=r" (dbat3u)); - __asm volatile ("mfdbatl %0,3" : "=r" (dbat3l)); - __asm volatile ("mfibatu %0,3" : "=r" (ibat3u)); - __asm volatile ("mfibatl %0,3" : "=r" (ibat3l)); - - __asm volatile ("mfmsr %0" : "=r" (msr)); - __asm volatile ("mfspr %0,1008": "=r" (hid0)); - __asm volatile ("mfspr %0,1017": "=r" (l2cr_reg)); - - printf("dbat0u: %08x dbat0l: %08x ibat0u: %08x ibat0l: %08x\n", - dbat0u, dbat0l, ibat0u, ibat0l); - printf("dbat1u: %08x dbat1l: %08x ibat1u: %08x ibat1l: %08x\n", - dbat1u, dbat1l, ibat1u, ibat1l); - printf("dbat2u: %08x dbat2l: %08x ibat2u: %08x ibat2l: %08x\n", - dbat2u, dbat2l, ibat2u, ibat2l); - printf("dbat3u: %08x dbat3l: %08x ibat3u: %08x ibat3l: %08x\n", - dbat3u, dbat3l, ibat3u, ibat3l); - - printf("\nMSR: %08x HID0: %08x L2CR: %08x \n", msr,hid0, l2cr_reg); -} - - -void remove_init_data(void) -{ - char *s; - - /* Invalidate and disable data cache */ - invalidate_l1_data_cache(); - dcache_disable(); - - s = getenv("x86_cache"); - - if (!s) - { - icache_enable(); - dcache_enable(); - } - else if (s) - { - if (strcmp(s, "dcache")==0) - { - dcache_enable(); - } - else if (strcmp(s, "icache") == 0) - { - icache_enable(); - } - else if (strcmp(s, "on")== 0 || strcmp(s, "both") == 0) - { - dcache_enable(); - icache_enable(); - } - } - - /* show_bat_mapping();*/ -} diff --git a/board/MAI/bios_emulator/glue.h b/board/MAI/bios_emulator/glue.h deleted file mode 100644 index 585efe1286..0000000000 --- a/board/MAI/bios_emulator/glue.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef GLUE_H -#define GLUE_H - -typedef unsigned int pci_dev_t; - -int mypci_find_device(int vendor, int product, int index); -int mypci_bus(int device); -int mypci_devfn(int device); -unsigned long get_bar_size(pci_dev_t dev, int offset); - -u8 mypci_read_cfg_byte(int bus, int devfn, int offset); -u16 mypci_read_cfg_word(int bus, int devfn, int offset); -u32 mypci_read_cfg_long(int bus, int devfn, int offset); - -void mypci_write_cfg_byte(int bus, int devfn, int offset, u8 value); -void mypci_write_cfg_word(int bus, int devfn, int offset, u16 value); -void mypci_write_cfg_long(int bus, int devfn, int offset, u32 value); - -void _printf(const char *fmt, ...); -char *_getenv(char *name); - -void *malloc(size_t size); -void memset(void *addr, int value, size_t size); -void memcpy(void *to, void *from, size_t numbytes); -int strcmp(char *, char *); - -void enable_compatibility_hole(void); -void disable_compatibility_hole(void); - -void map_rom(pci_dev_t dev, unsigned long address); -void unmap_rom(pci_dev_t dev); -int attempt_map_rom(pci_dev_t dev, void *copy_address); - -#define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */ -#define PCI_BASE_ADDRESS_SPACE_IO 0x01 -#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00 -#define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL) - -#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */ -#define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */ -#define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */ -#define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */ -#define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */ -#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */ -#define PCI_BUS(d) (((d) >> 16) & 0xff) -#define PCI_DEV(d) (((d) >> 11) & 0x1f) -#define PCI_FUNC(d) (((d) >> 8) & 0x7) -#define PCI_BDF(b,d,f) ((b) << 16 | (d) << 11 | (f) << 8) - -#define PCI_ANY_ID (~0) -#define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */ -#define PCI_ROM_ADDRESS_ENABLE 0x01 - -#define OFF(addr) ((addr) & 0xFFFF) -#define SEG(addr) (((addr)>>4) &0xF000) - -#endif diff --git a/board/MAI/bios_emulator/scitech/bin/bc31-d16.bat b/board/MAI/bios_emulator/scitech/bin/bc31-d16.bat deleted file mode 100755 index 776d13820f..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc31-d16.bat +++ /dev/null @@ -1,28 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 3.1. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS16\BC3;%BC3_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS16\BC3;%BC3_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BC3_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC3.MK -SET USE_DPMI16= -SET USE_WIN16= -SET USE_WIN32= -SET USE_SNAP= -PATH %SCITECH_BIN%;%BC3_PATH%\BIN;%DEFPATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC3_PATH%\BIN\turboc.cfg -echo -L%LIB% >> %BC3_PATH%\BIN\turboc.cfg -echo -L%LIB% > %BC3_PATH%\BIN\tlink.cfg - -echo Borland C++ 3.1 DOS compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bc45-c32.bat b/board/MAI/bios_emulator/scitech/bin/bc45-c32.bat deleted file mode 100755 index d2939f458a..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc45-c32.bat +++ /dev/null @@ -1,37 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 4.5 in 32 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\BC4;%BC4_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\BC4;%BC4_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BC4_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_VXD= -SET USE_TNT= -SET USE_BC5= -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC4 -PATH %SCITECH_BIN%;%BC4_PATH%\BIN;%DEFPATH%%BC_CD_PATH% - -REM: Enable Win32 SDK if desired (sdk on command line) -if NOT .%1%==.sdk goto createfiles -call win32sdk.bat borland - -:createfiles -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC4_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BC4_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BC4_PATH%\BIN\tlink32.cfg - -echo Borland C++ 4.5 32 bit Windows compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bc45-d16.bat b/board/MAI/bios_emulator/scitech/bin/bc45-d16.bat deleted file mode 100755 index 246517d103..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc45-d16.bat +++ /dev/null @@ -1,32 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 4.5 in 16 bit mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS16\BC4;%BC4_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS16\BC4;%BC4_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BC4_PATH%\INCLUDE -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC16.MK -SET USE_DPMI16= -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD= -SET USE_BC5= -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC4 -PATH %SCITECH_BIN%;%BC4_PATH%\BIN;%DEFPATH%%BC_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC4_PATH%\BIN\turboc.cfg -echo -L%LIB% >> %BC4_PATH%\BIN\turboc.cfg -echo -L%LIB% > %BC4_PATH%\BIN\tlink.cfg - -echo Borland C++ 4.5 16 bit DOS compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bc45-d32.bat b/board/MAI/bios_emulator/scitech/bin/bc45-d32.bat deleted file mode 100755 index cbb2c79510..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc45-d32.bat +++ /dev/null @@ -1,33 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 4.5 in 32 bit mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\BC4;%BC4_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS32\BC4;%BC4_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BC4_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_DPMI16= -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD= -SET USE_TNT= -SET USE_BC5= -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC4 -PATH %SCITECH_BIN%;%BC4_PATH%\BIN;%DEFPATH%%BC_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC4_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BC4_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BC4_PATH%\BIN\tlink32.cfg - -echo Borland C++ 4.5 32 bit DOS compilation configuration set up (DPMI32). diff --git a/board/MAI/bios_emulator/scitech/bin/bc45-snp.bat b/board/MAI/bios_emulator/scitech/bin/bc45-snp.bat deleted file mode 100755 index 14d7c05b14..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc45-snp.bat +++ /dev/null @@ -1,32 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 4.5 in 32 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\SNAP\BC4;%BC4_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\SNAP\BC4;%BC4_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD= -SET USE_TNT= -SET USE_BC5= -SET WIN32_GUI= -SET USE_SNAP=1 -SET BC_LIBBASE=BC4 -PATH %SCITECH_BIN%;%BC4_PATH%\BIN;%DEFPATH%%BC_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC4_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BC4_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BC4_PATH%\BIN\tlink32.cfg - -echo Borland C++ 4.5 Snap compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bc45-tnt.bat b/board/MAI/bios_emulator/scitech/bin/bc45-tnt.bat deleted file mode 100755 index 50bd3cb5d8..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc45-tnt.bat +++ /dev/null @@ -1,46 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 4.5 in 32 bit mode with Phar Lap TNT - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\BC4;%BC4_PATH%\LIB;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS32\BC4;%BC4_PATH%\LIB;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BC4_PATH%\INCLUDE;%TNT_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_DPMI16= -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD= -SET USE_TNT=1 -SET USE_BC5= -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC4 -PATH %SCITECH_BIN%;%BC4_PATH%\BIN;%TNT_PATH%\BIN;%DEFPATH%%BC_CD_PATH% - -REM If you set the following to a 1, a TNT DosStyle app will be created. -REM Otherwise a TNT NtStyle app will be created. NtStyle apps will *only* -REM run under real DOS when using our libraries, since we require access -REM to functions that the Win32 API does not support (such as direct access -REM to video memory, calling Int 10h BIOS functions etc). DosStyle apps -REM will however run fine in both DOS and a Win95 DOS box (NT DOS boxes don't -REM work too well). -REM -REM If you are using the RealTime DOS extender, your apps *must* be NtStyle, -REM and hence will never be able to run under Win95 or WinNT, only DOS. - -SET DOSSTYLE= - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC4_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BC4_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BC4_PATH%\BIN\tlink32.cfg - -echo Borland C++ 4.5 32 bit DOS compilation configuration set up (TNT). diff --git a/board/MAI/bios_emulator/scitech/bin/bc45-vxd.bat b/board/MAI/bios_emulator/scitech/bin/bc45-vxd.bat deleted file mode 100755 index 4b59fa422e..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc45-vxd.bat +++ /dev/null @@ -1,32 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 4.5 in 32 bit Windows VxD mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\VXD\BC4;%BC4_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\VXD\BC4;%BC4_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BC4_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD=1 -SET USE_TNT= -SET USE_BC5= -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC4 -PATH %SCITECH_BIN%;%BC4_PATH%\BIN;%DEFPATH%%BC_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC4_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BC4_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BC4_PATH%\BIN\tlink32.cfg - -echo Borland C++ 4.5 32-bit VxD compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bc45-w16.bat b/board/MAI/bios_emulator/scitech/bin/bc45-w16.bat deleted file mode 100755 index 4d799b47b6..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc45-w16.bat +++ /dev/null @@ -1,32 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 4.5 in 16 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN16\BC4;%BC4_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN16\BC4;%BC4_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BC4_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC16.MK -SET USE_DPMI16= -SET USE_WIN16=1 -SET USE_WIN32= -SET USE_VXD= -SET USE_BC5= -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC4 -PATH %SCITECH_BIN%;%BC4_PATH%\BIN;%DEFPATH%%BC_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC4_PATH%\BIN\turboc.cfg -echo -L%LIB% >> %BC4_PATH%\BIN\turboc.cfg -echo -L%LIB% > %BC4_PATH%\BIN\tlink.cfg - -echo Borland C++ 4.5 16 bit Windows compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bc45-w32.bat b/board/MAI/bios_emulator/scitech/bin/bc45-w32.bat deleted file mode 100755 index a6c199fe9a..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc45-w32.bat +++ /dev/null @@ -1,37 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 4.5 in 32 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\BC4;%BC4_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\BC4;%BC4_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BC4_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_VXD= -SET USE_TNT= -SET USE_BC5= -SET WIN32_GUI=1 -SET USE_SNAP= -SET BC_LIBBASE=BC4 -PATH %SCITECH_BIN%;%BC4_PATH%\BIN;%DEFPATH%%BC_CD_PATH% - -REM: Enable Win32 SDK if desired (sdk on command line) -if NOT .%1%==.sdk goto createfiles -call win32sdk.bat borland - -:createfiles -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC4_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BC4_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BC4_PATH%\BIN\tlink32.cfg - -echo Borland C++ 4.5 32 bit Windows compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bc50-c32.bat b/board/MAI/bios_emulator/scitech/bin/bc50-c32.bat deleted file mode 100755 index 6a0fde2c9e..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc50-c32.bat +++ /dev/null @@ -1,40 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 5.0 in 32 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\BC5;%BC5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\BC5;%BC5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET C_INCLUDE=%BC5_PATH%\INCLUDE -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%C_INCLUDE% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_VXD= -SET USE_TNT= -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BC5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Enable Win32 SDK if desired (sdk on command line) -if NOT .%1%==.sdk goto createfiles -call win32sdk.bat borland - -:createfiles -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BC5_PATH%\BIN\tlink32.cfg - -echo Borland C++ 5.0 32 bit Windows compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bc50-d16.bat b/board/MAI/bios_emulator/scitech/bin/bc50-d16.bat deleted file mode 100755 index 23b50389de..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc50-d16.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 5.0 in 16 bit mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS16\BC5;%BC5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS16\BC5;%BC5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BC5_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC16.MK -SET USE_DPMI16= -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD= -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BC5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC5_PATH%\BIN\turboc.cfg -echo -L%LIB% >> %BC5_PATH%\BIN\turboc.cfg -echo -L%LIB% > %BC5_PATH%\BIN\tlink.cfg - -echo Borland C++ 5.0 16 bit DOS compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bc50-d32.bat b/board/MAI/bios_emulator/scitech/bin/bc50-d32.bat deleted file mode 100755 index 0521f93cec..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc50-d32.bat +++ /dev/null @@ -1,35 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 5.0 in 32 bit mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\BC5;%BC5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS32\BC5;%BC5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BC5_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_DPMI16= -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD= -SET USE_TNT= -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BC5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BC5_PATH%\BIN\tlink32.cfg - -echo Borland C++ 5.0 32 bit DOS compilation configuration set up (DPMI32). diff --git a/board/MAI/bios_emulator/scitech/bin/bc50-smx.bat b/board/MAI/bios_emulator/scitech/bin/bc50-smx.bat deleted file mode 100755 index e3241ffae3..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc50-smx.bat +++ /dev/null @@ -1,35 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 5.0 in 32 bit mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\SMX32\BC5;%BC5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\SMX32\BC5;%BC5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BC5_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_DPMI16= -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD= -SET USE_TNT= -SET USE_SMX32=1 -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BC5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BC5_PATH%\BIN\tlink32.cfg - -echo Borland C++ 5.0 32 bit SMX compilation configuration set up (SMX32). diff --git a/board/MAI/bios_emulator/scitech/bin/bc50-snp.bat b/board/MAI/bios_emulator/scitech/bin/bc50-snp.bat deleted file mode 100755 index ab3acd23c4..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc50-snp.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 5.0 in 32 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\SNAP\BC5;%BC5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\SNAP\BC5;%BC5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD= -SET USE_TNT= -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI= -SET USE_SNAP=1 -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BC5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BC5_PATH%\BIN\tlink32.cfg - -echo Borland C++ 5.0 Snap compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bc50-tnt.bat b/board/MAI/bios_emulator/scitech/bin/bc50-tnt.bat deleted file mode 100755 index 4dcc3723be..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc50-tnt.bat +++ /dev/null @@ -1,48 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 5.0 in 32 bit mode with Phar Lap TNT - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\BC5;%BC5_PATH%\LIB;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS32\BC5;%BC5_PATH%\LIB;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BC5_PATH%\INCLUDE;%TNT_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_DPMI16= -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD= -SET USE_TNT=1 -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BC5_PATH%\BIN;%TNT_PATH%\BIN;%DEFPATH%%BC_CD_PATH% - -REM If you set the following to a 1, a TNT DosStyle app will be created. -REM Otherwise a TNT NtStyle app will be created. NtStyle apps will *only* -REM run under real DOS when using our libraries, since we require access -REM to functions that the Win32 API does not support (such as direct access -REM to video memory, calling Int 10h BIOS functions etc). DosStyle apps -REM will however run fine in both DOS and a Win95 DOS box (NT DOS boxes don't -REM work too well). -REM -REM If you are using the RealTime DOS extender, your apps *must* be NtStyle, -REM and hence will never be able to run under Win95 or WinNT, only DOS. - -SET DOSSTYLE= - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BC5_PATH%\BIN\tlink32.cfg - -echo Borland C++ 5.0 32 bit DOS compilation configuration set up (TNT). diff --git a/board/MAI/bios_emulator/scitech/bin/bc50-vxd.bat b/board/MAI/bios_emulator/scitech/bin/bc50-vxd.bat deleted file mode 100755 index 2356911aba..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc50-vxd.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 5.0 in 32 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\VXD\BC5;%BC5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\VXD\BC5;%BC5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BC5_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD=1 -SET USE_TNT= -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BC5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BC5_PATH%\BIN\tlink32.cfg - -echo Borland C++ 5.0 32 bit Windows (VxD) compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bc50-w16.bat b/board/MAI/bios_emulator/scitech/bin/bc50-w16.bat deleted file mode 100755 index cd79d86b8f..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc50-w16.bat +++ /dev/null @@ -1,34 +0,0 @@ - @echo off -REM Setup for compiling with Borland C++ 5.0 in 16 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN16\BC5;%BC5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN16\BC5;%BC5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BC5_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC16.MK -SET USE_DPMI16= -SET USE_WIN16=1 -SET USE_WIN32= -SET USE_VXD= -SET USE_BC5=1 -SET USE_SMX32= -SET USE_SMX16= -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BC5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC5_PATH%\BIN\turboc.cfg -echo -L%LIB% >> %BC5_PATH%\BIN\turboc.cfg -echo -L%LIB% > %BC5_PATH%\BIN\tlink.cfg - -echo Borland C++ 5.0 16 bit Windows compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bc50-w32.bat b/board/MAI/bios_emulator/scitech/bin/bc50-w32.bat deleted file mode 100755 index 8b8cec9436..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc50-w32.bat +++ /dev/null @@ -1,40 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 5.0 in 32 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\BC5;%BC5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\BC5;%BC5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET C_INCLUDE=%BC5_PATH%\INCLUDE -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%C_INCLUDE% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_VXD= -SET USE_TNT= -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI=1 -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BC5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Enable Win32 SDK if desired (sdk on command line) -if NOT .%1%==.sdk goto createfiles -call win32sdk.bat borland - -:createfiles -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BC5_PATH%\BIN\tlink32.cfg - -echo Borland C++ 5.0 32 bit Windows compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bc50-x11.bat b/board/MAI/bios_emulator/scitech/bin/bc50-x11.bat deleted file mode 100755 index ebfeb2eb64..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bc50-x11.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ 5.0 in 32 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\BC5;%BC5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\BC5;%BC5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BC5_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_VXD= -SET USE_TNT= -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI=1 -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BC5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BC5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BC5_PATH%\BIN\tlink32.cfg - -echo Borland C++ 5.0 32 bit Windows compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bcb5-c32.bat b/board/MAI/bios_emulator/scitech/bin/bcb5-c32.bat deleted file mode 100755 index 6e09428816..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bcb5-c32.bat +++ /dev/null @@ -1,40 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ Builder 5.0 in 32 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\BCB5;%BCB5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\BCB5;%BCB5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET C_INCLUDE=%BCB5_PATH%\INCLUDE -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%C_INCLUDE% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_VXD= -SET USE_TNT= -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BCB5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Enable Win32 SDK if desired (sdk on command line) -if NOT .%1%==.sdk goto createfiles -call win32sdk.bat borland - -:createfiles -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BCB5_PATH%\BIN\tlink32.cfg - -echo Borland C++ Builder 5.0 32 bit Windows compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bcb5-d16.bat b/board/MAI/bios_emulator/scitech/bin/bcb5-d16.bat deleted file mode 100755 index aa13e7dd20..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bcb5-d16.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ Builder 5.0 in 16 bit mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS16\BCB5;%BCB5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS16\BCB5;%BCB5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BCB5_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC16.MK -SET USE_DPMI16= -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD= -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BCB5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BCB5_PATH%\BIN\turboc.cfg -echo -L%LIB% >> %BCB5_PATH%\BIN\turboc.cfg -echo -L%LIB% > %BCB5_PATH%\BIN\tlink.cfg - -echo Borland C++ Builder 5.0 16 bit DOS compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bcb5-d32.bat b/board/MAI/bios_emulator/scitech/bin/bcb5-d32.bat deleted file mode 100755 index d0017d4ccb..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bcb5-d32.bat +++ /dev/null @@ -1,35 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ Builder 5.0 in 32 bit mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\BCB5;%BCB5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS32\BCB5;%BCB5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BCB5_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_DPMI16= -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD= -SET USE_TNT= -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BCB5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BCB5_PATH%\BIN\tlink32.cfg - -echo Borland C++ Builder 5.0 32 bit DOS compilation configuration set up (DPMI32). diff --git a/board/MAI/bios_emulator/scitech/bin/bcb5-smx.bat b/board/MAI/bios_emulator/scitech/bin/bcb5-smx.bat deleted file mode 100755 index 2b969a93ba..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bcb5-smx.bat +++ /dev/null @@ -1,35 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ Builder 5.0 in 32 bit mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\SMX32\BCB5;%BCB5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\SMX32\BCB5;%BCB5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BCB5_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_DPMI16= -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD= -SET USE_TNT= -SET USE_SMX32=1 -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BCB5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BCB5_PATH%\BIN\tlink32.cfg - -echo Borland C++ Builder 5.0 32 bit SMX compilation configuration set up (SMX32). diff --git a/board/MAI/bios_emulator/scitech/bin/bcb5-snp.bat b/board/MAI/bios_emulator/scitech/bin/bcb5-snp.bat deleted file mode 100755 index d7b8ff20a8..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bcb5-snp.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ Builder 5.0 in 32 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\SNAP\BCB5;%BCB5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\SNAP\BCB5;%BCB5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD= -SET USE_TNT= -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI= -SET USE_SNAP=1 -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BCB5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BCB5_PATH%\BIN\tlink32.cfg - -echo Borland C++ Builder 5.0 Snap compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bcb5-tnt.bat b/board/MAI/bios_emulator/scitech/bin/bcb5-tnt.bat deleted file mode 100755 index 1de3601a59..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bcb5-tnt.bat +++ /dev/null @@ -1,48 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ Builder 5.0 in 32 bit mode with Phar Lap TNT - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\BCB5;%BCB5_PATH%\LIB;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS32\BCB5;%BCB5_PATH%\LIB;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BCB5_PATH%\INCLUDE;%TNT_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_DPMI16= -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD= -SET USE_TNT=1 -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BCB5_PATH%\BIN;%TNT_PATH%\BIN;%DEFPATH%%BC_CD_PATH% - -REM If you set the following to a 1, a TNT DosStyle app will be created. -REM Otherwise a TNT NtStyle app will be created. NtStyle apps will *only* -REM run under real DOS when using our libraries, since we require access -REM to functions that the Win32 API does not support (such as direct access -REM to video memory, calling Int 10h BIOS functions etc). DosStyle apps -REM will however run fine in both DOS and a Win95 DOS box (NT DOS boxes don't -REM work too well). -REM -REM If you are using the RealTime DOS extender, your apps *must* be NtStyle, -REM and hence will never be able to run under Win95 or WinNT, only DOS. - -SET DOSSTYLE= - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BCB5_PATH%\BIN\tlink32.cfg - -echo Borland C++ Builder 5.0 32 bit DOS compilation configuration set up (TNT). diff --git a/board/MAI/bios_emulator/scitech/bin/bcb5-vxd.bat b/board/MAI/bios_emulator/scitech/bin/bcb5-vxd.bat deleted file mode 100755 index 28de58c3f0..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bcb5-vxd.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ Builder 5.0 in 32 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\VXD\BCB5;%BCB5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\VXD\BCB5;%BCB5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BCB5_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_WIN16= -SET USE_WIN32= -SET USE_VXD=1 -SET USE_TNT= -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BCB5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BCB5_PATH%\BIN\tlink32.cfg - -echo Borland C++ Builder 5.0 32 bit Windows (VxD) compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bcb5-w16.bat b/board/MAI/bios_emulator/scitech/bin/bcb5-w16.bat deleted file mode 100755 index c30d004081..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bcb5-w16.bat +++ /dev/null @@ -1,34 +0,0 @@ - @echo off -REM Setup for compiling with Borland C++ Builder 5.0 in 16 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN16\BCB5;%BCB5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN16\BCB5;%BCB5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BCB5_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC16.MK -SET USE_DPMI16= -SET USE_WIN16=1 -SET USE_WIN32= -SET USE_VXD= -SET USE_BC5=1 -SET USE_SMX32= -SET USE_SMX16= -SET WIN32_GUI= -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BCB5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BCB5_PATH%\BIN\turboc.cfg -echo -L%LIB% >> %BCB5_PATH%\BIN\turboc.cfg -echo -L%LIB% > %BCB5_PATH%\BIN\tlink.cfg - -echo Borland C++ Builder 5.0 16 bit Windows compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bcb5-w32.bat b/board/MAI/bios_emulator/scitech/bin/bcb5-w32.bat deleted file mode 100755 index 18760e1128..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bcb5-w32.bat +++ /dev/null @@ -1,40 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ Builder 5.0 in 32 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\BCB5;%BCB5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\BCB5;%BCB5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET C_INCLUDE=%BCB5_PATH%\INCLUDE -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%C_INCLUDE% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_VXD= -SET USE_TNT= -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI=1 -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BCB5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Enable Win32 SDK if desired (sdk on command line) -if NOT .%1%==.sdk goto createfiles -call win32sdk.bat borland - -:createfiles -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BCB5_PATH%\BIN\tlink32.cfg - -echo Borland C++ Builder 5.0 32 bit Windows compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/bcb5-x11.bat b/board/MAI/bios_emulator/scitech/bin/bcb5-x11.bat deleted file mode 100755 index 198c1a2425..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/bcb5-x11.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Borland C++ Builder 5.0 in 32 bit Windows mode. - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\BCB5;%BCB5_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\BCB5;%BCB5_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%BCB5_PATH%\INCLUDE; -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\BC32.MK -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_VXD= -SET USE_TNT= -SET USE_SMX32= -SET USE_SMX16= -SET USE_BC5=1 -SET WIN32_GUI=1 -SET USE_SNAP= -SET BC_LIBBASE=BC5 -PATH %SCITECH_BIN%;%BCB5_PATH%\BIN;%DEFPATH%%BC5_CD_PATH% - -REM: Create Borland compile/link configuration scripts -echo -I%INCLUDE% > %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% >> %BCB5_PATH%\BIN\bcc32.cfg -echo -L%LIB% > %BCB5_PATH%\BIN\tlink32.cfg - -echo Borland C++ Builder 5.0 32 bit Windows compilation configuration set up. diff --git a/board/MAI/bios_emulator/scitech/bin/build b/board/MAI/bios_emulator/scitech/bin/build deleted file mode 100755 index ff1973dc81..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/build +++ /dev/null @@ -1,22 +0,0 @@ -#! /bin/sh - -if [ $# -lt 1 ] || ( [ "$1" != gcc-linux ] && [ "$1" != qnx4 ] ) ; then - echo Usage: $0 compiler_name [DMAKE commands] - echo - echo Current compilers: - echo " gcc-linux - GNU C/C++ 2.7 or higher, 32 bit" - echo " qnx4 - Watcom C/C++ 10.6 or higher, 32 bit" - exit 1 -fi - -unset DBG OPT OPT_SIZE BUILD_DLL IMPORT_DLL FPU CHECKS BETA -. ${1}.sh - -shift -dmake $* && exit 0 - -echo ************************************************* -echo * An error occurred while building the library. * -echo ************************************************* -exit 1 - diff --git a/board/MAI/bios_emulator/scitech/bin/build.bat b/board/MAI/bios_emulator/scitech/bin/build.bat deleted file mode 100755 index ee29093631..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/build.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -rem Disable checked build and build release code -set CHECKED= -call build_it.bat %1 %2 %3 %4 %5 %6 %7 %8 %9 diff --git a/board/MAI/bios_emulator/scitech/bin/build_db.bat b/board/MAI/bios_emulator/scitech/bin/build_db.bat deleted file mode 100755 index 2b325293ab..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/build_db.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -rem Enable checked build and build debug code -set CHECKED=1 -call build_it.bat %1 %2 %3 %4 %5 %6 %7 %8 %9 diff --git a/board/MAI/bios_emulator/scitech/bin/build_it.bat b/board/MAI/bios_emulator/scitech/bin/build_it.bat deleted file mode 100755 index 5a619b4459..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/build_it.bat +++ /dev/null @@ -1,432 +0,0 @@ -@echo off -rem Generic batch file to build a version of the library. This batch file -rem assumes that the correct batch files exist to setup the appropriate -rem compilation environments, and that the DMAKE.EXE program is available -rem somewhere on the path. -rem -rem Builds as release or debug depending on the value of the CHECKED -rem environment variable. - -rem Unset all environment variables that change the compile process -set DBG= -set OPT= -set OPT_SIZE= -set BUILD_DLL= -set IMPORT_DLL= -set FPU= -set CHECKS= -set BETA= - -if %1==bc31-d16 goto bc31-d16 -if %1==bc45-d16 goto bc45-d16 -if %1==bc45-d32 goto bc45-d32 -if %1==bc45-tnt goto bc45-tnt -if %1==bc45-w16 goto bc45-w16 -if %1==bc45-w32 goto bc45-w32 -if %1==bc45-c32 goto bc45-c32 -if %1==bc45-vxd goto bc45-vxd -if %1==bc45-snp goto bc45-snp -if %1==bc50-d16 goto bc50-d16 -if %1==bc50-d32 goto bc50-d32 -if %1==bc50-tnt goto bc50-tnt -if %1==bc50-w16 goto bc50-w16 -if %1==bc50-w32 goto bc50-w32 -if %1==bc50-c32 goto bc50-c32 -if %1==bc50-vxd goto bc50-vxd -if %1==bc50-snp goto bc50-snp -if %1==gcc2-d32 goto gcc2-d32 -if %1==gcc2-w32 goto gcc2-w32 -if %1==gcc2-c32 goto gcc2-c32 -if %1==gcc2-linux goto gcc2-linux -if %1==vc40-d16 goto vc40-d16 -if %1==vc40-tnt goto vc40-tnt -if %1==vc40-w16 goto vc40-w16 -if %1==vc40-w32 goto vc40-w32 -if %1==vc40-c32 goto vc40-c32 -if %1==vc40-drv9x goto vc40-drv9x -if %1==vc40-drvnt goto vc40-drvnt -if %1==vc40-rtt goto vc40-rtt -if %1==vc40-snp goto vc40-snp -if %1==vc50-d16 goto vc50-d16 -if %1==vc50-tnt goto vc50-tnt -if %1==vc50-w16 goto vc50-w16 -if %1==vc50-w32 goto vc50-w32 -if %1==vc50-c32 goto vc50-c32 -if %1==vc50-drv9x goto vc50-drv9x -if %1==vc50-drvnt goto vc50-drvnt -if %1==vc50-rtt goto vc50-rtt -if %1==vc50-snp goto vc50-snp -if %1==vc60-d16 goto vc60-d16 -if %1==vc60-tnt goto vc60-tnt -if %1==vc60-w16 goto vc60-w16 -if %1==vc60-w32 goto vc60-w32 -if %1==vc60-c32 goto vc60-c32 -if %1==vc60-drv9x goto vc60-drv9x -if %1==vc60-drvnt goto vc60-drvnt -if %1==vc60-drvw2k goto vc60-drvw2k -if %1==vc60-rtt goto vc60-rtt -if %1==vc60-snp goto vc60-snp -if %1==wc10ad16 goto wc10ad16 -if %1==wc10ad32 goto wc10ad32 -if %1==wc10atnt goto wc10atnt -if %1==wc10aw16 goto wc10aw16 -if %1==wc10aw32 goto wc10aw32 -if %1==wc10ac32 goto wc10ac32 -if %1==wc10ao32 goto wc10ao32 -if %1==wc10ap32 goto wc10ap32 -if %1==wc10asnp goto wc10asnp -if %1==wc10-d16 goto wc10-d16 -if %1==wc10-d32 goto wc10-d32 -if %1==wc10-tnt goto wc10-tnt -if %1==wc10-w16 goto wc10-w16 -if %1==wc10-w32 goto wc10-w32 -if %1==wc10-c32 goto wc10-c32 -if %1==wc10-o32 goto wc10-o32 -if %1==wc10-p32 goto wc10-p32 -if %1==wc10-snp goto wc10-snp -if %1==wc11-d16 goto wc11-d16 -if %1==wc11-d32 goto wc11-d32 -if %1==wc11-tnt goto wc11-tnt -if %1==wc11-w16 goto wc11-w16 -if %1==wc11-w32 goto wc11-w32 -if %1==wc11-c32 goto wc11-c32 -if %1==wc11-o32 goto wc11-o32 -if %1==wc11-p32 goto wc11-p32 -if %1==wc11-snp goto wc11-snp - -echo Usage: BUILD 'compiler_name' [DMAKE commands] -echo. -echo Where 'compiler_name' is of the form comp-os, where -echo 'comp' defines the compiler and 'os' defines the OS environment. -echo For instance 'bc50-w32' is for Borland C++ 5.0 for Win32. -echo The value of 'comp' can be any of the following: -echo. -echo bc45 - Borland C++ 4.5x -echo bc50 - Borland C++ 5.x -echo vc40 - Visual C++ 4.x -echo vc50 - Visual C++ 5.x -echo vc60 - Visual C++ 6.x -echo wc10 - Watcom C++ 10.6 -echo wc11 - Watcom C++ 11.0 -echo gcc2 - GNU C/C++ 2.9x -echo. -echo The value of 'os' can be one of the following: -echo. -echo d16 - 16-bit DOS -echo d32 - 32-bit DOS -echo w16 - 16-bit Windows GUI mode -echo c32 - 32-bit Windows console mode -echo w32 - 32-bit Windows GUI mode -echo o16 - 16-bit OS/2 console mode -echo o32 - 32-bit OS/2 console mode -echo p32 - 32-bit OS/2 Presentation Manager -echo snp - 32-bit SciTech Snap application -echo linux - 32-bit Linux application -goto end - -rem ------------------------------------------------------------------------- -rem Setup for the specified compiler - -:bc31-d16 -call bc31-d16.bat -goto compileit - -:bc45-d16 -call bc45-d16.bat -goto compileit - -:bc45-d32 -call bc45-d32.bat -goto compileit - -:bc45-tnt -call bc45-tnt.bat -goto compileit - -:bc45-w16 -call bc45-w16.bat -goto compileit - -:bc45-w32 -call bc45-w32.bat -goto compileit - -:bc45-c32 -call bc45-c32.bat -goto compileit - -:bc45-vxd -call bc45-vxd.bat -goto compileit - -:bc50-d16 -call bc50-d16.bat -goto compileit - -:bc50-d32 -call bc50-d32.bat -goto compileit - -:bc50-tnt -call bc50-tnt.bat -goto compileit - -:bc50-w16 -call bc50-w16.bat -goto compileit - -:bc50-w32 -call bc50-w32.bat -goto compileit - -:bc50-c32 -call bc50-c32.bat -goto compileit - -:bc50-vxd -call bc50-vxd.bat -goto compileit - -:gcc2-d32 -call gcc2-d32.bat -goto compileit - -:gcc2-w32 -call gcc2-w32.bat -goto compileit - -:gcc2-c32 -call gcc2-c32.bat -goto compileit - -:gcc2-linux -call gcc2-linux.bat -goto compileit - -:sc70-d16 -call sc70-d16.bat -goto compileit - -:sc70-w16 -call sc70-w16.bat -goto compileit - -:sc70-tnt -call sc70-tnt.bat -goto compileit - -:sc70-w32 -call sc70-w32.bat -goto compileit - -:sc70-c32 -call sc70-c32.bat -goto compileit - -:vc40-d16 -call vc40-d16.bat -goto compileit - -:vc40-tnt -call vc40-tnt.bat -goto compileit - -:vc40-w16 -call vc40-w16.bat -goto compileit - -:vc40-w32 -call vc40-w32.bat -goto compileit - -:vc40-c32 -call vc40-c32.bat -goto compileit - -:vc40-drv9x -call vc40-drv9x.bat -goto compileit - -:vc40-drvnt -call vc40-drvnt.bat -goto compileit - -:vc40-rtt -call vc40-rtt.bat -goto compileit - -:vc50-d16 -call vc50-d16.bat -goto compileit - -:vc50-tnt -call vc50-tnt.bat -goto compileit - -:vc50-w16 -call vc50-w16.bat -goto compileit - -:vc50-w32 -call vc50-w32.bat -goto compileit - -:vc50-c32 -call vc50-c32.bat -goto compileit - -:vc50-drv9x -call vc50-drv9x.bat -goto compileit - -:vc50-drvnt -call vc50-drvnt.bat -goto compileit - -:vc50-rtt -call vc50-rtt.bat -goto compileit - -:vc60-d16 -call vc60-d16.bat -goto compileit - -:vc60-tnt -call vc60-tnt.bat -goto compileit - -:vc60-w16 -call vc60-w16.bat -goto compileit - -:vc60-w32 -call vc60-w32.bat -goto compileit - -:vc60-c32 -call vc60-c32.bat -goto compileit - -:vc60-drv9x -call vc60-drv9x.bat -goto compileit - -:vc60-drvnt -call vc60-drvnt.bat -goto compileit - -:vc60-drvw2k -call vc60-drvw2k.bat -goto compileit - -:vc60-rtt -call vc60-rtt.bat -goto compileit - -:wc10ad16 -call wc10ad16.bat -goto compileit - -:wc10ad32 -call wc10ad32.bat -goto compileit - -:wc10atnt -call wc10atnt.bat -goto compileit - -:wc10aw16 -call wc10aw16.bat -goto compileit - -:wc10aw32 -call wc10aw32.bat -goto compileit - -:wc10ac32 -call wc10ac32.bat -goto compileit - -:wc10ao32 -call wc10ao32.bat -goto compileit - -:wc10ap32 -call wc10ap32.bat -goto compileit - -:wc10-d16 -call wc10-d16.bat -goto compileit - -:wc10-d32 -call wc10-d32.bat -goto compileit - -:wc10-tnt -call wc10-tnt.bat -goto compileit - -:wc10-w16 -call wc10-w16.bat -goto compileit - -:wc10-w32 -call wc10-w32.bat -goto compileit - -:wc10-c32 -call wc10-c32.bat -goto compileit - -:wc10-o32 -call wc10-o32.bat -goto compileit - -:wc10-p32 -call wc10-p32.bat -goto compileit - -:wc11-d16 -call wc11-d16.bat -goto compileit - -:wc11-d32 -call wc11-d32.bat -goto compileit - -:wc11-tnt -call wc11-tnt.bat -goto compileit - -:wc11-w16 -call wc11-w16.bat -goto compileit - -:wc11-w32 -call wc11-w32.bat -goto compileit - -:wc11-c32 -call wc11-c32.bat -goto compileit - -:wc11-o32 -call wc11-o32.bat -goto compileit - -:wc11-p32 -call wc11-p32.bat -goto compileit - -:compileit -k_rm -f *.lib *.a -dmake %2 %3 %4 %5 %6 %7 %8 %9 -if errorlevel 1 goto errorend -goto end - -:errorend -echo ************************************************* -echo * An error occurred while building the library. * -echo ************************************************* -:end diff --git a/board/MAI/bios_emulator/scitech/bin/cddrv.bat b/board/MAI/bios_emulator/scitech/bin/cddrv.bat deleted file mode 100755 index b64f4d7463..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/cddrv.bat +++ /dev/null @@ -1,6 +0,0 @@ -@echo off -%1 -cd %3 -%4 %5 %6 %7 %8 %9 -%2 - diff --git a/board/MAI/bios_emulator/scitech/bin/cdit b/board/MAI/bios_emulator/scitech/bin/cdit deleted file mode 100755 index b22023d54c..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/cdit +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/sh - -cd $1 -PROG=$2 -shift 2 -rm -f *.lib *.a -$PROG $* -RET=$? -cd .. -exit $RET diff --git a/board/MAI/bios_emulator/scitech/bin/cdit.bat b/board/MAI/bios_emulator/scitech/bin/cdit.bat deleted file mode 100755 index 950b648071..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/cdit.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off -cd %1 -k_rm -f *.lib *.a -shift 1 -%1 %2 %3 %4 %5 %6 %7 %8 %9 diff --git a/board/MAI/bios_emulator/scitech/bin/djgpp.env b/board/MAI/bios_emulator/scitech/bin/djgpp.env deleted file mode 100644 index 5a2c3d816a..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/djgpp.env +++ /dev/null @@ -1,46 +0,0 @@ -#= Don't edit this line unless you move djgpp.env outside -#= of the djgpp installation directory. If you do move -#= it, set DJDIR to the directory you installed DJGPP in. -#= -DJDIR=%:/>DJGPP% - -+USER=dosuser -+TMPDIR=%DJDIR%/tmp -+EMU387=%DJDIR%/bin/emu387.dxe -+LFN=y - -[bison] -BISON_HAIRY=%DJDIR%/lib/bison.hai -BISON_SIMPLE=%DJDIR%/lib/bison.sim - -[cpp] -CPLUS_INCLUDE_PATH=%/>;CPLUS_INCLUDE_PATH%include;%SCITECH%/include;%PRIVATE%/include;.;%DJDIR%/lang/cxx;%DJDIR%/include;%DJDIR%/contrib/grx20/include -C_INCLUDE_PATH=%/>;C_INCLUDE_PATH%include;%SCITECH%/include;%PRIVATE%/include;.;%DJDIR%/include;%DJDIR%/contrib/grx20/include -OBJCPLUS_INCLUDE_PATH=%/>;OBJCPLUS_INCLUDE_PATH%%DJDIR%/include;%DJDIR%/lang/objc -OBJC_INCLUDE_PATH=%/>;OBJC_INCLUDE_PATH%%DJDIR%/include;%DJDIR%/lang/objc - -[gcc] -COMPILER_PATH=%/>;COMPILER_PATH%%DJDIR%/bin -LIBRARY_PATH=%/>;LIBRARY_PATH%%DJDIR%/lib;%DJDIR%/contrib/grx20/lib;%SCITECH%/lib/release/dos32/dj2 - -[info] -INFOPATH=%/>;INFOPATH%%DJDIR%/info;%DJDIR%/gnu/emacs/info -INFO_COLORS=0x1f.0x31 - -[emacs] -INFOPATH=%/>;INFOPATH%%DJDIR%/info;%DJDIR%/gnu/emacs/info - -[less] -LESSBINFMT=*k<%X> -LESSCHARDEF=8bcccbcc12bc5b95.b127.b -LESS=%LESS% -h5$y5$Dd2.0$Du14.0$Ds4.7$Dk9.0$ - -[locate] -+LOCATE_PATH=%DJDIR%/lib/locatedb.dat - -[ls] -+LS_COLORS=no=00:fi=00:di=36:lb=37;07:cd=40;33;01:ex=32:*.cmd=32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.deb=01;31:*.jpg=01;34:*.gif=01;34:*.bmp=01;34:*.ppm=01;34:*.tga=01;34:*.xbm=01;34:*.xpm=01;34:*.tif=01;34:*.mpg=01;37:*.avi=01;37:*.gl=01;37:*.dl=01;37:*~=08:*.bak=08: -[dir] -+LS_COLORS=no=00:fi=00:di=36:lb=37;07:cd=40;33;01:ex=32:*.cmd=32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.deb=01;31:*.jpg=01;34:*.gif=01;34:*.bmp=01;34:*.ppm=01;34:*.tga=01;34:*.xbm=01;34:*.xpm=01;34:*.tif=01;34:*.mpg=01;37:*.avi=01;37:*.gl=01;37:*.dl=01;37:*~=08:*.bak=08: -[vdir] -+LS_COLORS=no=00:fi=00:di=36:lb=37;07:cd=40;33;01:ex=32:*.cmd=32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.deb=01;31:*.jpg=01;34:*.gif=01;34:*.bmp=01;34:*.ppm=01;34:*.tga=01;34:*.xbm=01;34:*.xpm=01;34:*.tif=01;34:*.mpg=01;37:*.avi=01;37:*.gl=01;37:*.dl=01;37:*~=08:*.bak=08: diff --git a/board/MAI/bios_emulator/scitech/bin/djgpp_db.env b/board/MAI/bios_emulator/scitech/bin/djgpp_db.env deleted file mode 100644 index 9b792c93e4..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/djgpp_db.env +++ /dev/null @@ -1,46 +0,0 @@ -#= Don't edit this line unless you move djgpp.env outside -#= of the djgpp installation directory. If you do move -#= it, set DJDIR to the directory you installed DJGPP in. -#= -DJDIR=%:/>DJGPP% - -+USER=dosuser -+TMPDIR=%DJDIR%/tmp -+EMU387=%DJDIR%/bin/emu387.dxe -+LFN=y - -[bison] -BISON_HAIRY=%DJDIR%/lib/bison.hai -BISON_SIMPLE=%DJDIR%/lib/bison.sim - -[cpp] -CPLUS_INCLUDE_PATH=%/>;CPLUS_INCLUDE_PATH%include;%SCITECH%/include;%PRIVATE%/include;.;%DJDIR%/lang/cxx;%DJDIR%/include;%DJDIR%/contrib/grx20/include -C_INCLUDE_PATH=%/>;C_INCLUDE_PATH%include;%SCITECH%/include;%PRIVATE%/include;.;%DJDIR%/include;%DJDIR%/contrib/grx20/include -OBJCPLUS_INCLUDE_PATH=%/>;OBJCPLUS_INCLUDE_PATH%%DJDIR%/include;%DJDIR%/lang/objc -OBJC_INCLUDE_PATH=%/>;OBJC_INCLUDE_PATH%%DJDIR%/include;%DJDIR%/lang/objc - -[gcc] -COMPILER_PATH=%/>;COMPILER_PATH%%DJDIR%/bin -LIBRARY_PATH=%/>;LIBRARY_PATH%%DJDIR%/lib;%DJDIR%/contrib/grx20/lib;%SCITECH%/lib/debug/dos32/dj2 - -[info] -INFOPATH=%/>;INFOPATH%%DJDIR%/info;%DJDIR%/gnu/emacs/info -INFO_COLORS=0x1f.0x31 - -[emacs] -INFOPATH=%/>;INFOPATH%%DJDIR%/info;%DJDIR%/gnu/emacs/info - -[less] -LESSBINFMT=*k<%X> -LESSCHARDEF=8bcccbcc12bc5b95.b127.b -LESS=%LESS% -h5$y5$Dd2.0$Du14.0$Ds4.7$Dk9.0$ - -[locate] -+LOCATE_PATH=%DJDIR%/lib/locatedb.dat - -[ls] -+LS_COLORS=no=00:fi=00:di=36:lb=37;07:cd=40;33;01:ex=32:*.cmd=32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.deb=01;31:*.jpg=01;34:*.gif=01;34:*.bmp=01;34:*.ppm=01;34:*.tga=01;34:*.xbm=01;34:*.xpm=01;34:*.tif=01;34:*.mpg=01;37:*.avi=01;37:*.gl=01;37:*.dl=01;37:*~=08:*.bak=08: -[dir] -+LS_COLORS=no=00:fi=00:di=36:lb=37;07:cd=40;33;01:ex=32:*.cmd=32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.deb=01;31:*.jpg=01;34:*.gif=01;34:*.bmp=01;34:*.ppm=01;34:*.tga=01;34:*.xbm=01;34:*.xpm=01;34:*.tif=01;34:*.mpg=01;37:*.avi=01;37:*.gl=01;37:*.dl=01;37:*~=08:*.bak=08: -[vdir] -+LS_COLORS=no=00:fi=00:di=36:lb=37;07:cd=40;33;01:ex=32:*.cmd=32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.deb=01;31:*.jpg=01;34:*.gif=01;34:*.bmp=01;34:*.ppm=01;34:*.tga=01;34:*.xbm=01;34:*.xpm=01;34:*.tif=01;34:*.mpg=01;37:*.avi=01;37:*.gl=01;37:*.dl=01;37:*~=08:*.bak=08: diff --git a/board/MAI/bios_emulator/scitech/bin/findint3.bat b/board/MAI/bios_emulator/scitech/bin/findint3.bat deleted file mode 100755 index 2e1506c2ce..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/findint3.bat +++ /dev/null @@ -1 +0,0 @@ -perl c:\scitech\src\perl\findint3.per diff --git a/board/MAI/bios_emulator/scitech/bin/gcc-beos.sh b/board/MAI/bios_emulator/scitech/bin/gcc-beos.sh deleted file mode 100755 index 61ffd93507..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/gcc-beos.sh +++ /dev/null @@ -1,16 +0,0 @@ -#! /bin/sh - -# Setup for compiling with GCC/G++ for BeOS - -if [ "$CHECKED" = "1" ]; then - echo Checked debug build enabled. -else - echo Release build enabled. -fi - -export MAKESTARTUP=$SCITECH/makedefs/gcc_beos.mk -export INCLUDE="-Iinclude -I$SCITECH/include -I$PRIVATE/include" -export USE_X11=0 -export USE_BEOS=1 - -echo GCC BeOS console compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/gcc-freebsd.sh b/board/MAI/bios_emulator/scitech/bin/gcc-freebsd.sh deleted file mode 100755 index 3816a5dca7..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/gcc-freebsd.sh +++ /dev/null @@ -1,16 +0,0 @@ -#! /bin/sh - -# Setup for compiling with GCC/G++ for FreeBSD - -if [ "$CHECKED" = "1" ]; then - echo Checked debug build enabled. -else - echo Release build enabled. -fi - -export MAKESTARTUP=$SCITECH/makedefs/gcc_freebsd.mk -export INCLUDE="-Iinclude -I$SCITECH/include -I$PRIVATE/include" -export USE_X11=1 -export USE_FREEBSD=1 - -echo GCC FreeBSD console compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/gcc-linux.sh b/board/MAI/bios_emulator/scitech/bin/gcc-linux.sh deleted file mode 100755 index 27a4c49065..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/gcc-linux.sh +++ /dev/null @@ -1,19 +0,0 @@ -#! /bin/sh - -# Setup for compiling with GCC/G++ for Linux - -if [ "$CHECKED" = "1" ]; then - echo Checked debug build enabled. -else - echo Release build enabled. -fi - -export MAKESTARTUP=$SCITECH/makedefs/gcc_linux.mk -export INCLUDE="include;$SCITECH/include;$PRIVATE/include" -export USE_LINUX=1 - -if [ "x$LIBC" = x ]; then - echo "GCC Linux console compilation environment set up (glib)" -else - echo "GCC Linux console compilation environment set up (libc5)" -fi diff --git a/board/MAI/bios_emulator/scitech/bin/gcc2-c32.bat b/board/MAI/bios_emulator/scitech/bin/gcc2-c32.bat deleted file mode 100755 index 13c4783699..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/gcc2-c32.bat +++ /dev/null @@ -1,26 +0,0 @@ -@echo off -REM Setup for compiling with GNU C compiler - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\release\win32\gcc2 -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\debug\win32\gcc2 -echo Checked debug build enabled. -goto setvars - -:setvars -set INCLUDE=include;%SCITECH%\include;%PRIVATE%\include -set MAKESTARTUP=%SCITECH%\makedefs\gcc_win32.mk -set MAKE_MODE= -set USE_WIN16= -set USE_WIN32=1 -set WIN32_GUI= -set USE_SNAP= -set GCC_LIBBASE=gcc2 -PATH %SCITECH_BIN%;%GCC2_PATH%\NATIVE\BIN;%DEFPATH% - -echo GCC 2.9.x 32-bit Win32 console compilation environment set up - diff --git a/board/MAI/bios_emulator/scitech/bin/gcc2-dos.bat b/board/MAI/bios_emulator/scitech/bin/gcc2-dos.bat deleted file mode 100755 index 97cb8bda13..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/gcc2-dos.bat +++ /dev/null @@ -1,28 +0,0 @@ -@echo off -REM Setup for compiling with DJGPP 2.02 - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\release\dos32\dj2 -%SCITECH%\bin-dos\k_cp %SCITECH%\BIN\DJGPP.ENV %DJ_PATH%\DJGPP.ENV -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\debug\dos32\dj2 -%SCITECH%\bin-dos\k_cp %SCITECH%\BIN\DJGPP_DB.ENV %DJ_PATH%\DJGPP.ENV -echo Checked debug build enabled. -goto setvars - -:setvars -set DJGPP=%DJ_PATH%\DJGPP.ENV -set INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%DJ_PATH%\INCLUDE; -set MAKESTARTUP=%SCITECH%\MAKEDEFS\DJ32.MK -set USE_WIN16= -set USE_WIN32= -set WIN32_GUI= -set USE_SNAP= -set DJ_LIBBASE=dj2 -PATH %SCITECH_BIN%;%DJ_PATH%\BIN;%DEFPATH% - -echo DJGPP 2.02 32-bit DOS compilation environment set up (DPMI). - diff --git a/board/MAI/bios_emulator/scitech/bin/gcc2-linux.bat b/board/MAI/bios_emulator/scitech/bin/gcc2-linux.bat deleted file mode 100755 index ceb2ab84e9..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/gcc2-linux.bat +++ /dev/null @@ -1,26 +0,0 @@ -@echo off -REM Setup for compiling with GNU C cross-compiler - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\release\win32\gcc2 -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\debug\win32\gcc2 -echo Checked debug build enabled. -goto setvars - -:setvars -set INCLUDE=include;%SCITECH%\include;%PRIVATE%\include -set MAKESTARTUP=%SCITECH%\MAKEDEFS\gcc_linux.mk -set MAKE_MODE=UNIX -set USE_WIN16= -set USE_WIN32= -set WIN32_GUI= -set USE_SNAP= -set GCC_LIBBASE=gcc2 -PATH %SCITECH_BIN%;%GCC2_PATH%\cross-linux\i386-redhat-linux\BIN;%DEFPATH% - -echo GCC 2.9.x 32-bit Linux console cross compilation environment set up - diff --git a/board/MAI/bios_emulator/scitech/bin/gcc2-w32.bat b/board/MAI/bios_emulator/scitech/bin/gcc2-w32.bat deleted file mode 100755 index bdb31aaf5d..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/gcc2-w32.bat +++ /dev/null @@ -1,26 +0,0 @@ -@echo off -REM Setup for compiling with GNU C compiler - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\release\win32\gcc2 -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\debug\win32\gcc2 -echo Checked debug build enabled. -goto setvars - -:setvars -set INCLUDE=include;%SCITECH%\include;%PRIVATE%\include -set MAKESTARTUP=%SCITECH%\makedefs\gcc_win32.mk -set MAKE_MODE= -set USE_WIN16= -set USE_WIN32=1 -set WIN32_GUI=1 -set USE_SNAP= -set GCC_LIBBASE=gcc2 -PATH %SCITECH_BIN%;%GCC2_PATH%\NATIVE\BIN;%DEFPATH% - -echo GCC 2.9.x 32-bit Win32 GUI compilation environment set up - diff --git a/board/MAI/bios_emulator/scitech/bin/makelib.bat b/board/MAI/bios_emulator/scitech/bin/makelib.bat deleted file mode 100755 index 631673483c..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/makelib.bat +++ /dev/null @@ -1,97 +0,0 @@ -call wc11-d32.bat - -cd c:\private\src\license -dmake clean -dmake depend -dmake -u install -cd c:\scitech\src\pm -dmake clean -dmake depend -dmake -u install -cd c:\scitech\src\console -dmake clean -dmake depend -dmake -u install -cd c:\scitech\src\nucleus -dmake clean -dmake depend -dmake -u install -cd c:\scitech\src\zlib -dmake clean -dmake depend -dmake -u install - -cd c:\private\src\graphics\ref2d -dmake clean -dmake depend -dmake -u install -cd c:\private\src\drvlib -dmake clean -dmake depend -dmake -u install - -call wc11-w32.bat - -cd c:\private\src\license -dmake clean -dmake depend -dmake -u install -cd c:\scitech\src\pm -dmake clean -dmake depend -dmake -u install -cd c:\scitech\src\console -dmake clean -dmake depend -dmake -u install -cd c:\scitech\src\nucleus -dmake clean -dmake depend -dmake -u install -cd c:\scitech\src\zlib -dmake clean -dmake depend -dmake -u install - -cd c:\private\src\graphics\ref2d -dmake clean -dmake depend -dmake -u install -cd c:\private\src\drvlib -dmake clean -dmake depend -dmake -u install - -call wc10-d32.bat - -cd c:\private\src\license -dmake clean -dmake depend -dmake -u install -cd c:\scitech\src\pm -dmake clean -dmake depend -dmake -u install -cd c:\scitech\src\console -dmake clean -dmake depend -dmake -u install -cd c:\scitech\src\nucleus -dmake clean -dmake depend -dmake -u install -cd c:\scitech\src\zlib -dmake clean -dmake depend -dmake -u install - -cd c:\private\src\graphics\ref2d -dmake clean -dmake depend -dmake -u install -cd c:\private\src\drvlib -dmake clean -dmake depend -dmake -u install - -cd \private\src\graphics\drivers diff --git a/board/MAI/bios_emulator/scitech/bin/meltobjs.sh b/board/MAI/bios_emulator/scitech/bin/meltobjs.sh deleted file mode 100755 index fd1804b70f..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/meltobjs.sh +++ /dev/null @@ -1,23 +0,0 @@ -#! /bin/sh -# -# This script generates a single object file from a set of libraries (*.a files) -# Usage: meltobjs.sh target.o library1.a library2.a ... -# -# (C) SciTech Software, Inc. 1998 -# - -TMPDIR=/tmp/melt$$ -TARGET=$1 -TARGETDIR=$PWD -shift -mkdir $TMPDIR - -cd $TMPDIR - -for a in $* -do - ar x $a -done -ld -r -o $TARGETDIR/$TARGET *.o - -rm -fr $TMPDIR \ No newline at end of file diff --git a/board/MAI/bios_emulator/scitech/bin/ntddk.bat b/board/MAI/bios_emulator/scitech/bin/ntddk.bat deleted file mode 100755 index 07c0d78505..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/ntddk.bat +++ /dev/null @@ -1,42 +0,0 @@ -@echo off -REM: Set up environment variables for Microsoft Windows NT DDK development. -REM: Note that we have hard coded this for Windows NT i386 development. - -SET USE_NTDRV=1 -SET USE_W2KDRV= -SET BASEDIR=%NT_DDKROOT% -SET PATH=%BASEDIR%\bin;%PATH% -SET NTMAKEENV=%BASEDIR%\inc -SET BUILD_MAKE_PROGRAM=nmake.exe -SET BUILD_DEFAULT=-ei -nmake -i -SET BUILD_DEFAULT_TARGETS=-386 -SET _OBJ_DIR=obj -SET NEW_CRTS=1 -SET _NTROOT=%BASEDIR% -SET INCLUDE=%BASEDIR%\inc;%INCLUDE% - -if .%CHECKED%==.1 goto checked - -REM: set up an NT free build environment -SET DDKBUILDENV=free -SET C_DEFINES=-D_IDWBUILD -SET NTDBGFILES=1 -SET NTDEBUG= -SET NTDEBUGTYPE= -SET MSC_OPTIMIZATION= -set LIB=%BASEDIR%\lib\i386\free;%SCITECH_LIB%\LIB\RELEASE\NTDRV\VC6;%MSVCDir%\LIB;. - -goto done - -:checked - -REM: set up an NT checked build environment -SET DDKBUILDENV=checked -SET C_DEFINES=-D_IDWBUILD -DRDRDBG -DSRVDBG -SET NTDBGFILES= -SET NTDEBUG=ntsd -SET NTDEBUGTYPE=both -SET MSC_OPTIMIZATION=/Od /Oi -set LIB=%BASEDIR%\lib\i386\free;%SCITECH_LIB%\LIB\DEBUG\NTDRV\VC6;%MSVCDir%\LIB;. - -:done diff --git a/board/MAI/bios_emulator/scitech/bin/qnx4.sh b/board/MAI/bios_emulator/scitech/bin/qnx4.sh deleted file mode 100755 index 843c4d9fb3..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/qnx4.sh +++ /dev/null @@ -1,18 +0,0 @@ -#! /bin/sh - -# Setup for compiling with Watcom C/C++ for QNX4 - -if [ "$CHECKED" = "1" ]; then - echo Checked debug build enabled. -else - echo Release build enabled. -fi - -export MAKESTARTUP=$SCITECH/makedefs/qnx4.mk -export INCLUDE="-I$SCITECH/include -I$PRIVATE/include -I/usr/include" -export USE_QNX=1 -export USE_QNX4=1 -export WC_LIBBASE=wc10 - -echo Qnx 4 console compilation environment set up - diff --git a/board/MAI/bios_emulator/scitech/bin/qnxnto.sh b/board/MAI/bios_emulator/scitech/bin/qnxnto.sh deleted file mode 100755 index c114f9e337..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/qnxnto.sh +++ /dev/null @@ -1,21 +0,0 @@ -#! /bin/sh - -# Setup for compiling with Watcom C/C++ for QNX Neutrino - -if [ "$CHECKED" = "1" ]; then - echo Checked debug build enabled. -else - echo Release build enabled. -fi - -if [ X$GCC_PATH = "X" ]; then - export GCC_PATH=/usr/gcc/bin -fi - -export MAKESTARTUP=$SCITECH/makedefs/qnxnto.mk -export INCLUDE="-I$SCITECH/include -I$PRIVATE/include -I/usr/nto/include" -export USE_BIOS=1 # VBIOS lib is tiny under Neutrino, always include it -export USE_QNX=1 -export USE_QNXNTO=1 - -echo Qnx Neutrino console compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/set-vars-beos.sh b/board/MAI/bios_emulator/scitech/bin/set-vars-beos.sh deleted file mode 100755 index 0a272d6a46..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/set-vars-beos.sh +++ /dev/null @@ -1,42 +0,0 @@ -#! /bin/sh - -# BeOS VERSION -# Set the place where SciTech Software is installed, and where each -# of the supported compilers is installed. These environment variables -# are used by the batch files in the SCITECH\BIN directory. -# -# Modify the as appropriate for your compiler configuration (you should -# only need to change things in this batch file). -# -# This version is for a normal BeOS installation. - -# The SCITECH variable points to where batch files, makefile startups, -# include files and source files will be found when compiling. - -export SCITECH=$MGL_ROOT - -# The SCITECH_LIB variable points to where the SciTech libraries live -# for installation and linking. This allows you to have the source and -# include files on local machines for compiling and have the libraries -# located on a common network machine (for network builds). - -export SCITECH_LIB=$SCITECH - -# The PRIVATE variable points to where private source files reside that -# do not live in the public source tree - -export PRIVATE=$HOME/private - -# The following define the locations of all the compilers that you may -# be using. Change them to reflect where you have installed your -# compilers. - -export GCC_PATH=/boot/develop/tools/gnupro/bin - -# Add the Scitech bin path to the current PATH -export PATH=$SCITECH/bin:$SCITECH/bin-beos:$PATH -#if [ "x$LIBC" = x ]; then -# export PATH=$PATH:$SCITECH/bin-beos/glibc -#else -# export PATH=$PATH:$SCITECH/bin-beos/libc -#fi diff --git a/board/MAI/bios_emulator/scitech/bin/set-vars-freebsd.sh b/board/MAI/bios_emulator/scitech/bin/set-vars-freebsd.sh deleted file mode 100755 index c920748a7f..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/set-vars-freebsd.sh +++ /dev/null @@ -1,37 +0,0 @@ -#! /bin/sh - -# LINUX VERSION -# Set the place where SciTech Software is installed, and where each -# of the supported compilers is installed. These environment variables -# are used by the batch files in the SCITECH\BIN directory. -# -# Modify the as appropriate for your compiler configuration (you should -# only need to change things in this batch file). -# -# This version is for a normal Linux installation. - -# The SCITECH variable points to where batch files, makefile startups, -# include files and source files will be found when compiling. - -export SCITECH=$MGL_ROOT - -# The SCITECH_LIB variable points to where the SciTech libraries live -# for installation and linking. This allows you to have the source and -# include files on local machines for compiling and have the libraries -# located on a common network machine (for network builds). - -export SCITECH_LIB=$SCITECH - -# The PRIVATE variable points to where private source files reside that -# do not live in the public source tree - -export PRIVATE=$HOME/private - -# The following define the locations of all the compilers that you may -# be using. Change them to reflect where you have installed your -# compilers. - -export GCC_PATH=/usr/bin - -# Add the Scitech bin path to the current PATH -export PATH=$SCITECH/bin:$SCITECH/bin-freebsd:$PATH diff --git a/board/MAI/bios_emulator/scitech/bin/set-vars-linux.sh b/board/MAI/bios_emulator/scitech/bin/set-vars-linux.sh deleted file mode 100755 index 35cbf1dc16..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/set-vars-linux.sh +++ /dev/null @@ -1,43 +0,0 @@ -#! /bin/sh - -# LINUX VERSION -# Set the place where SciTech Software is installed, and where each -# of the supported compilers is installed. These environment variables -# are used by the batch files in the SCITECH\BIN directory. -# -# Modify the as appropriate for your compiler configuration (you should -# only need to change things in this batch file). -# -# This version is for a normal Linux installation. - -# The SCITECH variable points to where batch files, makefile startups, -# include files and source files will be found when compiling. - -export SCITECH=$MGL_ROOT - -# The SCITECH_LIB variable points to where the SciTech libraries live -# for installation and linking. This allows you to have the source and -# include files on local machines for compiling and have the libraries -# located on a common network machine (for network builds). - -export SCITECH_LIB=$SCITECH - -# The PRIVATE variable points to where private source files reside that -# do not live in the public source tree - -export PRIVATE=$HOME/private - -# The following define the locations of all the compilers that you may -# be using. Change them to reflect where you have installed your -# compilers. - -export GCC_PATH=/usr/bin -export TEMP=/tmp TMP=/tmp - -# Add the Scitech bin path to the current PATH -export PATH=$SCITECH/bin:$SCITECH/bin-linux:$PATH -if [ "x$LIBC" = x ]; then - export PATH=$SCITECH/bin-linux/glibc:$PATH -else - export PATH=$SCITECH/bin-linux/libc:$PATH -fi diff --git a/board/MAI/bios_emulator/scitech/bin/set-vars-qnx.sh b/board/MAI/bios_emulator/scitech/bin/set-vars-qnx.sh deleted file mode 100755 index 1d73109ea4..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/set-vars-qnx.sh +++ /dev/null @@ -1,37 +0,0 @@ -#! /bin/sh - -# QNX 4 VERSION -# Set the place where SciTech Software is installed, and where each -# of the supported compilers is installed. These environment variables -# are used by the batch files in the SCITECH\BIN directory. -# -# Modify the as appropriate for your compiler configuration (you should -# only need to change things in this batch file). -# -# This version is for a normal Linux installation. - -# The SCITECH variable points to where batch files, makefile startups, -# include files and source files will be found when compiling. - -export SCITECH=$MGL_ROOT - -# The SCITECH_LIB variable points to where the SciTech libraries live -# for installation and linking. This allows you to have the source and -# include files on local machines for compiling and have the libraries -# located on a common network machine (for network builds). - -export SCITECH_LIB=$SCITECH - -# The PRIVATE variable points to where private source files reside that -# do not live in the public source tree - -export PRIVATE=$HOME/private - -# The following define the locations of all the compilers that you may -# be using. Change them to reflect where you have installed your -# compilers. - -export WC10_PATH=/usr/watcom/10.6/usr - -# Add the Scitech bin path to the current PATH -export PATH=$SCITECH/bin:$SCITECH/bin-qnx:$PATH diff --git a/board/MAI/bios_emulator/scitech/bin/set-vars.bat b/board/MAI/bios_emulator/scitech/bin/set-vars.bat deleted file mode 100755 index 2a2101d4b4..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/set-vars.bat +++ /dev/null @@ -1,110 +0,0 @@ -@echo off -REM:========================================================================= -REM: Master batch file to set up all necessary environment variables for -REM: the SciTech makefile utilities. This batch file should be executed -REM: *first* before any other batch files when you start a command shell. -REM: You should not need to modify any batch files except this one to -REM: configure the makefile utilities. -REM:========================================================================= - -REM: Set the place where SciTech Software is installed, and where each -REM: of the supported compilers is installed. These environment variables -REM: are used by the batch files in the SCITECH\BIN directory. -REM: -REM: Modify the as appropriate for your compiler configuration (you should -REM: only need to change things in this batch file). -REM: -REM: This version is for a normal MSDOS installation. - -REM: The SCITECH variable points to where batch files, makefile startups, -REM: include files and source files will be found when compiling. - -SET SCITECH=c:\scitech - -REM: The SCITECH_LIB variable points to where the SciTech libraries live -REM: for installation and linking. This allows you to have the source and -REM: include files on local machines for compiling and have the libraries -REM: located on a common network machine (for network builds). - -SET SCITECH_LIB=%SCITECH% - -REM: The PRIVATE variable points to where private source files reside that -REM: do not live in the public source tree - -SET PRIVATE=c:\private - -REM: The following sets up the path to the SciTech command line utilities -REM: for the development operating system. We select either DOS hosted -REM: tools or Win32 hosted tools depending on whether you are running -REM: on NT or not. Windows 9x users can use the Win32 hosted tools but -REM: they run slower, but you will have long filenames if you do this. - -IF .%OS%==.Windows_NT goto Win32_path -IF NOT .%WINDIR%==. goto Win32_path -SET SCITECH_BIN=%SCITECH%\bin;%SCITECH%\bin-dos -goto path_set - -REM: The following sets up the path to the SciTech command line utilities -REM: for the development operating system. This version uses the Win32 -REM: hosted tools by default, so you can use long filenames. - -:Win32_path -SET SCITECH_BIN=%SCITECH%\bin;%SCITECH%\bin-win32 - -:path_set - -REM: Set the TMP variable for dmake if this is not already set - -SET TMP=%SCITECH% - -REM: Set the following environment variable to use the Netwide Assembler -REM: (NASM) provided with the MGL tools to build all assembler modules. -REM: If you have Turbo Assembler 4.0 or later and you wish to use it, -REM: you can use it by removing the following line. - -SET USE_NASM=1 - -REM: The following is used to set up DDK directories for device driver -REM: development. They can safely be ignored unless you are using the -REM: SciTech makefile utilities to build device drivers. - -SET DDKDRIVE=c: -SET MSSDK=c:\c\win32sdk -SET W95_DDKROOT=c:\c\95ddk -SET W98_DDKROOT=c:\c\98ddk -SET NT_DDKROOT=c:\c\ntddk -SET W2K_DDKROOT=c:\c\2000ddk -SET MASM_ROOT=c:\c\masm611 -SET VTOOLSD=c:\c\vtd95 -SET SOFTICE_PATH=c:\c\sint - -REM: The following define the locations of all the compilers that you may -REM: be using. Change them to reflect where you have installed your -REM: compilers. - -SET BC3_PATH=c:\c\bc3 -SET BC4_PATH=c:\c\bc45 -SET BC5_PATH=c:\c\bc50 -SET BCB5_PATH=c:\c\bcb50 -SET VC_PATH=c:\c\msvc -SET VC4_PATH=c:\c\vc42 -SET VC5_PATH=c:\c\vc50 -SET VC6_PATH=c:\c\vc60 -SET SC70_PATH=c:\c\sc75 -SET WC10A_PATH=c:\c\wc10a -SET WC10_PATH=c:\c\wc10 -SET WC11_PATH=c:\c\wc11 -SET TNT_PATH=c:\c\tnt -SET DJ_PATH=c:\c\djgpp -SET GCC2_PATH=c:\unix\usr - -REM: The following define the locations of the IDE and compiler path -REM: tools for Visual C++. If you do a standard installation, you wont -REM: need to change this. If however you did a custom install and changed -REM: the paths to these directory, you will need to modify this to suit. - -SET VC5_MSDevDir=%VC5_PATH%\sharedide -SET VC5_MSVCDir=%VC5_PATH%\vc -SET VC6_MSDevDir=%VC6_PATH%\common\msdev98 -SET VC6_MSVCDir=%VC6_PATH%\vc98 - diff --git a/board/MAI/bios_emulator/scitech/bin/vc40-c32.bat b/board/MAI/bios_emulator/scitech/bin/vc40-c32.bat deleted file mode 100755 index 71f7d8e10d..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc40-c32.bat +++ /dev/null @@ -1,36 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 4.2 32 bit edition - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\VC4;%VC4_PATH%\LIB;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\VC4;%VC4_PATH%\LIB;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%VC4_PATH% -set C_INCLUDE=%VC4_PATH%\INCLUDE;%TNT_PATH%\INCLUDE; -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%C_INCLUDE% -set INIT=%VC4_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_TNT= -SET USE_WIN16= -SET USE_WIN32=1 -SET WIN32_GUI= -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=VC4 -PATH %SCITECH_BIN%;%VC4_PATH%\BIN;%TNT_PATH%\BIN;%DEFPATH%%VC32_CD_PATH% - -REM: Enable Win32 SDK if desired (sdk on command line) -if NOT .%1%==.sdk goto done -call win32sdk.bat - -:done -echo Visual C++ 4.2 32 bit Windows compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc40-d16.bat b/board/MAI/bios_emulator/scitech/bin/vc40-d16.bat deleted file mode 100755 index 9817493e37..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc40-d16.bat +++ /dev/null @@ -1,27 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 1.52c 16 bit edition - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\DOS16\VC4;%VC_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\DOS16\VC4;%VC_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%VC_PATH% -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%VC_PATH%\INCLUDE; -set INIT=%VC_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC16.MK -SET USE_WIN16= -SET USE_WIN32= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=VC4 -PATH %SCITECH_BIN%;%VC_PATH%\BIN;%DEFPATH%%VC_CD_PATH% - -echo Visual C++ 1.52c 16 DOS bit compilation environment set up. - diff --git a/board/MAI/bios_emulator/scitech/bin/vc40-drv9x.bat b/board/MAI/bios_emulator/scitech/bin/vc40-drv9x.bat deleted file mode 100755 index 62e35214e9..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc40-drv9x.bat +++ /dev/null @@ -1,21 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 4.2 32 bit edition - -REM: First setup for Win32 console development -call vc40-c32.bat > NUL - -REM: Extra stuff to set up for Windows 9x DDK development -set MASTER_MAKE=1 -set DDKROOT=%W95_DDKROOT% -set SDKROOT=%MSSDK% -set C16_ROOT=%VC_PATH% -set C32_ROOT=%VC4_PATH% - -if .%CHECKED%==.1 goto checked_build -echo Release build enabled. -goto done -:checked_build -echo Checked debug build enabled. -goto done -:done -echo Visual C++ 4.2 Windows 9x driver compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc40-drvnt.bat b/board/MAI/bios_emulator/scitech/bin/vc40-drvnt.bat deleted file mode 100755 index 83b67802df..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc40-drvnt.bat +++ /dev/null @@ -1,18 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 4.2 32 bit edition - -REM: First setup for Win32 console development (with Platform SDK) -call vc40-c32.bat sdk > NUL - -REM: Extra stuff to set up for Windows NT DDK development -SET BASEDIR=%NT_DDKROOT% -SET PATH=%NT_DDKROOT%\bin;%PATH% - -if .%CHECKED%==.1 goto checked_build -echo Release build enabled. -goto done -:checked_build -echo Checked debug build enabled. -goto done -:done -echo Visual C++ 4.2 Windows NT driver compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc40-snp.bat b/board/MAI/bios_emulator/scitech/bin/vc40-snp.bat deleted file mode 100755 index 7997044f82..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc40-snp.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 4.2 32 bit edition - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\SNAP\VC4;%VC4_PATH%\LIB;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\SNAP\VC4;%VC4_PATH%\LIB;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%VC4_PATH% -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE -set INIT=%VC4_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_TNT= -SET USE_WIN16= -SET USE_WIN32= -SET WIN32_GUI= -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET= -SET USE_SNAP=1 -SET VC_LIBBASE=VC4 -PATH %SCITECH_BIN%;%VC4_PATH%\BIN;%TNT_PATH%\BIN;%DEFPATH%%VC32_CD_PATH% - -echo Visual C++ 4.2 Snap compilation environment set up - diff --git a/board/MAI/bios_emulator/scitech/bin/vc40-tnt.bat b/board/MAI/bios_emulator/scitech/bin/vc40-tnt.bat deleted file mode 100755 index b0fc93675b..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc40-tnt.bat +++ /dev/null @@ -1,42 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 4.2 32 bit edition - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\VC4;%VC4_PATH%\LIB;%TNT_PATH%\COFFLIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\DOS32\VC4;%VC4_PATH%\LIB;%TNT_PATH%\COFFLIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%VC4_PATH% -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%VC4_PATH%\INCLUDE;%TNT_PATH%\INCLUDE; -set INIT=%VC4_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_WIN16= -SET USE_WIN32= -SET USE_TNT= -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=VC4 -PATH %SCITECH_BIN%;%VC4_PATH%\BIN;%TNT_PATH%\BIN;%DEFPATH%%VC32_CD_PATH% - -REM If you set the following to a 1, a TNT DosStyle app will be created. -REM Otherwise a TNT NtStyle app will be created. NtStyle apps will *only* -REM run under real DOS when using our libraries, since we require access -REM to functions that the Win32 API does not support (such as direct access -REM to video memory, calling Int 10h BIOS functions etc). DosStyle apps -REM will however run fine in both DOS and a Win95 DOS box (NT DOS boxes don't -REM work too well). -REM -REM If you are using the RealTime DOS extender, your apps *must* be NtStyle, -REM and hence will never be able to run under Win95 or WinNT, only DOS. - -SET DOSSTYLE= - -echo Visual C++ 4.2 32-bit DOS compilation environment set up (TNT). diff --git a/board/MAI/bios_emulator/scitech/bin/vc40-w16.bat b/board/MAI/bios_emulator/scitech/bin/vc40-w16.bat deleted file mode 100755 index 2849a20e75..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc40-w16.bat +++ /dev/null @@ -1,26 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 1.52c 16 bit edition - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\WIN16\VC4;%VC_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\WIN16\VC4;%VC_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%VC_PATH% -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%VC_PATH%\INCLUDE; -set INIT=%VC_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC16.MK -SET USE_WIN16=1 -SET USE_WIN32= -SET VC_LIBBASE=VC4 -SET USE_RTTARGET= -SET USE_SNAP= -PATH %SCITECH_BIN%;%VC_PATH%\BIN;%DEFPATH%%VC_CD_PATH% - -echo Visual C++ 1.52c 16 bit Windows compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/vc40-w32.bat b/board/MAI/bios_emulator/scitech/bin/vc40-w32.bat deleted file mode 100755 index d93a6246e3..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc40-w32.bat +++ /dev/null @@ -1,37 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 4.2 32 bit edition - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\VC4;%VC4_PATH%\LIB;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\VC4;%VC4_PATH%\LIB;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%VC4_PATH% -set C_INCLUDE=%VC4_PATH%\INCLUDE;%TNT_PATH%\INCLUDE; -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%C_INCLUDE% -set INIT=%VC4_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_TNT= -SET USE_WIN16= -SET USE_WIN32=1 -SET WIN32_GUI=1 -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=VC4 -PATH %SCITECH_BIN%;%VC4_PATH%\BIN;%TNT_PATH%\BIN;%DEFPATH%%VC32_CD_PATH% - -REM: Enable Win32 SDK if desired (sdk on command line) -if NOT .%1%==.sdk goto done -call win32sdk.bat - -:done -echo Visual C++ 4.2 32 bit Windows compilation environment set up - diff --git a/board/MAI/bios_emulator/scitech/bin/vc40-x11.bat b/board/MAI/bios_emulator/scitech/bin/vc40-x11.bat deleted file mode 100755 index a420a54eab..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc40-x11.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 4.2 32 bit edition - -SET LIB=%VC4_PATH%\LIB;. -SET TOOLROOTDIR=%VC4_PATH% -SET INCLUDE=\xc\include;%VC4_PATH%\INCLUDE -SET INIT=%VC4_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_TNT= -SET USE_WIN16= -SET USE_WIN32=1 -SET WIN32_GUI=1 -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=VC4 -PATH %SCITECH_BIN%;%VC4_PATH%\BIN;%DEFPATH% - -echo Visual C++ 4.2 X11 compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc50-c32.bat b/board/MAI/bios_emulator/scitech/bin/vc50-c32.bat deleted file mode 100755 index 62d27b9bc7..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc50-c32.bat +++ /dev/null @@ -1,39 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 5.0 32 bit edition - -SET MSDevDir=%VC5_MSDevDir% -SET MSVCDir=%VC5_MSVCDir% - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\VC5;%MSVCDir%\LIB;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\VC5;%MSVCDir%\LIB;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%MSVCDir% -set C_INCLUDE=%MSVCDir%\INCLUDE;%TNT_PATH%\INCLUDE; -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%C_INCLUDE% -set INIT=%MSVCDir% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_TNT= -SET USE_WIN16= -SET USE_WIN32=1 -SET WIN32_GUI= -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=vc5 -PATH %SCITECH_BIN%;%MSVCDir%\BIN;%MSDevDir%\BIN;%TNT_PATH%\BIN;%DEFPATH%%VC32_CD_PATH% - -REM: Enable Win32 SDK if desired (sdk on command line) -if NOT .%1%==.sdk goto done -call win32sdk.bat - -:done -echo Visual C++ 5.0 32-bit Windows console compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc50-d16.bat b/board/MAI/bios_emulator/scitech/bin/vc50-d16.bat deleted file mode 100755 index c789c5037d..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc50-d16.bat +++ /dev/null @@ -1,26 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 1.52c 16 bit edition - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\DOS16\VC5;%VC_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\DOS16\VC5;%VC_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%VC_PATH% -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%VC_PATH%\INCLUDE; -set INIT=%VC_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC16.MK -SET USE_WIN16= -SET USE_WIN32= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=vc5 -PATH %SCITECH_BIN%;%VC_PATH%\BIN;%DEFPATH%%VC_CD_PATH% - -echo Visual C++ 1.52c 16-bit DOS compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/vc50-drv9x.bat b/board/MAI/bios_emulator/scitech/bin/vc50-drv9x.bat deleted file mode 100755 index 27a4a1439f..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc50-drv9x.bat +++ /dev/null @@ -1,21 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 6.0 32 bit edition - -REM: First setup for Win32 console development -call vc60-c32.bat > NUL - -REM: Extra stuff to set up for Windows 9x DDK development -set MASTER_MAKE=1 -set DDKROOT=%W95_DDKROOT% -set SDKROOT=%MSSDK% -set C16_ROOT=%VC_PATH% -set C32_ROOT=%VC6_PATH% - -if .%CHECKED%==.1 goto checked_build -echo Release build enabled. -goto done -:checked_build -echo Checked debug build enabled. -goto done -:done -echo Visual C++ 6.0 Windows 9x driver compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc50-drvnt.bat b/board/MAI/bios_emulator/scitech/bin/vc50-drvnt.bat deleted file mode 100755 index 17b2f25cc7..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc50-drvnt.bat +++ /dev/null @@ -1,17 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 6.0 32 bit edition - -REM: First setup for Win32 console development (with Platform SDK) -call vc60-c32.bat sdk > NUL - -REM: Now setup stuff for the NT DDK build environment -call ntddk.bat - -if .%CHECKED%==.1 goto checked_build -echo Release build enabled. -goto done -:checked_build -echo Checked debug build enabled. -goto done -:done -echo Visual C++ 6.0 Windows NT driver compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc50-rtt.bat b/board/MAI/bios_emulator/scitech/bin/vc50-rtt.bat deleted file mode 100755 index afb2fb186a..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc50-rtt.bat +++ /dev/null @@ -1,30 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 5.0 32 bit edition - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\VC5;%VC5_PATH%\VC\LIB;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\VC5;%VC5_PATH%\VC\LIB;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%VC5_PATH%\VC -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%VC5_PATH%\VC\INCLUDE;%TNT_PATH%\INCLUDE; -set INIT=%VC5_PATH%\VC -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_TNT= -SET USE_WIN16= -SET USE_WIN32= -SET WIN32_GUI= -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET=1 -SET USE_SNAP= -SET VC_LIBBASE=vc5 -PATH %SCITECH_BIN%;%VC5_PATH%\VC\BIN;%VC5_PATH%\SHAREDIDE\BIN;%TNT_PATH%\BIN;%DEFPATH%%VC32_CD_PATH% - -echo Visual C++ 5.0 RTTarget-32 compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc50-snp.bat b/board/MAI/bios_emulator/scitech/bin/vc50-snp.bat deleted file mode 100755 index 22d2e13c26..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc50-snp.bat +++ /dev/null @@ -1,33 +0,0 @@ -@echo off REM Setup environment variables for Visual C++ 5.0 32 bit -edition - -SET MSDevDir=%VC5_MSDevDir% -SET MSVCDir=%VC5_MSVCDir% - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\SNAP\VC5;%MSVCDir%\LIB;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\SNAP\VC5;%MSVCDir%\LIB;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%MSVCDir% -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE -set INIT=%MSVCDir% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_TNT= -SET USE_WIN16= -SET USE_WIN32= -SET WIN32_GUI= -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET= -SET USE_SNAP=1 -SET VC_LIBBASE=vc5 -PATH %SCITECH_BIN%;%MSVCDir%\BIN;%MSDevDir%\BIN;%TNT_PATH%\BIN;%DEFPATH%%VC32_CD_PATH% - -echo Visual C++ 5.0 Snap compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc50-tnt.bat b/board/MAI/bios_emulator/scitech/bin/vc50-tnt.bat deleted file mode 100755 index 6b09199054..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc50-tnt.bat +++ /dev/null @@ -1,42 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 5.0 32 bit edition - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\VC5;%VC5_PATH%\VC\LIB;%TNT_PATH%\COFFLIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\VC5;%VC5_PATH%\VC\LIB;%TNT_PATH%\COFFLIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%VC5_PATH%\VC -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%VC5_PATH%\VC\INCLUDE;%TNT_PATH%\INCLUDE; -set INIT=%VC5_PATH%\VC -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_WIN16= -SET USE_WIN32= -SET USE_TNT= -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=vc5 -PATH %SCITECH_BIN%;%VC5_PATH%\VC\BIN;%VC5_PATH%\SHAREDIDE\BIN;%TNT_PATH%\BIN;%DEFPATH%%VC32_CD_PATH% - -REM If you set the following to a 1, a TNT DosStyle app will be created. -REM Otherwise a TNT NtStyle app will be created. NtStyle apps will *only* -REM run under real DOS when using our libraries, since we require access -REM to functions that the Win32 API does not support (such as direct access -REM to video memory, calling Int 10h BIOS functions etc). DosStyle apps -REM will however run fine in both DOS and a Win95 DOS box (NT DOS boxes don't -REM work too well). -REM -REM If you are using the RealTime DOS extender, your apps *must* be NtStyle, -REM and hence will never be able to run under Win95 or WinNT, only DOS. - -SET DOSSTYLE= - -echo Visual C++ 5.0 32-bit compilation environment set up (with TNT). diff --git a/board/MAI/bios_emulator/scitech/bin/vc50-w16.bat b/board/MAI/bios_emulator/scitech/bin/vc50-w16.bat deleted file mode 100755 index 52ab495a3b..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc50-w16.bat +++ /dev/null @@ -1,27 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 1.52c 16 bit edition - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\WIN16\VC5;%VC_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\WIN16\VC5;%VC_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%VC_PATH% -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%VC_PATH%\INCLUDE; -set INIT=%VC_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC16.MK -SET USE_WIN16=1 -SET USE_WIN32= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=vc5 -PATH %SCITECH_BIN%;%VC_PATH%\BIN;%DEFPATH%%VC_CD_PATH% - -echo Visual C++ 1.52c 16-bit Windows compilation environment set up. - diff --git a/board/MAI/bios_emulator/scitech/bin/vc50-w32.bat b/board/MAI/bios_emulator/scitech/bin/vc50-w32.bat deleted file mode 100755 index 07bc5e51df..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc50-w32.bat +++ /dev/null @@ -1,39 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 5.0 32 bit edition - -SET MSDevDir=%VC5_MSDevDir% -SET MSVCDir=%VC5_MSVCDir% - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\VC5;%MSVCDir%\LIB;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\VC5;%MSVCDir%\LIB;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%MSVCDir% -set C_INCLUDE=%MSVCDir%\INCLUDE;%TNT_PATH%\INCLUDE; -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%C_INCLUDE% -set INIT=%MSVCDir% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_TNT= -SET USE_WIN16= -SET USE_WIN32=1 -SET WIN32_GUI=1 -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=vc5 -PATH %SCITECH_BIN%;%MSVCDir%\BIN;%MSDevDir%\BIN;%TNT_PATH%\BIN;%DEFPATH%%VC32_CD_PATH% - -REM: Enable Win32 SDK if desired (sdk on command line) -if NOT .%1%==.sdk goto done -call win32sdk.bat - -:done -echo Visual C++ 5.0 32-bit Windows console compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc50-x11.bat b/board/MAI/bios_emulator/scitech/bin/vc50-x11.bat deleted file mode 100755 index fe286bd95d..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc50-x11.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 5.0 32 bit edition - -SET LIB=%VC5_PATH%\VC\LIB;. -SET TOOLROOTDIR=%VC5_PATH%\VC -SET INCLUDE=\xc\include;%VC5_PATH%\VC\INCLUDE -SET INIT=%VC5_PATH%\VC -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_TNT= -SET USE_WIN16= -SET USE_WIN32=1 -SET WIN32_GUI=1 -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=vc5 -PATH %SCITECH_BIN%;%VC5_PATH%\VC\BIN;%VC5_PATH%\SHAREDIDE\BIN;%DEFPATH% - -echo Visual C++ 5.0 X11 compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc60-c32.bat b/board/MAI/bios_emulator/scitech/bin/vc60-c32.bat deleted file mode 100755 index e98417d613..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc60-c32.bat +++ /dev/null @@ -1,39 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 6.0 32 bit edition - -SET MSDevDir=%VC6_MSDevDir% -SET MSVCDir=%VC6_MSVCDir% - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\VC6;%MSVCDir%\LIB;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\VC6;%MSVCDir%\LIB;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%MSVCDir% -set C_INCLUDE=%MSVCDir%\INCLUDE;%TNT_PATH%\INCLUDE -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%C_INCLUDE% -set INIT=%MSVCDir% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_TNT= -SET USE_WIN16= -SET USE_WIN32=1 -SET WIN32_GUI= -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=vc6 -PATH %SCITECH_BIN%;%MSVCDir%\BIN;%MSDevDir%\BIN;%TNT_PATH%\BIN;%DEFPATH%%VC32_CD_PATH% - -REM: Enable Win32 SDK if desired (sdk on command line) -if NOT .%1%==.sdk goto done -call win32sdk.bat - -:done -echo Visual C++ 6.0 32-bit Windows console compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc60-d16.bat b/board/MAI/bios_emulator/scitech/bin/vc60-d16.bat deleted file mode 100755 index 10855e06cb..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc60-d16.bat +++ /dev/null @@ -1,26 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 1.52c 16 bit edition - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\DOS16\VC6;%VC_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\DOS16\VC6;%VC_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%VC_PATH% -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%VC_PATH%\INCLUDE; -set INIT=%VC_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC16.MK -SET USE_WIN16= -SET USE_WIN32= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=vc6 -PATH %SCITECH_BIN%;%VC_PATH%\BIN;%DEFPATH%%VC_CD_PATH% - -echo Visual C++ 1.52c 16-bit DOS compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/vc60-drv9x.bat b/board/MAI/bios_emulator/scitech/bin/vc60-drv9x.bat deleted file mode 100755 index 27a4a1439f..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc60-drv9x.bat +++ /dev/null @@ -1,21 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 6.0 32 bit edition - -REM: First setup for Win32 console development -call vc60-c32.bat > NUL - -REM: Extra stuff to set up for Windows 9x DDK development -set MASTER_MAKE=1 -set DDKROOT=%W95_DDKROOT% -set SDKROOT=%MSSDK% -set C16_ROOT=%VC_PATH% -set C32_ROOT=%VC6_PATH% - -if .%CHECKED%==.1 goto checked_build -echo Release build enabled. -goto done -:checked_build -echo Checked debug build enabled. -goto done -:done -echo Visual C++ 6.0 Windows 9x driver compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc60-drvnt.bat b/board/MAI/bios_emulator/scitech/bin/vc60-drvnt.bat deleted file mode 100755 index 17b2f25cc7..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc60-drvnt.bat +++ /dev/null @@ -1,17 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 6.0 32 bit edition - -REM: First setup for Win32 console development (with Platform SDK) -call vc60-c32.bat sdk > NUL - -REM: Now setup stuff for the NT DDK build environment -call ntddk.bat - -if .%CHECKED%==.1 goto checked_build -echo Release build enabled. -goto done -:checked_build -echo Checked debug build enabled. -goto done -:done -echo Visual C++ 6.0 Windows NT driver compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc60-drvw2k.bat b/board/MAI/bios_emulator/scitech/bin/vc60-drvw2k.bat deleted file mode 100755 index f304293270..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc60-drvw2k.bat +++ /dev/null @@ -1,17 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 6.0 32 bit edition - -REM: First setup for Win32 console development (with Platform SDK) -call vc60-c32.bat sdk > NUL - -REM: Now setup stuff for the NT DDK build environment -call w2kddk.bat - -if .%CHECKED%==.1 goto checked_build -echo Release build enabled. -goto done -:checked_build -echo Checked debug build enabled. -goto done -:done -echo Visual C++ 6.0 Windows Windows 2000 driver compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc60-snp.bat b/board/MAI/bios_emulator/scitech/bin/vc60-snp.bat deleted file mode 100755 index 5348ef9521..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc60-snp.bat +++ /dev/null @@ -1,33 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 6.0 32 bit edition - -SET MSDevDir=%VC6_MSDevDir% -SET MSVCDir=%VC6_MSVCDir% - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\SNAP\VC6;%MSVCDir%\LIB;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\SNAP\VC6;%MSVCDir%\LIB;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%MSVCDir% -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE -set INIT=%MSVCDir% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_TNT= -SET USE_WIN16= -SET USE_WIN32= -SET WIN32_GUI= -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET= -SET USE_SNAP=1 -SET VC_LIBBASE=vc6 -PATH %SCITECH_BIN%;%MSVCDir%\BIN;%MSDevDir%\BIN;%TNT_PATH%\BIN;%DEFPATH%%VC32_CD_PATH% - -echo Visual C++ 6.0 Snap compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc60-tnt.bat b/board/MAI/bios_emulator/scitech/bin/vc60-tnt.bat deleted file mode 100755 index 1d8b5e3038..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc60-tnt.bat +++ /dev/null @@ -1,42 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 6.0 32 bit edition - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\VC6;%VC6_PATH%\VC98\LIB;%TNT_PATH%\COFFLIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\VC6;%VC6_PATH%\VC98\LIB;%TNT_PATH%\COFFLIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%VC6_PATH%\VC98 -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%VC6_PATH%\VC98\INCLUDE;%TNT_PATH%\INCLUDE; -set INIT=%VC6_PATH%\VC98 -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_WIN16= -SET USE_WIN32= -SET USE_TNT= -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=vc6 PATH -%SCITECH_BIN%;%VC6_PATH%\VC98\BIN;%VC6_PATH%\COMMON\MSDEV98\BIN;%TNT_PATH%\BIN;%DEFPATH%%VC32_CD_PATH% - -REM If you set the following to a 1, a TNT DosStyle app will be created. -REM Otherwise a TNT NtStyle app will be created. NtStyle apps will *only* -REM run under real DOS when using our libraries, since we require access -REM to functions that the Win32 API does not support (such as direct access -REM to video memory, calling Int 10h BIOS functions etc). DosStyle apps -REM will however run fine in both DOS and a Win95 DOS box (NT DOS boxes don't -REM work too well). -REM -REM If you are using the RealTime DOS extender, your apps *must* be NtStyle, -REM and hence will never be able to run under Win95 or WinNT, only DOS. - -SET DOSSTYLE= - -echo Visual C++ 6.0 32-bit compilation environment set up (with TNT). diff --git a/board/MAI/bios_emulator/scitech/bin/vc60-w16.bat b/board/MAI/bios_emulator/scitech/bin/vc60-w16.bat deleted file mode 100755 index 70175c37ab..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc60-w16.bat +++ /dev/null @@ -1,27 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 1.52c 16 bit edition - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\WIN16\VC6;%VC_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\WIN16\VC6;%VC_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%VC_PATH% -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%VC_PATH%\INCLUDE; -set INIT=%VC_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC16.MK -SET USE_WIN16=1 -SET USE_WIN32= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=vc6 -PATH %SCITECH_BIN%;%VC_PATH%\BIN;%DEFPATH%%VC_CD_PATH% - -echo Visual C++ 1.52c 16-bit Windows compilation environment set up. - diff --git a/board/MAI/bios_emulator/scitech/bin/vc60-w32.bat b/board/MAI/bios_emulator/scitech/bin/vc60-w32.bat deleted file mode 100755 index 2f8e7ab9b8..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc60-w32.bat +++ /dev/null @@ -1,39 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 6.0 32 bit edition - -SET MSDevDir=%VC6_MSDevDir% -SET MSVCDir=%VC6_MSVCDir% - -if .%CHECKED%==.1 goto checked_build -set LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\VC6;%MSVCDir%\LIB;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -set LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\VC6;%MSVCDir%\LIB;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -set TOOLROOTDIR=%MSVCDir% -set C_INCLUDE=%MSVCDir%\INCLUDE;%TNT_PATH%\INCLUDE -set INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%C_INCLUDE% -set INIT=%MSVCDir% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_TNT= -SET USE_WIN16= -SET USE_WIN32=1 -SET WIN32_GUI=1 -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=vc6 -PATH %SCITECH_BIN%;%MSVCDir%\BIN;%MSDevDir%\BIN;%TNT_PATH%\BIN;%DEFPATH%%VC32_CD_PATH% - -REM: Enable Win32 SDK if desired (sdk on command line) -if NOT .%1%==.sdk goto done -call win32sdk.bat - -:done -echo Visual C++ 6.0 32-bit Windows compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/vc60-x11.bat b/board/MAI/bios_emulator/scitech/bin/vc60-x11.bat deleted file mode 100755 index 57b23d2048..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/vc60-x11.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off -REM Setup environment variables for Visual C++ 6.0 32 bit edition - -SET LIB=%VC6_PATH%\VC98\LIB;. -SET TOOLROOTDIR=%VC6_PATH%\VC98 -SET INCLUDE=\xc\include;%VC6_PATH%\VC98\INCLUDE; -SET INIT=%VC6_PATH%\VC98 -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\VC32.MK -SET USE_TNT= -SET USE_WIN16= -SET USE_WIN32=1 -SET WIN32_GUI=1 -SET USE_VXD= -SET USE_NTDRV= -SET USE_RTTARGET= -SET USE_SNAP= -SET VC_LIBBASE=vc6 -PATH %SCITECH_BIN%;%VC6_PATH%\VC98\BIN;%VC6_PATH%\COMMON\MSDEV98\BIN;%DEFPATH% - -echo Visual C++ 6.0 X11 compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/w2kddk.bat b/board/MAI/bios_emulator/scitech/bin/w2kddk.bat deleted file mode 100755 index 92858d162e..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/w2kddk.bat +++ /dev/null @@ -1,42 +0,0 @@ -@echo off -REM: Set up environment variables for Microsoft Windows NT DDK development. -REM: Note that we have hard coded this for Windows NT i386 development. - -SET USE_NTDRV=1 -SET USE_W2KDRV=1 -SET BASEDIR=%W2K_DDKROOT% -SET PATH=%BASEDIR%\bin;%PATH% -SET NTMAKEENV=%BASEDIR%\inc -SET BUILD_MAKE_PROGRAM=nmake.exe -SET BUILD_DEFAULT=-ei -nmake -i -SET BUILD_DEFAULT_TARGETS=-386 -SET _OBJ_DIR=obj -SET NEW_CRTS=1 -SET _NTROOT=%BASEDIR% -SET INCLUDE=%BASEDIR%\inc;%BASEDIR%\inc\ddk;%INCLUDE% - -if .%CHECKED%==.1 goto checked - -REM: set up an NT free build environment -SET DDKBUILDENV=free -SET C_DEFINES=-D_IDWBUILD -SET NTDBGFILES=1 -SET NTDEBUG= -SET NTDEBUGTYPE= -SET MSC_OPTIMIZATION= -set LIB=%BASEDIR%\libfre\i386;%SCITECH_LIB%\LIB\RELEASE\W2KDRV\VC6;%MSVCDir%\LIB;. - -goto done - -:checked - -REM: set up an NT checked build environment -SET DDKBUILDENV=checked -SET C_DEFINES=-D_IDWBUILD -DRDRDBG -DSRVDBG -SET NTDBGFILES= -SET NTDEBUG=ntsd -SET NTDEBUGTYPE=both -SET MSC_OPTIMIZATION=/Od /Oi -set LIB=%BASEDIR%\libchk\i386;%SCITECH_LIB%\LIB\DEBUG\W2KDRV\VC6;%MSVCDir%\LIB;. - -:done diff --git a/board/MAI/bios_emulator/scitech/bin/wc10-c32.bat b/board/MAI/bios_emulator/scitech/bin/wc10-c32.bat deleted file mode 100755 index 2d738f376f..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10-c32.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.6 in 32 bit mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\WC10;%WC10_PATH%\LIB386;%WC10_PATH%\LIB386\NT;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\WC10;%WC10_PATH%\LIB386;%WC10_PATH%\LIB386\NT;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC10_PATH%\H;%WC10_PATH%\H\NT; -SET WATCOM=%WC10_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_WIN386= -SET WIN32_GUI= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=WC10 -PATH %SCITECH_BIN%;%WC10_PATH%\BINNT;%WC10_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.6 Win32 console compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/wc10-d16.bat b/board/MAI/bios_emulator/scitech/bin/wc10-d16.bat deleted file mode 100755 index 5c53a90a17..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10-d16.bat +++ /dev/null @@ -1,30 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.6 in 32 bit mode (DOS4GW) - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS16\WC10;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS16\WC10;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC10_PATH%\H;%WC10_PATH%\H\WIN; -SET WATCOM=%WC10_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC16.MK -SET USE_WIN16= -SET USE_WIN32= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=WC10 -SET EDPATH=%WC10_PATH%\EDDAT -PATH %SCITECH_BIN%;%WC10_PATH%\BINNT;%WC10_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.6 16-bit DOS compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc10-d32.bat b/board/MAI/bios_emulator/scitech/bin/wc10-d32.bat deleted file mode 100755 index a5c7210526..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10-d32.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.6 in 32 bit mode (DOS4GW) - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\WC10;%WC10_PATH%\LIB386;%WC10_PATH%\LIB386\DOS;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS32\WC10;%WC10_PATH%\LIB386;%WC10_PATH%\LIB386\DOS;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC10_PATH%\H; -SET WATCOM=%WC10_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=WC10 -PATH %SCITECH_BIN%;%WC10_PATH%\BINNT;%WC10_PATH%\BINW;%DJ_PATH%\BIN;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.6 32-bit DOS compilation environment set up (DOS4GW) - diff --git a/board/MAI/bios_emulator/scitech/bin/wc10-o16.bat b/board/MAI/bios_emulator/scitech/bin/wc10-o16.bat deleted file mode 100755 index 579dece3b0..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10-o16.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.6 in 16-bit OS/2 mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\lib\release\os216\wc10;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\lib\debug\os216\wc10;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10_PATH%\eddat -SET INCLUDE=include;%SCITECH%\include;%PRIVATE%\include;%WC10_PATH%\h\os2;%WC10_PATH%\h -SET WATCOM=%WC10_PATH% -SET MAKESTARTUP=%SCITECH%\makedefs\wc16.mk -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216=1 -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=wc10 -SET EDPATH=%WC10_PATH%\EDDAT -PATH %SCITECH_BIN%;%WC10_PATH%\BINNT;%WC10_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.6 16-bit OS/2 compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc10-o32.bat b/board/MAI/bios_emulator/scitech/bin/wc10-o32.bat deleted file mode 100755 index 3404b42a01..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10-o32.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.6 in 32-bit OS/2 mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\lib\release\os232\wc10;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\lib\debug\os232\wc10;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10_PATH%\eddat -SET INCLUDE=include;%SCITECH%\include;%PRIVATE%\include;%WC10_PATH%\h\os2;%WC10_PATH%\h -SET WATCOM=%WC10_PATH% -SET MAKESTARTUP=%SCITECH%\makedefs\wc32.mk -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232=1 -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=wc10 -SET EDPATH=%WC10_PATH%\EDDAT -PATH %SCITECH_BIN%;%WC10_PATH%\BINNT;%WC10_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.6 32-bit OS/2 console compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc10-p32.bat b/board/MAI/bios_emulator/scitech/bin/wc10-p32.bat deleted file mode 100755 index 57057de361..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10-p32.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.6 in 32-bit OS/2 mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\lib\release\os232\wc10;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\lib\debug\os232\wc10;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10_PATH%\eddat -SET INCLUDE=include;%SCITECH%\include;%PRIVATE%\include;%WC10_PATH%\h\os2;%WC10_PATH%\h -SET WATCOM=%WC10_PATH% -SET MAKESTARTUP=%SCITECH%\makedefs\wc32.mk -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232=1 -SET USE_OS2GUI=1 -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=wc10 -SET EDPATH=%WC10_PATH%\EDDAT -PATH %SCITECH_BIN%;%WC10_PATH%\BINNT;%WC10_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.6 32-bit OS/2 GUI compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc10-qnx.bat b/board/MAI/bios_emulator/scitech/bin/wc10-qnx.bat deleted file mode 100755 index 46f8659ce6..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10-qnx.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.6 in 32 bit mode (QNX 4) - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\QNX4\WC10;%WC10_PATH%\LIB386;%WC10_PATH%\LIB386\QNX;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\QNX4\WC10;%WC10_PATH%\LIB386;%WC10_PATH%\LIB386\QNX;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC10_PATH%\QH; -SET WATCOM=%WC10_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4=1 -SET WC_LIBBASE=WC10 -PATH %SCITECH_BIN%;%WC10_PATH%\BINNT;%WC10_PATH%\BINW;%DJ_PATH%\BIN;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.6 32-bit QNX compilation environment set up - diff --git a/board/MAI/bios_emulator/scitech/bin/wc10-snp.bat b/board/MAI/bios_emulator/scitech/bin/wc10-snp.bat deleted file mode 100755 index 1fde624f1f..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10-snp.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.6 in 32 bit mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\SNAP\WC10;%WC10_PATH%\LIB386;%WC10_PATH%\LIB386\NT;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\SNAP\WC10;%WC10_PATH%\LIB386;%WC10_PATH%\LIB386\NT;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC10_PATH%\H -SET WATCOM=%WC10_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET WIN32_GUI= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP=1 -SET USE_QNX4= -SET WC_LIBBASE=WC10 -PATH %SCITECH_BIN%;%WC10_PATH%\BINNT;%WC10_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.6 Snap compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/wc10-tnt.bat b/board/MAI/bios_emulator/scitech/bin/wc10-tnt.bat deleted file mode 100755 index d12f042fa1..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10-tnt.bat +++ /dev/null @@ -1,46 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.6 in 32 bit mode with Phar Lap TNT - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\WC10;%WC10_PATH%\LIB386;%WC10_PATH%\LIB386\DOS;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS32\WC10;%WC10_PATH%\LIB386;%WC10_PATH%\LIB386\DOS;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC10_PATH%\H;%WC10_PATH%\H\NT;%TNT_PATH%\INCLUDE -SET WATCOM=%WC10_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT=1 -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=WC10 -PATH %SCITECH_BIN%;%WC10_PATH%\BINNT;%WC10_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -REM If you set the following to a 1, a TNT DosStyle app will be created. -REM Otherwise a TNT NtStyle app will be created. NtStyle apps will *only* -REM run under real DOS when using our libraries, since we require access -REM to functions that the Win32 API does not support (such as direct access -REM to video memory, calling Int 10h BIOS functions etc). DosStyle apps -REM will however run fine in both DOS and a Win95 DOS box (NT DOS boxes don't -REM work too well). -REM -REM If you are using the RealTime DOS extender, your apps *must* be NtStyle, -REM and hence will never be able to run under Win95 or WinNT, only DOS. - -SET DOSSTYLE=1 - -echo Watcom C/C++ 10.6 32-bit DOS compilation environment set up (TNT). diff --git a/board/MAI/bios_emulator/scitech/bin/wc10-w16.bat b/board/MAI/bios_emulator/scitech/bin/wc10-w16.bat deleted file mode 100755 index e8ba871bb9..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10-w16.bat +++ /dev/null @@ -1,32 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.6 in 16 bit Windows mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN16\WC10;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN16\WC10;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC10_PATH%\H;%WC10_PATH%\H\WIN; -SET WATCOM=%WC10_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC16.MK -SET USE_WIN16=1 -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=WC10 -SET EDPATH=%WC10_PATH%\EDDAT -PATH %SCITECH_BIN%;%WC10_PATH%\BINNT;%WC10_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.6 16-bit Windows compilation environment set up. - diff --git a/board/MAI/bios_emulator/scitech/bin/wc10-w32.bat b/board/MAI/bios_emulator/scitech/bin/wc10-w32.bat deleted file mode 100755 index 839bdde9c0..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10-w32.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.6 in 32 bit mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\WC10;%WC10_PATH%\LIB386;%WC10_PATH%\LIB386\NT;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\WC10;%WC10_PATH%\LIB386;%WC10_PATH%\LIB386\NT;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC10_PATH%\H;%WC10_PATH%\H\NT; -SET WATCOM=%WC10_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_WIN386= -SET WIN32_GUI=1 -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=WC10 -PATH %SCITECH_BIN%;%WC10_PATH%\BINNT;%WC10_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.6 Win32 GUI compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/wc10-x11.bat b/board/MAI/bios_emulator/scitech/bin/wc10-x11.bat deleted file mode 100755 index fc783d8143..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10-x11.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.6 in 32 bit mode - -SET LIB=%WC10_PATH%\LIB386;%WC10_PATH%\LIB386\NT;. -SET EDPATH=%WC10_PATH%\EDDAT -SET INCLUDE=%WC10_PATH%\H;%WC10_PATH%\H\NT; -SET WATCOM=%WC10_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_WIN386= -SET WIN32_GUI=1 -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=WC10 -PATH %SCITECH_BIN%;%WC10_PATH%\BINNT;%WC10_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.6 X11 compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/wc10ac32.bat b/board/MAI/bios_emulator/scitech/bin/wc10ac32.bat deleted file mode 100755 index 6e0c24d5e7..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10ac32.bat +++ /dev/null @@ -1,33 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.0a in 32 bit mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\WC10A;%WC10A_PATH%\LIB386;%WC10A_PATH%\LIB386\NT;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\WC10A;%WC10A_PATH%\LIB386;%WC10A_PATH%\LIB386\NT;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10A_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC10A_PATH%\H;%WC10A_PATH%\H\NT; -SET WATCOM=%WC10A_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_WIN386= -SET WIN32_GUI= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET WC_LIBBASE=WC10A -PATH %SCITECH_BIN%;%WC10A_PATH%\BINNT;%WC10A_PATH%\BINB;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.0a Win32 console compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/wc10ad16.bat b/board/MAI/bios_emulator/scitech/bin/wc10ad16.bat deleted file mode 100755 index f9ecb67273..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10ad16.bat +++ /dev/null @@ -1,29 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.0a in 32 bit mode (DOS4GW) - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS16\WC10A;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS16\WC10A;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10A_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC10A_PATH%\H;%WC10A_PATH%\H\WIN; -SET WATCOM=%WC10A_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC16.MK -SET USE_WIN16= -SET USE_WIN32= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET WC_LIBBASE=WC10A -SET EDPATH=%WC10A_PATH%\EDDAT -PATH %SCITECH_BIN%;%WC10A_PATH%\BINNT;%WC10A_PATH%\BINB;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.0a 16-bit DOS compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc10ad32.bat b/board/MAI/bios_emulator/scitech/bin/wc10ad32.bat deleted file mode 100755 index d52b79a82c..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10ad32.bat +++ /dev/null @@ -1,32 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.0a in 32 bit mode (DOS4GW) - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\WC10A;%WC10A_PATH%\LIB386;%WC10A_PATH%\LIB386\DOS;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS32\WC10A;%WC10A_PATH%\LIB386;%WC10A_PATH%\LIB386\DOS;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10A_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC10A_PATH%\H; -SET WATCOM=%WC10A_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET WC_LIBBASE=WC10A -PATH %SCITECH_BIN%;%WC10A_PATH%\BINNT;%WC10A_PATH%\BINB;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.0a 32-bit DOS compilation environment set up (DOS4GW) diff --git a/board/MAI/bios_emulator/scitech/bin/wc10ao16.bat b/board/MAI/bios_emulator/scitech/bin/wc10ao16.bat deleted file mode 100755 index ba7351d0d8..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10ao16.bat +++ /dev/null @@ -1,30 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.0a in 16-bit OS/2 mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\lib\release\os216\wc10;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\lib\debug\os216\wc10;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10A_PATH%\eddat -SET INCLUDE=include;%SCITECH%\include;%PRIVATE%\include;%WC10A_PATH%\h\os2;%WC10A_PATH%\h -SET WATCOM=%WC10A_PATH% -SET MAKESTARTUP=%SCITECH%\makedefs\wc16.mk -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216=1 -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET WC_LIBBASE=wc10 -SET EDPATH=%WC10A_PATH%\EDDAT -PATH %SCITECH_BIN%;%WC10A_PATH%\BINNT;%WC10A_PATH%\BINB;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.0a 16-bit OS/2 compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc10ao32.bat b/board/MAI/bios_emulator/scitech/bin/wc10ao32.bat deleted file mode 100755 index f3caa59591..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10ao32.bat +++ /dev/null @@ -1,30 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.0a in 32-bit OS/2 mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\lib\release\os232\wc10;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\lib\debug\os232\wc10;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10AA_PATH%\eddat -SET INCLUDE=include;%SCITECH%\include;%PRIVATE%\include;%WC10AA_PATH%\h\os2;%WC10AA_PATH%\h -SET WATCOM=%WC10AA_PATH% -SET MAKESTARTUP=%SCITECH%\makedefs\wc32.mk -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232=1 -SET USE_OS2GUI= -SET USE_SNAP= -SET WC_LIBBASE=WC10A -SET EDPATH=%WC10AA_PATH%\EDDAT -PATH %SCITECH_BIN%;%WC10AA_PATH%\BINNT;%WC10AA6_PATH%\BINB;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.0a 32-bit OS/2 console compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc10ap32.bat b/board/MAI/bios_emulator/scitech/bin/wc10ap32.bat deleted file mode 100755 index 8d21c62eac..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10ap32.bat +++ /dev/null @@ -1,30 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.0a in 32-bit OS/2 mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\lib\release\os232\wc10;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\lib\debug\os232\wc10;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10_PATH%\eddat -SET INCLUDE=include;%SCITECH%\include;%PRIVATE%\include;%WC10_PATH%\h\os2;%WC10_PATH%\h -SET WATCOM=%WC10_PATH% -SET MAKESTARTUP=%SCITECH%\makedefs\wc32.mk -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232=1 -SET USE_OS2GUI=1 -SET USE_SNAP= -SET WC_LIBBASE=WC10A -SET EDPATH=%WC10_PATH%\EDDAT -PATH %SCITECH_BIN%;%WC10_PATH%\BINNT;%WC10_PATH%\BINB;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.0a 32-bit OS/2 GUI compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc10asnp.bat b/board/MAI/bios_emulator/scitech/bin/wc10asnp.bat deleted file mode 100755 index 28f857c80d..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10asnp.bat +++ /dev/null @@ -1,33 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.0a in 32 bit mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\SNAP\WC10A;%WC10A_PATH%\LIB386;%WC10A_PATH%\LIB386\NT;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\SNAP\WC10A;%WC10A_PATH%\LIB386;%WC10A_PATH%\LIB386\NT;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10A_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE -SET WATCOM=%WC10A_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_WIN386= -SET WIN32_GUI= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP=1 -SET WC_LIBBASE=WC10A -PATH %SCITECH_BIN%;%WC10A_PATH%\BINNT;%WC10A_PATH%\BINB;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.0a Snap compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/wc10atnt.bat b/board/MAI/bios_emulator/scitech/bin/wc10atnt.bat deleted file mode 100755 index a2b32193e4..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10atnt.bat +++ /dev/null @@ -1,45 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.0a in 32 bit mode with Phar Lap TNT - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\WC10A;%WC10A_PATH%\LIB386;%WC10A_PATH%\LIB386\DOS;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS32\WC10A;%WC10A_PATH%\LIB386;%WC10A_PATH%\LIB386\DOS;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10A_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC10A_PATH%\H;%WC10A_PATH%\H\NT;%TNT_PATH%\INCLUDE -SET WATCOM=%WC10A_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT=1 -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET WC_LIBBASE=WC10A -PATH %SCITECH_BIN%;%WC10A_PATH%\BINNT;%WC10A_PATH%\BINB;%DEFPATH%%WC_CD_PATH% - -REM If you set the following to a 1, a TNT DosStyle app will be created. -REM Otherwise a TNT NtStyle app will be created. NtStyle apps will *only* -REM run under real DOS when using our libraries, since we require access -REM to functions that the Win32 API does not support (such as direct access -REM to video memory, calling Int 10h BIOS functions etc). DosStyle apps -REM will however run fine in both DOS and a Win95 DOS box (NT DOS boxes don't -REM work too well). -REM -REM If you are using the RealTime DOS extender, your apps *must* be NtStyle, -REM and hence will never be able to run under Win95 or WinNT, only DOS. - -SET DOSSTYLE=1 - -echo Watcom C/C++ 10.0a 32-bit DOS compilation environment set up (TNT). diff --git a/board/MAI/bios_emulator/scitech/bin/wc10aw16.bat b/board/MAI/bios_emulator/scitech/bin/wc10aw16.bat deleted file mode 100755 index 94011cc337..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10aw16.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.0a in 16 bit Windows mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN16\WC10A;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN16\WC10A;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10A_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC10A_PATH%\H;%WC10A_PATH%\H\WIN; -SET WATCOM=%WC10A_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC16.MK -SET USE_WIN16=1 -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET WC_LIBBASE=WC10A -SET EDPATH=%WC10A_PATH%\EDDAT -PATH %SCITECH_BIN%;%WC10A_PATH%\BINNT;%WC10A_PATH%\BINB;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.0a 16-bit Windows compilation environment set up. - diff --git a/board/MAI/bios_emulator/scitech/bin/wc10aw32.bat b/board/MAI/bios_emulator/scitech/bin/wc10aw32.bat deleted file mode 100755 index 1e14dbc9f2..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc10aw32.bat +++ /dev/null @@ -1,33 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 10.0a in 32 bit mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\WC10A;%WC10A_PATH%\LIB386;%WC10A_PATH%\LIB386\NT;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\WC10A;%WC10A_PATH%\LIB386;%WC10A_PATH%\LIB386\NT;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC10A_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC10A_PATH%\H;%WC10A_PATH%\H\NT; -SET WATCOM=%WC10A_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_WIN386= -SET WIN32_GUI=1 -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET WC_LIBBASE=WC10A -PATH %SCITECH_BIN%;%WC10A_PATH%\BINNT;%WC10A_PATH%\BINB;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 10.0a Win32 GUI compilation environment set up diff --git a/board/MAI/bios_emulator/scitech/bin/wc11-c32.bat b/board/MAI/bios_emulator/scitech/bin/wc11-c32.bat deleted file mode 100755 index e75312927c..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc11-c32.bat +++ /dev/null @@ -1,40 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 11.0 in 32 bit mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\WC11;%WC11_PATH%\LIB386;%WC11_PATH%\LIB386\NT;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\WC11;%WC11_PATH%\LIB386;%WC11_PATH%\LIB386\NT;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC11_PATH%\EDDAT -SET C_INCLUDE=%WC11_PATH%\H;%WC11_PATH%\H\NT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%C_INCLUDE% -SET WATCOM=%WC11_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_WIN386= -SET WIN32_GUI= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=WC11 -PATH %SCITECH_BIN%;%WC11_PATH%\BINNT;%WC11_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -REM: Enable Win32 SDK if desired (sdk on command line) -if NOT .%1%==.sdk goto done -call win32sdk.bat - -:done -echo Watcom C/C++ 11.0 Win32 console compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc11-d16.bat b/board/MAI/bios_emulator/scitech/bin/wc11-d16.bat deleted file mode 100755 index 4338adaef9..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc11-d16.bat +++ /dev/null @@ -1,30 +0,0 @@ -@echo off -REM SETup for compiling with Watcom C/C++ 11.0 in 16 bit mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS16\WC11;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS16\WC11;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC11_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC11_PATH%\H;%WC11_PATH%\H\WIN; -SET WATCOM=%WC11_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC16.MK -SET USE_WIN16= -SET USE_WIN32= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=WC11 -SET EDPATH=%WC11_PATH%\EDDAT -PATH %SCITECH_BIN%;%WC11_PATH%\BINNT;%WC11_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 11.0 16-bit DOS compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc11-d32.bat b/board/MAI/bios_emulator/scitech/bin/wc11-d32.bat deleted file mode 100755 index e5a54d4bb4..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc11-d32.bat +++ /dev/null @@ -1,33 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 11.0 in 32 bit mode (DOS4GW) - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\WC11;%WC11_PATH%\LIB386;%WC11_PATH%\LIB386\DOS;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS32\WC11;%WC11_PATH%\LIB386;%WC11_PATH%\LIB386\DOS;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC11_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC11_PATH%\H; -SET WATCOM=%WC11_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=WC11 -PATH %SCITECH_BIN%;%WC11_PATH%\BINNT;%WC11_PATH%\BINW;%DJ_PATH%\BIN;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 11.0 32-bit DOS compilation environment set up (DOS4GW). diff --git a/board/MAI/bios_emulator/scitech/bin/wc11-o16.bat b/board/MAI/bios_emulator/scitech/bin/wc11-o16.bat deleted file mode 100755 index d46754a3c0..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc11-o16.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 11.0 in 16-bit OS/2 mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\lib\release\os216\wc11;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\lib\debug\os216\wc11;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC11_PATH%\eddat -SET INCLUDE=include;%SCITECH%\include;%PRIVATE%\include;%WC11_PATH%\h\os2;%WC11_PATH%\h -SET WATCOM=%WC11_PATH% -SET MAKESTARTUP=%SCITECH%\makedefs\wc16.mk -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216=1 -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=wc11 -SET EDPATH=%WC11_PATH%\EDDAT -PATH %SCITECH_BIN%;%WC11_PATH%\BINNT;%WC11_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 11.0 16-bit OS/2 compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc11-o32.bat b/board/MAI/bios_emulator/scitech/bin/wc11-o32.bat deleted file mode 100755 index 37f5dc7617..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc11-o32.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 11.0 in 32-bit OS/2 mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\lib\release\os232\wc11;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\lib\debug\os232\wc11;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC11_PATH%\eddat -SET INCLUDE=include;%SCITECH%\include;%PRIVATE%\include;%WC11_PATH%\h\os2;%WC11_PATH%\h -SET WATCOM=%WC11_PATH% -SET MAKESTARTUP=%SCITECH%\makedefs\wc32.mk -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232=1 -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=wc11 -SET EDPATH=%WC11_PATH%\EDDAT -PATH %SCITECH_BIN%;%WC11_PATH%\BINNT;%WC11_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 11.0 32-bit OS/2 console compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc11-p32.bat b/board/MAI/bios_emulator/scitech/bin/wc11-p32.bat deleted file mode 100755 index 348cbbda81..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc11-p32.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 11.0 in 32-bit OS/2 mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\lib\release\os232\wc11;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\lib\debug\os232\wc11;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC11_PATH%\eddat -SET INCLUDE=include;%SCITECH%\include;%PRIVATE%\include;%WC11_PATH%\h\os2;%WC11_PATH%\h -SET WATCOM=%WC11_PATH% -SET MAKESTARTUP=%SCITECH%\makedefs\wc32.mk -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232=1 -SET USE_OS2GUI=1 -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=wc11 -SET EDPATH=%WC11_PATH%\EDDAT -PATH %SCITECH_BIN%;%WC11_PATH%\BINNT;%WC11_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 11.0 32-bit OS/2 GUI compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc11-qnx.bat b/board/MAI/bios_emulator/scitech/bin/wc11-qnx.bat deleted file mode 100755 index 1fd60feea8..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc11-qnx.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 11.0 in 32 bit mode (QNX 4) - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\QNX4\WC11;%WC11_PATH%\LIB386;%WC11_PATH%\LIB386\QNX;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\QNX4\WC11;%WC11_PATH%\LIB386;%WC11_PATH%\LIB386\QNX;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC11_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC11_PATH%\QH; -SET WATCOM=%WC11_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4=1 -SET WC_LIBBASE=WC11 -PATH %SCITECH_BIN%;%WC11_PATH%\BINNT;%WC11_PATH%\BINW;%DJ_PATH%\BIN;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 11.0 32-bit QNX compilation environment set up - diff --git a/board/MAI/bios_emulator/scitech/bin/wc11-snp.bat b/board/MAI/bios_emulator/scitech/bin/wc11-snp.bat deleted file mode 100755 index 6d2ac5783d..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc11-snp.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 11.0 in 32 bit mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\SNAP\WC11;%WC11_PATH%\LIB386;%WC11_PATH%\LIB386\NT;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\SNAP\WC11;%WC11_PATH%\LIB386;%WC11_PATH%\LIB386\NT;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC11_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC11_PATH%\H -SET WATCOM=%WC11_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET WIN32_GUI= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP=1 -SET USE_QNX4= -SET WC_LIBBASE=WC11 -PATH %SCITECH_BIN%;%WC11_PATH%\BINNT;%WC11_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 11.0 Snap compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc11-tnt.bat b/board/MAI/bios_emulator/scitech/bin/wc11-tnt.bat deleted file mode 100755 index 44dbf24847..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc11-tnt.bat +++ /dev/null @@ -1,46 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 11.0 in 32 bit mode with Phar Lap TNT - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\DOS32\WC11;%WC11_PATH%\LIB386;%WC11_PATH%\LIB386\DOS;%TNT_PATH%\LIB;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\DOS32\WC11;%WC11_PATH%\LIB386;%WC11_PATH%\LIB386\DOS;%TNT_PATH%\LIB;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC11_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC11_PATH%\H;%WC11_PATH%\H\NT;%TNT_PATH%\INCLUDE -SET WATCOM=%WC11_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT=1 -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=WC11 -PATH %SCITECH_BIN%;%WC11_PATH%\BINNT;%WC11_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -REM If you set the following to a 1, a TNT DosStyle app will be created. -REM Otherwise a TNT NtStyle app will be created. NtStyle apps will *only* -REM run under real DOS when using our libraries, since we require access -REM to functions that the Win32 API does not support (such as direct access -REM to video memory, calling Int 10h BIOS functions etc). DosStyle apps -REM will however run fine in both DOS and a Win95 DOS box (NT DOS boxes don't -REM work too well). -REM -REM If you are using the RealTime DOS extender, your apps *must* be NtStyle, -REM and hence will never be able to run under Win95 or WinNT, only DOS. - -SET DOSSTYLE=1 - -echo Watcom C/C++ 11.0 32-bit DOS compilation environment set up (TNT). diff --git a/board/MAI/bios_emulator/scitech/bin/wc11-w16.bat b/board/MAI/bios_emulator/scitech/bin/wc11-w16.bat deleted file mode 100755 index e65c70e178..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc11-w16.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 11.0 in 16 bit Windows mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN16\WC11;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN16\WC11;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC11_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC11_PATH%\H;%WC11_PATH%\H\WIN; -SET WATCOM=%WC11_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC16.MK -SET USE_WIN16=1 -SET USE_WIN32= -SET USE_WIN386= -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=WC11 -SET EDPATH=%WC11_PATH%\EDDAT -PATH %SCITECH_BIN%;%WC11_PATH%\BINNT;%WC11_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 11.0 16-bit Windows compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc11-w32.bat b/board/MAI/bios_emulator/scitech/bin/wc11-w32.bat deleted file mode 100755 index 764cdbd111..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc11-w32.bat +++ /dev/null @@ -1,40 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 11.0 in 32 bit mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\WC11;%WC11_PATH%\LIB386;%WC11_PATH%\LIB386\NT;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\WC11;%WC11_PATH%\LIB386;%WC11_PATH%\LIB386\NT;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC11_PATH%\EDDAT -SET C_INCLUDE=%WC11_PATH%\H;%WC11_PATH%\H\NT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%C_INCLUDE% -SET WATCOM=%WC11_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_WIN386= -SET WIN32_GUI=1 -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=WC11 -PATH %SCITECH_BIN%;%WC11_PATH%\BINNT;%WC11_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -REM: Enable Win32 SDK if desired (sdk on command line) -if NOT .%1%==.sdk goto done -call win32sdk.bat - -:done -echo Watcom C/C++ 11.0 Win32 GUI compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/wc11-x11.bat b/board/MAI/bios_emulator/scitech/bin/wc11-x11.bat deleted file mode 100755 index c2569a3eb9..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/wc11-x11.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -REM Setup for compiling with Watcom C/C++ 11.0 in 32 bit mode - -if .%CHECKED%==.1 goto checked_build -SET LIB=%SCITECH_LIB%\LIB\RELEASE\WIN32\WC11;%WC11_PATH%\LIB386;%WC11_PATH%\LIB386\NT;. -echo Release build enabled. -goto setvars - -:checked_build -SET LIB=%SCITECH_LIB%\LIB\DEBUG\WIN32\WC11;%WC11_PATH%\LIB386;%WC11_PATH%\LIB386\NT;. -echo Checked debug build enabled. -goto setvars - -:setvars -SET EDPATH=%WC11_PATH%\EDDAT -SET INCLUDE=INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%WC11_PATH%\H;%WC11_PATH%\H\NT; -SET WATCOM=%WC11_PATH% -SET MAKESTARTUP=%SCITECH%\MAKEDEFS\WC32.MK -SET USE_TNT= -SET USE_X32= -SET USE_X32VM= -SET USE_WIN16= -SET USE_WIN32=1 -SET USE_WIN386= -SET WIN32_GUI=1 -SET USE_OS216= -SET USE_OS232= -SET USE_OS2GUI= -SET USE_SNAP= -SET USE_QNX4= -SET WC_LIBBASE=WC11 -PATH %SCITECH_BIN%;%WC11_PATH%\BINNT;%WC11_PATH%\BINW;%DEFPATH%%WC_CD_PATH% - -echo Watcom C/C++ 11.0 Win32 GUI compilation environment set up. diff --git a/board/MAI/bios_emulator/scitech/bin/win32sdk.bat b/board/MAI/bios_emulator/scitech/bin/win32sdk.bat deleted file mode 100755 index 3c7f017cb5..0000000000 --- a/board/MAI/bios_emulator/scitech/bin/win32sdk.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off -REM: Set up environment variables for Microsoft Platform SDK development -REM: Note that we have hard coded this for Windows NT i386 development. - -SET MSTOOLS=%MSSDK% -SET DXSDKROOT=%MSTOOLS% -SET INETSDK=%MSTOOLS% -SET BKOFFICE=%MSTOOLS% -SET BASEMAKE=%BKOFFICE%\INCLUDE\BKOffice.Mak -SET INCLUDE=.;INCLUDE;%SCITECH%\INCLUDE;%PRIVATE%\INCLUDE;%MSTOOLS%\INCLUDE;%C_INCLUDE% -if .%1%==.borland goto borland -SET LIB=%MSTOOLS%\LIB;%LIB% -goto notborland -:borland -SET LIB=%MSTOOLS%\LIB\BORLAND;%LIB% -:notborland -SET PATH=%MSTOOLS%\Bin\;%MSTOOLS%\Bin\WinNT;%PATH% -SET CPU=i386 - -echo Microsoft Platform SDK support enbabled. diff --git a/board/MAI/bios_emulator/scitech/include/biosemu.h b/board/MAI/bios_emulator/scitech/include/biosemu.h deleted file mode 100644 index 82c33a7c1d..0000000000 --- a/board/MAI/bios_emulator/scitech/include/biosemu.h +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -* -* BIOS emulator and interface -* to Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Header file for the real mode x86 BIOS emulator, which is -* used to warmboot any number of VGA compatible PCI/AGP -* controllers under any OS, on any processor family that -* supports PCI. We also allow the user application to call -* real mode BIOS functions and Int 10h functions (including -* the VESA BIOS). -* -****************************************************************************/ - -#ifndef __BIOSEMU_H -#define __BIOSEMU_H - -#include "x86emu.h" -#include "pmapi.h" -#include "pcilib.h" - -/*---------------------- Macros and type definitions ----------------------*/ - -#pragma pack(1) - -/**************************************************************************** -REMARKS: -Data structure used to describe the details specific to a particular VGA -controller. This information is used to allow the VGA controller to be -swapped on the fly within the BIOS emulator. - -HEADER: -biosemu.h - -MEMBERS: -pciInfo - PCI device information block for the controller -BIOSImage - Pointer to a read/write copy of the BIOS image -BIOSImageLen - Length of the BIOS image -LowMem - Copy of key low memory areas -****************************************************************************/ -typedef struct { - PCIDeviceInfo *pciInfo; - void *BIOSImage; - ulong BIOSImageLen; - uchar LowMem[1536]; - } BE_VGAInfo; - -/**************************************************************************** -REMARKS: -Data structure used to describe the details for the BIOS emulator system -environment as used by the X86 emulator library. - -HEADER: -biosemu.h - -MEMBERS: -vgaInfo - VGA BIOS information structure -biosmem_base - Base of the BIOS image -biosmem_limit - Limit of the BIOS image -busmem_base - Base of the VGA bus memory -****************************************************************************/ -typedef struct { - BE_VGAInfo vgaInfo; - ulong biosmem_base; - ulong biosmem_limit; - ulong busmem_base; - } BE_sysEnv; - -/**************************************************************************** -REMARKS: -Structure defining all the BIOS Emulator API functions as exported from -the Binary Portable DLL. -{secret} -****************************************************************************/ -typedef struct { - ulong dwSize; - ibool (PMAPIP BE_init)(u32 debugFlags,int memSize,BE_VGAInfo *info); - void (PMAPIP BE_setVGA)(BE_VGAInfo *info); - void (PMAPIP BE_getVGA)(BE_VGAInfo *info); - void * (PMAPIP BE_mapRealPointer)(uint r_seg,uint r_off); - void * (PMAPIP BE_getVESABuf)(uint *len,uint *rseg,uint *roff); - void (PMAPIP BE_callRealMode)(uint seg,uint off,RMREGS *regs,RMSREGS *sregs); - int (PMAPIP BE_int86)(int intno,RMREGS *in,RMREGS *out); - int (PMAPIP BE_int86x)(int intno,RMREGS *in,RMREGS *out,RMSREGS *sregs); - void * reserved1; - void (PMAPIP BE_exit)(void); - } BE_exports; - -/**************************************************************************** -REMARKS: -Function pointer type for the Binary Portable DLL initialisation entry point. -{secret} -****************************************************************************/ -typedef BE_exports * (PMAPIP BE_initLibrary_t)(PM_imports *PMImp); - -#pragma pack() - -/*---------------------------- Global variables ---------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -/* {secret} Global BIOS emulator system environment */ -extern BE_sysEnv _BE_env; - -/*-------------------------- Function Prototypes --------------------------*/ - -/* BIOS emulator library entry points */ - -ibool PMAPI BE_init(u32 debugFlags,int memSize,BE_VGAInfo *info); -void PMAPI BE_setVGA(BE_VGAInfo *info); -void PMAPI BE_getVGA(BE_VGAInfo *info); -void PMAPI BE_setDebugFlags(u32 debugFlags); -void * PMAPI BE_mapRealPointer(uint r_seg,uint r_off); -void * PMAPI BE_getVESABuf(uint *len,uint *rseg,uint *roff); -void PMAPI BE_callRealMode(uint seg,uint off,RMREGS *regs,RMSREGS *sregs); -int PMAPI BE_int86(int intno,RMREGS *in,RMREGS *out); -int PMAPI BE_int86x(int intno,RMREGS *in,RMREGS *out,RMSREGS *sregs); -void PMAPI BE_exit(void); - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif - -#endif /* __BIOSEMU_H */ diff --git a/board/MAI/bios_emulator/scitech/include/event.h b/board/MAI/bios_emulator/scitech/include/event.h deleted file mode 100644 index beeac87645..0000000000 --- a/board/MAI/bios_emulator/scitech/include/event.h +++ /dev/null @@ -1,696 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Header file for the SciTech cross platform event library -* -****************************************************************************/ - -#ifndef __EVENT_H -#define __EVENT_H - -#include "scitech.h" - -/*---------------------- Macros and type definitions ----------------------*/ - -#pragma pack(1) - -/* 'C' calling conventions always */ - -#define EVTAPI _ASMAPI -#define EVTAPIP _ASMAPIP - -/* Event message masks for keyDown events */ - -#define EVT_ASCIIMASK 0x00FF /* ASCII code of key pressed */ -#define EVT_SCANMASK 0xFF00 /* Scan code of key pressed */ -#define EVT_COUNTMASK 0x7FFF0000L /* Count for KEYREPEAT's */ - -/* Macros to extract values from the message fields */ - -#define EVT_asciiCode(m) ( (uchar) (m & EVT_ASCIIMASK) ) -#define EVT_scanCode(m) ( (uchar) ( (m & EVT_SCANMASK) >> 8 ) ) -#define EVT_repeatCount(m) ( (short) ( (m & EVT_COUNTMASK) >> 16 ) ) - -/**************************************************************************** -REMARKS: -Defines the set of ASCII codes reported by the event library functions -in the message field. Use the EVT_asciiCode macro to extract the code -from the event structure. - -HEADER: -event.h -****************************************************************************/ -typedef enum { - ASCII_ctrlA = 0x01, - ASCII_ctrlB = 0x02, - ASCII_ctrlC = 0x03, - ASCII_ctrlD = 0x04, - ASCII_ctrlE = 0x05, - ASCII_ctrlF = 0x06, - ASCII_ctrlG = 0x07, - ASCII_backspace = 0x08, - ASCII_ctrlH = 0x08, - ASCII_tab = 0x09, - ASCII_ctrlI = 0x09, - ASCII_ctrlJ = 0x0A, - ASCII_ctrlK = 0x0B, - ASCII_ctrlL = 0x0C, - ASCII_enter = 0x0D, - ASCII_ctrlM = 0x0D, - ASCII_ctrlN = 0x0E, - ASCII_ctrlO = 0x0F, - ASCII_ctrlP = 0x10, - ASCII_ctrlQ = 0x11, - ASCII_ctrlR = 0x12, - ASCII_ctrlS = 0x13, - ASCII_ctrlT = 0x14, - ASCII_ctrlU = 0x15, - ASCII_ctrlV = 0x16, - ASCII_ctrlW = 0x17, - ASCII_ctrlX = 0x18, - ASCII_ctrlY = 0x19, - ASCII_ctrlZ = 0x1A, - ASCII_esc = 0x1B, - ASCII_space = 0x20, - ASCII_exclamation = 0x21, /* ! */ - ASCII_quote = 0x22, /* " */ - ASCII_pound = 0x23, /* # */ - ASCII_dollar = 0x24, /* $ */ - ASCII_percent = 0x25, /* % */ - ASCII_ampersand = 0x26, /* & */ - ASCII_apostrophe = 0x27, /* ' */ - ASCII_leftBrace = 0x28, /* ( */ - ASCII_rightBrace = 0x29, /* ) */ - ASCII_times = 0x2A, /* * */ - ASCII_plus = 0x2B, /* + */ - ASCII_comma = 0x2C, /* , */ - ASCII_minus = 0x2D, /* - */ - ASCII_period = 0x2E, /* . */ - ASCII_divide = 0x2F, /* / */ - ASCII_0 = 0x30, - ASCII_1 = 0x31, - ASCII_2 = 0x32, - ASCII_3 = 0x33, - ASCII_4 = 0x34, - ASCII_5 = 0x35, - ASCII_6 = 0x36, - ASCII_7 = 0x37, - ASCII_8 = 0x38, - ASCII_9 = 0x39, - ASCII_colon = 0x3A, /* : */ - ASCII_semicolon = 0x3B, /* ; */ - ASCII_lessThan = 0x3C, /* < */ - ASCII_equals = 0x3D, /* = */ - ASCII_greaterThan = 0x3E, /* > */ - ASCII_question = 0x3F, /* ? */ - ASCII_at = 0x40, /* @ */ - ASCII_A = 0x41, - ASCII_B = 0x42, - ASCII_C = 0x43, - ASCII_D = 0x44, - ASCII_E = 0x45, - ASCII_F = 0x46, - ASCII_G = 0x47, - ASCII_H = 0x48, - ASCII_I = 0x49, - ASCII_J = 0x4A, - ASCII_K = 0x4B, - ASCII_L = 0x4C, - ASCII_M = 0x4D, - ASCII_N = 0x4E, - ASCII_O = 0x4F, - ASCII_P = 0x50, - ASCII_Q = 0x51, - ASCII_R = 0x52, - ASCII_S = 0x53, - ASCII_T = 0x54, - ASCII_U = 0x55, - ASCII_V = 0x56, - ASCII_W = 0x57, - ASCII_X = 0x58, - ASCII_Y = 0x59, - ASCII_Z = 0x5A, - ASCII_leftSquareBrace = 0x5B, /* [ */ - ASCII_backSlash = 0x5C, /* \ */ - ASCII_rightSquareBrace = 0x5D, /* ] */ - ASCII_caret = 0x5E, /* ^ */ - ASCII_underscore = 0x5F, /* _ */ - ASCII_leftApostrophe = 0x60, /* ` */ - ASCII_a = 0x61, - ASCII_b = 0x62, - ASCII_c = 0x63, - ASCII_d = 0x64, - ASCII_e = 0x65, - ASCII_f = 0x66, - ASCII_g = 0x67, - ASCII_h = 0x68, - ASCII_i = 0x69, - ASCII_j = 0x6A, - ASCII_k = 0x6B, - ASCII_l = 0x6C, - ASCII_m = 0x6D, - ASCII_n = 0x6E, - ASCII_o = 0x6F, - ASCII_p = 0x70, - ASCII_q = 0x71, - ASCII_r = 0x72, - ASCII_s = 0x73, - ASCII_t = 0x74, - ASCII_u = 0x75, - ASCII_v = 0x76, - ASCII_w = 0x77, - ASCII_x = 0x78, - ASCII_y = 0x79, - ASCII_z = 0x7A, - ASCII_leftCurlyBrace = 0x7B, /* { */ - ASCII_verticalBar = 0x7C, /* | */ - ASCII_rightCurlyBrace = 0x7D, /* } */ - ASCII_tilde = 0x7E /* ~ */ - } EVT_asciiCodesType; - -/**************************************************************************** -REMARKS: -Defines the set of scan codes reported by the event library functions -in the message field. Use the EVT_scanCode macro to extract the code -from the event structure. Note that the scan codes reported will be the -same across all keyboards (assuming the placement of keys on a 101 key US -keyboard), but the translated ASCII values may be different depending on -the country code pages in use. - -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 codes begin with scan code 0x60 and - range up from there. - -HEADER: -event.h -****************************************************************************/ -typedef enum { - KB_padEnter = 0x60, /* Keypad keys */ - KB_padMinus = 0x4A, - KB_padPlus = 0x4E, - KB_padTimes = 0x37, - KB_padDivide = 0x61, - KB_padLeft = 0x62, - KB_padRight = 0x63, - KB_padUp = 0x64, - KB_padDown = 0x65, - KB_padInsert = 0x66, - KB_padDelete = 0x67, - KB_padHome = 0x68, - KB_padEnd = 0x69, - KB_padPageUp = 0x6A, - KB_padPageDown = 0x6B, - KB_padCenter = 0x4C, - KB_F1 = 0x3B, /* Function keys */ - KB_F2 = 0x3C, - KB_F3 = 0x3D, - KB_F4 = 0x3E, - KB_F5 = 0x3F, - KB_F6 = 0x40, - KB_F7 = 0x41, - KB_F8 = 0x42, - KB_F9 = 0x43, - KB_F10 = 0x44, - KB_F11 = 0x57, - KB_F12 = 0x58, - KB_left = 0x4B, /* Cursor control keys */ - KB_right = 0x4D, - KB_up = 0x48, - KB_down = 0x50, - KB_insert = 0x52, - KB_delete = 0x53, - KB_home = 0x47, - KB_end = 0x4F, - KB_pageUp = 0x49, - KB_pageDown = 0x51, - KB_capsLock = 0x3A, - KB_numLock = 0x45, - KB_scrollLock = 0x46, - KB_leftShift = 0x2A, - KB_rightShift = 0x36, - KB_leftCtrl = 0x1D, - KB_rightCtrl = 0x6C, - KB_leftAlt = 0x38, - KB_rightAlt = 0x6D, - KB_leftWindows = 0x5B, - KB_rightWindows = 0x5C, - KB_menu = 0x5D, - KB_sysReq = 0x54, - KB_esc = 0x01, /* Normal keyboard keys */ - KB_1 = 0x02, - KB_2 = 0x03, - KB_3 = 0x04, - KB_4 = 0x05, - KB_5 = 0x06, - KB_6 = 0x07, - KB_7 = 0x08, - KB_8 = 0x09, - KB_9 = 0x0A, - KB_0 = 0x0B, - KB_minus = 0x0C, - KB_equals = 0x0D, - KB_backSlash = 0x2B, - KB_backspace = 0x0E, - KB_tab = 0x0F, - KB_Q = 0x10, - KB_W = 0x11, - KB_E = 0x12, - KB_R = 0x13, - KB_T = 0x14, - KB_Y = 0x15, - KB_U = 0x16, - KB_I = 0x17, - KB_O = 0x18, - KB_P = 0x19, - KB_leftSquareBrace = 0x1A, - KB_rightSquareBrace = 0x1B, - KB_enter = 0x1C, - KB_A = 0x1E, - KB_S = 0x1F, - KB_D = 0x20, - KB_F = 0x21, - KB_G = 0x22, - KB_H = 0x23, - KB_J = 0x24, - KB_K = 0x25, - KB_L = 0x26, - KB_semicolon = 0x27, - KB_apostrophe = 0x28, - KB_Z = 0x2C, - KB_X = 0x2D, - KB_C = 0x2E, - KB_V = 0x2F, - KB_B = 0x30, - KB_N = 0x31, - KB_M = 0x32, - KB_comma = 0x33, - KB_period = 0x34, - KB_divide = 0x35, - KB_space = 0x39, - KB_tilde = 0x29 - } EVT_scanCodesType; - -/**************************************************************************** -REMARKS: -Defines the mask for the joystick axes that are present - -HEADER: -event.h - -MEMBERS: -EVT_JOY_AXIS_X1 - Joystick 1, X axis is present -EVT_JOY_AXIS_Y1 - Joystick 1, Y axis is present -EVT_JOY_AXIS_X2 - Joystick 2, X axis is present -EVT_JOY_AXIS_Y2 - Joystick 2, Y axis is present -EVT_JOY_AXIS_ALL - Mask for all axes -****************************************************************************/ -typedef enum { - EVT_JOY_AXIS_X1 = 0x00000001, - EVT_JOY_AXIS_Y1 = 0x00000002, - EVT_JOY_AXIS_X2 = 0x00000004, - EVT_JOY_AXIS_Y2 = 0x00000008, - EVT_JOY_AXIS_ALL = 0x0000000F - } EVT_eventJoyAxisType; - -/**************************************************************************** -REMARKS: -Defines the event message masks for joystick events - -HEADER: -event.h - -MEMBERS: -EVT_JOY1_BUTTONA - Joystick 1, button A is down -EVT_JOY1_BUTTONB - Joystick 1, button B is down -EVT_JOY2_BUTTONA - Joystick 2, button A is down -EVT_JOY2_BUTTONB - Joystick 2, button B is down -****************************************************************************/ -typedef enum { - EVT_JOY1_BUTTONA = 0x00000001, - EVT_JOY1_BUTTONB = 0x00000002, - EVT_JOY2_BUTTONA = 0x00000004, - EVT_JOY2_BUTTONB = 0x00000008 - } EVT_eventJoyMaskType; - -/**************************************************************************** -REMARKS: -Defines the event message masks for mouse events - -HEADER: -event.h - -MEMBERS: -EVT_LEFTBMASK - Left button is held down -EVT_RIGHTBMASK - Right button is held down -EVT_MIDDLEBMASK - Middle button is held down -EVT_BOTHBMASK - Both left and right held down together -EVT_ALLBMASK - All buttons pressed -EVT_DBLCLICK - Set if mouse down event was a double click -****************************************************************************/ -typedef enum { - EVT_LEFTBMASK = 0x00000001, - EVT_RIGHTBMASK = 0x00000002, - EVT_MIDDLEBMASK = 0x00000004, - EVT_BOTHBMASK = 0x00000007, - EVT_ALLBMASK = 0x00000007, - EVT_DBLCLICK = 0x00010000 - } EVT_eventMouseMaskType; - -/**************************************************************************** -REMARKS: -Defines the event modifier masks. These are the masks used to extract -the modifier information from the modifiers field of the event_t structure. -Note that the values in the modifiers field represent the values of these -modifier keys at the time the event occurred, not the time you decided -to process the event. - -HEADER: -event.h - -MEMBERS: -EVT_LEFTBUT - Set if left mouse button was down -EVT_RIGHTBUT - Set if right mouse button was down -EVT_MIDDLEBUT - Set if the middle button was down -EVT_RIGHTSHIFT - Set if right shift was down -EVT_LEFTSHIFT - Set if left shift was down -EVT_RIGHTCTRL - Set if right ctrl key was down -EVT_RIGHTALT - Set if right alt key was down -EVT_LEFTCTRL - Set if left ctrl key was down -EVT_LEFTALT - Set if left alt key was down -EVT_SHIFTKEY - Mask for any shift key down -EVT_CTRLSTATE - Set if ctrl key was down -EVT_ALTSTATE - Set if alt key was down -EVT_CAPSLOCK - Caps lock is active -EVT_NUMLOCK - Num lock is active -EVT_SCROLLLOCK - Scroll lock is active -****************************************************************************/ -typedef enum { - EVT_LEFTBUT = 0x00000001, - EVT_RIGHTBUT = 0x00000002, - EVT_MIDDLEBUT = 0x00000004, - EVT_RIGHTSHIFT = 0x00000008, - EVT_LEFTSHIFT = 0x00000010, - EVT_RIGHTCTRL = 0x00000020, - EVT_RIGHTALT = 0x00000040, - EVT_LEFTCTRL = 0x00000080, - EVT_LEFTALT = 0x00000100, - EVT_SHIFTKEY = 0x00000018, - EVT_CTRLSTATE = 0x000000A0, - EVT_ALTSTATE = 0x00000140, - EVT_SCROLLLOCK = 0x00000200, - EVT_NUMLOCK = 0x00000400, - EVT_CAPSLOCK = 0x00000800 - } EVT_eventModMaskType; - -/**************************************************************************** -REMARKS: -Defines the event codes returned in the event_t structures what field. Note -that these are defined as a set of mutually exlusive bit fields, so you -can test for multiple event types using the combined event masks defined -in the EVT_eventMaskType enumeration. - -HEADER: -event.h - -MEMBERS: -EVT_NULLEVT - A null event -EVT_KEYDOWN - Key down event -EVT_KEYREPEAT - Key repeat event -EVT_KEYUP - Key up event -EVT_MOUSEDOWN - Mouse down event -EVT_MOUSEAUTO - Mouse down autorepeat event -EVT_MOUSEUP - Mouse up event -EVT_MOUSEMOVE - Mouse movement event -EVT_JOYCLICK - Joystick button state change event -EVT_JOYMOVE - Joystick movement event -EVT_USEREVT - First user event -****************************************************************************/ -typedef enum { - EVT_NULLEVT = 0x00000000, - EVT_KEYDOWN = 0x00000001, - EVT_KEYREPEAT = 0x00000002, - EVT_KEYUP = 0x00000004, - EVT_MOUSEDOWN = 0x00000008, - EVT_MOUSEAUTO = 0x00000010, - EVT_MOUSEUP = 0x00000020, - EVT_MOUSEMOVE = 0x00000040, - EVT_JOYCLICK = 0x00000080, - EVT_JOYMOVE = 0x00000100, - EVT_USEREVT = 0x00000200 - } EVT_eventType; - -/**************************************************************************** -REMARKS: -Defines the event code masks you can use to test for multiple types of -events, since the event codes are mutually exlusive bit fields. - -HEADER: -event.h - -MEMBERS: -EVT_KEYEVT - Mask for any key event -EVT_MOUSEEVT - Mask for any mouse event -EVT_MOUSECLICK - Mask for any mouse click event -EVT_JOYEVT - Mask for any joystick event -EVT_EVERYEVT - Mask for any event -****************************************************************************/ -typedef enum { - EVT_KEYEVT = (EVT_KEYDOWN | EVT_KEYREPEAT | EVT_KEYUP), - EVT_MOUSEEVT = (EVT_MOUSEDOWN | EVT_MOUSEAUTO | EVT_MOUSEUP | EVT_MOUSEMOVE), - EVT_MOUSECLICK = (EVT_MOUSEDOWN | EVT_MOUSEUP), - EVT_JOYEVT = (EVT_JOYCLICK | EVT_JOYMOVE), - EVT_EVERYEVT = 0x7FFFFFFF - } EVT_eventMaskType; - -/**************************************************************************** -REMARKS: -Structure describing the information contained in an event extracted from -the event queue. - -HEADER: -event.h - -MEMBERS: -which - Window identifier for message for use by high level window manager - code (i.e. MegaVision GUI or Windows API). -what - Type of event that occurred. Will be one of the values defined by - the EVT_eventType enumeration. -when - Time that the event occurred in milliseconds since startup -where_x - X coordinate of the mouse cursor location at the time of the event - (in screen coordinates). For joystick events this represents - the position of the first joystick X axis. -where_y - Y coordinate of the mouse cursor location at the time of the event - (in screen coordinates). For joystick events this represents - the position of the first joystick Y axis. -relative_x - Relative movement of the mouse cursor in the X direction (in - units of mickeys, or 1/200th of an inch). For joystick events - this represents the position of the second joystick X axis. -relative_y - Relative movement of the mouse cursor in the Y direction (in - units of mickeys, or 1/200th of an inch). For joystick events - this represents the position of the second joystick Y axis. -message - Event specific message for the event. For use events this can be - any user specific information. For keyboard events this contains - the ASCII code in bits 0-7, the keyboard scan code in bits 8-15 and - the character repeat count in bits 16-30. You can use the - EVT_asciiCode, EVT_scanCode and EVT_repeatCount macros to extract - this information from the message field. For mouse events this - contains information about which button was pressed, and will be a - combination of the flags defined by the EVT_eventMouseMaskType - enumeration. For joystick events, this conatins information - about which buttons were pressed, and will be a combination of - the flags defined by the EVT_eventJoyMaskType enumeration. -modifiers - Contains additional information about the state of the keyboard - shift modifiers (Ctrl, Alt and Shift keys) when the event - occurred. For mouse events it will also contain the state of - the mouse buttons. Will be a combination of the values defined - by the EVT_eventModMaskType enumeration. -next - Internal use; do not use. -prev - Internal use; do not use. -****************************************************************************/ -typedef struct { - ulong which; - ulong what; - ulong when; - int where_x; - int where_y; - int relative_x; - int relative_y; - ulong message; - ulong modifiers; - int next; - int prev; - } event_t; - -/**************************************************************************** -REMARKS: -Structure describing an entry in the code page table. A table of translation -codes for scan codes to ASCII codes is provided in this table to be used -by the keyboard event libraries. On some OS'es the keyboard translation is -handled by the OS, but for DOS and embedded systems you must register a -different code page translation table if you want to support keyboards -other than the US English keyboard (the default). - -NOTE: Entries in code page tables *must* be in ascending order for the - scan codes as we do a binary search on the tables for the ASCII - code equivalents. - -HEADER: -event.h - -MEMBERS: -scanCode - Scan code to translate (really the virtual scan code). -asciiCode - ASCII code for this scan code. -****************************************************************************/ -typedef struct { - uchar scanCode; - uchar asciiCode; - } codepage_entry_t; - -/**************************************************************************** -REMARKS: -Structure describing a complete code page translation table. The table -contains translation tables for normal keys, shifted keys and ctrl keys. -The Ctrl key always has precedence over the shift table, and the shift -table is used when the shift key is down or the CAPSLOCK key is down. - -HEADER: -event.h - -MEMBERS: -name - Name of the code page table (ie: "US English") -normal - Code page for translating normal keys -normalLen - Length of normal translation table -caps - Code page for translating keys when CAPSLOCK is down -capsLen - Length of CAPSLOCK translation table -shift - Code page for shifted keys (ie: shift key is held down) -shiftLen - Length of shifted translation table -shiftCaps - Code page for shifted keys when CAPSLOCK is down -shiftCapsLen - Length of shifted CAPSLOCK translation table -ctrl - Code page for ctrl'ed keys (ie: ctrl key is held down) -ctrlLen - Length of ctrl'ed translation table -numPad - Code page for NUMLOCK'ed keypad keys -numPadLen - Length of NUMLOCK'ed translation table -****************************************************************************/ -typedef struct { - char name[20]; - codepage_entry_t *normal; - int normalLen; - codepage_entry_t *caps; - int capsLen; - codepage_entry_t *shift; - int shiftLen; - codepage_entry_t *shiftCaps; - int shiftCapsLen; - codepage_entry_t *ctrl; - int ctrlLen; - codepage_entry_t *numPad; - int numPadLen; - } codepage_t; - -/* {secret} */ -typedef ibool (EVTAPIP _EVT_userEventFilter)(event_t *evt); -/* {secret} */ -typedef void (EVTAPIP _EVT_mouseMoveHandler)(int x,int y); -/* {secret} */ -typedef void (EVTAPIP _EVT_heartBeatCallback)(void *params); - -/* Macro to find the size of a static array */ - -#define EVT_ARR_SIZE(a) (sizeof(a)/sizeof((a)[0])) - -#pragma pack() - -/*--------------------------- Global variables ----------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -/* Standard code page tables */ - -extern codepage_t _CP_US_English; - -/*------------------------- Function Prototypes ---------------------------*/ - -/* Public API functions for user applications */ - -ibool EVTAPI EVT_getNext(event_t *evt,ulong mask); -ibool EVTAPI EVT_peekNext(event_t *evt,ulong mask); -ibool EVTAPI EVT_post(ulong which,ulong what,ulong message,ulong modifiers); -void EVTAPI EVT_flush(ulong mask); -void EVTAPI EVT_halt(event_t *evt,ulong mask); -ibool EVTAPI EVT_isKeyDown(uchar scanCode); -void EVTAPI EVT_setMousePos(int x,int y); -void EVTAPI EVT_getMousePos(int *x,int *y); - -/* Function to enable/disable updating of keyboard LED status indicators */ - -void EVTAPI EVT_allowLEDS(ibool enable); - -/* Function to install a custom keyboard code page. Default is US English */ - -codepage_t *EVTAPI EVT_getCodePage(void); -void EVTAPI EVT_setCodePage(codepage_t *page); - -/* Functions for fine grained joystick calibration */ - -void EVTAPI EVT_pollJoystick(void); -int EVTAPI EVT_joyIsPresent(void); -void EVTAPI EVT_joySetUpperLeft(void); -void EVTAPI EVT_joySetLowerRight(void); -void EVTAPI EVT_joySetCenter(void); - -/* Install user supplied event filter callback */ - -void EVTAPI EVT_setUserEventFilter(_EVT_userEventFilter filter); - -/* Install user supplied event heartbeat callback function */ - -void EVTAPI EVT_setHeartBeatCallback(_EVT_heartBeatCallback callback,void *params); -void EVTAPI EVT_getHeartBeatCallback(_EVT_heartBeatCallback *callback,void **params); - -/* Internal functions to initialise and kill the event manager. MGL - * applications should never call these functions directly as the MGL - * libraries do it for you. - */ - -/* {secret} */ -void EVTAPI EVT_init(_EVT_mouseMoveHandler mouseMove); -/* {secret} */ -void EVTAPI EVT_setMouseRange(int xRes,int yRes); -/* {secret} */ -void EVTAPI EVT_suspend(void); -/* {secret} */ -void EVTAPI EVT_resume(void); -/* {secret} */ -void EVTAPI EVT_exit(void); - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif /* __cplusplus */ - -#endif /* __EVENT_H */ diff --git a/board/MAI/bios_emulator/scitech/include/mtrr.h b/board/MAI/bios_emulator/scitech/include/mtrr.h deleted file mode 100644 index b29812c928..0000000000 --- a/board/MAI/bios_emulator/scitech/include/mtrr.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Include file defining the external ring 0 helper functions -* needed by the MTRR module. These functions may be included -* directly for native ring 0 device drivers, or they may -* be calls down to a ring 0 helper device driver where -* appropriate (or the entire MTRR module may be located in -* the device driver if the device driver is 32-bit). -* -****************************************************************************/ - -#ifndef __MTRR_H -#define __MTRR_H - -#include "scitech.h" - -/*--------------------------- Function Prototypes -------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -/* Internal functions (requires ring 0 access or helper functions!) */ - -void MTRR_init(void); -int MTRR_enableWriteCombine(ulong base,ulong size,uint type); - -/* External assembler helper functions */ - -ibool _ASMAPI _MTRR_isRing0(void); -ulong _ASMAPI _MTRR_disableInt(void); -void _ASMAPI _MTRR_restoreInt(ulong flags); -ulong _ASMAPI _MTRR_saveCR4(void); -void _ASMAPI _MTRR_restoreCR4(ulong cr4Val); -uchar _ASMAPI _MTRR_getCx86(uchar reg); -void _ASMAPI _MTRR_setCx86(uchar reg,uchar data); -#ifdef __16BIT__ -void _ASMAPI _MTRR_readMSR(ulong reg, ulong far *eax, ulong far *edx); -#else -void _ASMAPI _MTRR_readMSR(ulong reg, ulong *eax, ulong *edx); -#endif -void _ASMAPI _MTRR_writeMSR(ulong reg, ulong eax, ulong edx); - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif - -#endif /* __MTRR_H */ diff --git a/board/MAI/bios_emulator/scitech/include/pcilib.h b/board/MAI/bios_emulator/scitech/include/pcilib.h deleted file mode 100644 index 238f8ef83b..0000000000 --- a/board/MAI/bios_emulator/scitech/include/pcilib.h +++ /dev/null @@ -1,413 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Header file for interface routines to the PCI bus. -* -****************************************************************************/ - -#ifndef __PCILIB_H -#define __PCILIB_H - -#include "scitech.h" - -/*---------------------- Macros and type definitions ----------------------*/ - -#pragma pack(1) - -/* Defines for PCIDeviceInfo.HeaderType */ - -typedef enum { - PCI_deviceType = 0x00, - PCI_bridgeType = 0x01, - PCI_cardBusBridgeType = 0x02, - PCI_multiFunctionType = 0x80 - } PCIHeaderTypeFlags; - -/* Defines for PCIDeviceInfo.Command */ - -typedef enum { - PCI_enableIOSpace = 0x0001, - PCI_enableMemorySpace = 0x0002, - PCI_enableBusMaster = 0x0004, - PCI_enableSpecialCylces = 0x0008, - PCI_enableWriteAndInvalidate = 0x0010, - PCI_enableVGACompatiblePalette = 0x0020, - PCI_enableParity = 0x0040, - PCI_enableWaitCycle = 0x0080, - PCI_enableSerr = 0x0100, - PCI_enableFastBackToBack = 0x0200 - } PCICommandFlags; - -/* Defines for PCIDeviceInfo.Status */ - -typedef enum { - PCI_statusCapabilitiesList = 0x0010, - PCI_status66MhzCapable = 0x0020, - PCI_statusUDFSupported = 0x0040, - PCI_statusFastBackToBack = 0x0080, - PCI_statusDataParityDetected = 0x0100, - PCI_statusDevSel = 0x0600, - PCI_statusSignaledTargetAbort = 0x0800, - PCI_statusRecievedTargetAbort = 0x1000, - PCI_statusRecievedMasterAbort = 0x2000, - PCI_statusSignaledSystemError = 0x4000, - PCI_statusDetectedParityError = 0x8000 - } PCIStatusFlags; - -/* PCI capability IDs */ - -typedef enum { - PCI_capsPowerManagement = 0x01, - PCI_capsAGP = 0x02, - PCI_capsMSI = 0x05 - } PCICapsType; - -/* PCI AGP rate definitions */ - -typedef enum { - PCI_AGPRate1X = 0x1, - PCI_AGPRate2X = 0x2, - PCI_AGPRate4X = 0x4 - } PCIAGPRateType; - -/* NOTE: We define all bitfield's as uint's, specifically so that the IBM - * Visual Age C++ compiler does not complain. We need them to be - * 32-bits wide, and this is the width of an unsigned integer, but - * we can't use a ulong to make this explicit or we get errors. - */ - -/* Structure defining a PCI slot identifier */ - -typedef union { - struct { - uint Zero:2; - uint Register:6; - uint Function:3; - uint Device:5; - uint Bus:8; - uint Reserved:7; - uint Enable:1; - } p; - ulong i; - } PCIslot; - -/* Structure defining the regular (type 0) PCI configuration register - * layout. We use this in a union below so we can describe all types of - * PCI configuration spaces with a single structure. - */ - -typedef struct { - ulong BaseAddress10; - ulong BaseAddress14; - ulong BaseAddress18; - ulong BaseAddress1C; - ulong BaseAddress20; - ulong BaseAddress24; - ulong CardbusCISPointer; - ushort SubSystemVendorID; - ushort SubSystemID; - ulong ROMBaseAddress; - uchar CapabilitiesPointer; - uchar reserved1; - uchar reserved2; - uchar reserved3; - ulong reserved4; - uchar InterruptLine; - uchar InterruptPin; - uchar MinimumGrant; - uchar MaximumLatency; - - /* These are not in the actual config space, but we enumerate them */ - ulong BaseAddress10Len; - ulong BaseAddress14Len; - ulong BaseAddress18Len; - ulong BaseAddress1CLen; - ulong BaseAddress20Len; - ulong BaseAddress24Len; - ulong ROMBaseAddressLen; - } PCIType0Info; - -/* Structure defining PCI to PCI bridge (type 1) PCI configuration register - * layout. We use this in a union below so we can describe all types of - * PCI configuration spaces with a single structure. - */ - -typedef struct { - ulong BaseAddress10; - ulong BaseAddress14; - uchar PrimaryBusNumber; - uchar SecondayBusNumber; - uchar SubordinateBusNumber; - uchar SecondaryLatencyTimer; - uchar IOBase; - uchar IOLimit; - ushort SecondaryStatus; - ushort MemoryBase; - ushort MemoryLimit; - ushort PrefetchableMemoryBase; - ushort PrefetchableMemoryLimit; - ulong PrefetchableBaseHi; - ulong PrefetchableLimitHi; - ushort IOBaseHi; - ushort IOLimitHi; - uchar CapabilitiesPointer; - uchar reserved1; - uchar reserved2; - uchar reserved3; - ulong ROMBaseAddress; - uchar InterruptLine; - uchar InterruptPin; - ushort BridgeControl; - } PCIType1Info; - -/* PCI to CardBus bridge (type 2) configuration information */ -typedef struct { - ulong SocketRegistersBaseAddress; - uchar CapabilitiesPointer; - uchar reserved1; - ushort SecondaryStatus; - uchar PrimaryBus; - uchar SecondaryBus; - uchar SubordinateBus; - uchar SecondaryLatency; - struct { - ulong Base; - ulong Limit; - } Range[4]; - uchar InterruptLine; - uchar InterruptPin; - ushort BridgeControl; - } PCIType2Info; - -/* Structure defining the PCI configuration space information for a - * single PCI device on the PCI bus. We enumerate all this information - * for all PCI devices on the bus. - */ - -typedef struct { - ulong dwSize; - PCIslot slot; - ulong mech1; - ushort VendorID; - ushort DeviceID; - ushort Command; - ushort Status; - uchar RevID; - uchar Interface; - uchar SubClass; - uchar BaseClass; - uchar CacheLineSize; - uchar LatencyTimer; - uchar HeaderType; - uchar BIST; - union { - PCIType0Info type0; - PCIType1Info type1; - PCIType2Info type2; - } u; - } PCIDeviceInfo; - -/* PCI Capability header structure. All PCI capabilities have the - * following header. - * - * capsID is used to identify the type of the structure as define above. - * - * next is the offset in PCI configuration space (0x40-0xFC) of the - * next capability structure in the list, or 0x00 if there are no more - * entries. - */ - -typedef struct { - uchar capsID; - uchar next; - } PCICapsHeader; - -/* Structure defining the PCI AGP status register contents */ - -typedef struct { - uint rate:3; - uint rsvd1:1; - uint fastWrite:1; - uint fourGB:1; - uint rsvd2:3; - uint sideBandAddressing:1; - uint rsvd3:14; - uint requestQueueDepthMaximum:8; - } PCIAGPStatus; - -/* Structure defining the PCI AGP command register contents */ - -typedef struct { - uint rate:3; - uint rsvd1:1; - uint fastWriteEnable:1; - uint fourGBEnable:1; - uint rsvd2:2; - uint AGPEnable:1; - uint SBAEnable:1; - uint rsvd3:14; - uint requestQueueDepth:8; - } PCIAGPCommand; - -/* AGP Capability structure */ - -typedef struct { - PCICapsHeader h; - ushort majMin; - PCIAGPStatus AGPStatus; - PCIAGPCommand AGPCommand; - } PCIAGPCapability; - -/* Structure for obtaining the PCI IRQ routing information */ - -typedef struct { - uchar bus; - uchar device; - uchar linkA; - ushort mapA; - uchar linkB; - ushort mapB; - uchar linkC; - ushort mapC; - uchar linkD; - ushort mapD; - uchar slot; - uchar reserved; - } PCIRouteInfo; - -typedef struct { - ushort BufferSize; - PCIRouteInfo *DataBuffer; - } PCIRoutingOptionsBuffer; - -#define NUM_PCI_REG (sizeof(PCIDeviceInfo) / 4) - 10 -#define PCI_BRIDGE_CLASS 0x06 -#define PCI_HOST_BRIDGE_SUBCLASS 0x00 -#define PCI_EARLY_VGA_CLASS 0x00 -#define PCI_EARLY_VGA_SUBCLASS 0x01 -#define PCI_DISPLAY_CLASS 0x03 -#define PCI_DISPLAY_VGA_SUBCLASS 0x00 -#define PCI_DISPLAY_XGA_SUBCLASS 0x01 -#define PCI_DISPLAY_OTHER_SUBCLASS 0x80 -#define PCI_MM_CLASS 0x04 -#define PCI_AUDIO_SUBCLASS 0x01 - -/* Macros to detect specific classes of devices */ - -#define PCI_IS_3DLABS_NONVGA_CLASS(pci) \ - (((pci)->BaseClass == PCI_DISPLAY_CLASS && (pci)->SubClass == PCI_DISPLAY_OTHER_SUBCLASS) \ - && ((pci)->VendorID == 0x3D3D || (pci)->VendorID == 0x104C)) - -#define PCI_IS_DISPLAY_CLASS(pci) \ - (((pci)->BaseClass == PCI_DISPLAY_CLASS && (pci)->SubClass == PCI_DISPLAY_VGA_SUBCLASS) \ - || ((pci)->BaseClass == PCI_DISPLAY_CLASS && (pci)->SubClass == PCI_DISPLAY_XGA_SUBCLASS) \ - || ((pci)->BaseClass == PCI_EARLY_VGA_CLASS && (pci)->SubClass == PCI_EARLY_VGA_SUBCLASS) \ - || PCI_IS_3DLABS_NONVGA_CLASS(pci)) - -/* Function codes to pass to PCI_accessReg */ - -#define PCI_READ_BYTE 0 -#define PCI_READ_WORD 1 -#define PCI_READ_DWORD 2 -#define PCI_WRITE_BYTE 3 -#define PCI_WRITE_WORD 4 -#define PCI_WRITE_DWORD 5 - -/* Macros to read/write PCI registers. These assume a global PCI array - * of device information. - */ - -#define PCI_readPCIRegB(index,device) \ - PCI_accessReg(index,0,0,&PCI[DeviceIndex[device]]) - -#define PCI_readPCIRegW(index,device) \ - PCI_accessReg(index,0,1,&PCI[DeviceIndex[device]]) - -#define PCI_readPCIRegL(index,device) \ - PCI_accessReg(index,0,2,&PCI[DeviceIndex[device]]) - -#define PCI_writePCIRegB(index,value,device) \ - PCI_accessReg(index,value,3,&PCI[DeviceIndex[device]]) - -#define PCI_writePCIRegW(index,value,device) \ - PCI_accessReg(index,value,4,&PCI[DeviceIndex[device]]) - -#define PCI_writePCIRegL(index,value,device) \ - PCI_accessReg(index,value,5,&PCI[DeviceIndex[device]]) - -#pragma pack() - -/*-------------------------- Function Prototypes --------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -/* Function to determine the number of PCI devices in the system */ - -int _ASMAPI PCI_getNumDevices(void); - -/* Function to enumerate all device on the PCI bus */ - -int _ASMAPI PCI_enumerate(PCIDeviceInfo info[]); - -/* Function to access PCI configuration registers */ - -ulong _ASMAPI PCI_accessReg(int index,ulong value,int func,PCIDeviceInfo *info); - -/* Function to get PCI IRQ routing options for a card */ - -int _ASMAPI PCI_getIRQRoutingOptions(int numDevices,PCIRouteInfo *buffer); - -/* Function to re-route the PCI IRQ setting for a device */ - -ibool _ASMAPI PCI_setHardwareIRQ(PCIDeviceInfo *info,uint intPin,uint IRQ); - -/* Function to generate a special cyle on the specified PCI bus */ - -void _ASMAPI PCI_generateSpecialCyle(uint bus,ulong specialCycleData); - -/* Function to determine the size of a PCI base address register */ - -ulong _ASMAPI PCI_findBARSize(int bar,PCIDeviceInfo *pci); - -/* Function to read a block of PCI configuration space registers */ - -void _ASMAPI PCI_readRegBlock(PCIDeviceInfo *info,int index,void *dst,int count); - -/* Function to write a block of PCI configuration space registers */ - -void _ASMAPI PCI_writeRegBlock(PCIDeviceInfo *info,int index,void *src,int count); - -/* Function to return the 32-bit PCI BIOS entry point */ - -ulong _ASMAPI PCIBIOS_getEntry(void); - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif - -#endif /* __PCILIB_H */ diff --git a/board/MAI/bios_emulator/scitech/include/pm_help.h b/board/MAI/bios_emulator/scitech/include/pm_help.h deleted file mode 100644 index 536a2baac5..0000000000 --- a/board/MAI/bios_emulator/scitech/include/pm_help.h +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Win32, OS/2 -* -* Description: Include file for the SciTech Portability Manager 32-bit -* helper VxD for Windows 9x for and the 16-bit ring 0 -* helper device driver for OS/2. -* -* This file documents all the public services used by the -* SciTech Portability Manager library and SciTech Nucleus -* loader library. -* -****************************************************************************/ - -#ifndef __PMHELP_H -#define __PMHELP_H - -/* Include version information */ - -#include "sdd/sddver.h" -#define PMHELP_Major SDD_RELEASE_MAJOR -#define PMHELP_Minor SDD_RELEASE_MINOR -#define PMHELP_VERSION ((PMHELP_Major << 8) | PMHELP_Minor) - -#ifdef __OS2__ - -/**************************************************************************** -* Public OS/2 Support functions -****************************************************************************/ - -#include "scitech.h" -#include "nucleus/graphics.h" - -/* Name of device driver */ - -#define PMHELP_NAME (PSZ)"sddhelp$" - -/* Main IOCTL function to talk to device driver */ - -#define PMHELP_IOCTL 0x0080 - -/* Macro definition for defining IOCTL function control codes for the SDDHELP - * device driver for OS/2. Similar to that used for the DOS/Win32 version. - */ - -#define PMHELP_CTL_CODE(name,value) \ - PMHELP_##name = value - -typedef enum { - /* Version function used by all drivers */ - PMHELP_CTL_CODE(GETVER ,0x0001), - PMHELP_CTL_CODE(MAPPHYS ,0x0002), - PMHELP_CTL_CODE(ALLOCLOCKED ,0x0003), - PMHELP_CTL_CODE(FREELOCKED ,0x0004), - PMHELP_CTL_CODE(GETGDT32 ,0x0005), - PMHELP_CTL_CODE(MALLOCSHARED ,0x0007), - PMHELP_CTL_CODE(FREESHARED ,0x0008), - PMHELP_CTL_CODE(MAPTOPROCESS ,0x0009), - PMHELP_CTL_CODE(FREEPHYS ,0x000A), - PMHELP_CTL_CODE(FLUSHTLB ,0x000B), - PMHELP_CTL_CODE(SAVECR4 ,0x000C), - PMHELP_CTL_CODE(RESTORECR4 ,0x000D), - PMHELP_CTL_CODE(READMSR ,0x000E), - PMHELP_CTL_CODE(WRITEMSR ,0x000F), - PMHELP_CTL_CODE(GETPHYSICALADDR ,0x0010), - PMHELP_CTL_CODE(GETPHYSICALADDRRANGE ,0x0011), - PMHELP_CTL_CODE(LOCKPAGES ,0x0012), - PMHELP_CTL_CODE(UNLOCKPAGES ,0x0013), - PMHELP_CTL_CODE(GETSHAREDEXP ,0x0042), - PMHELP_CTL_CODE(SETSHAREDEXP ,0x0043), - PMHELP_CTL_CODE(GETSTACKSWITCHRTN ,0x0044), - PMHELP_CTL_CODE(GETBUILDNO ,0x0050), - } PMHELP_ctlCodes; - -#else - -/**************************************************************************** -* Public DOS/Windows Support functions -****************************************************************************/ - -#ifdef DEVICE_MAIN -#include -#define PMHELP_Init_Order (VDD_INIT_ORDER-1) -#define RETURN_LONGS(n) *p->dioc_bytesret = (n) * sizeof(ulong) -#endif /* DEVICE_MAIN */ -#include "scitech.h" -#include "nucleus/graphics.h" - -/* We connect to the SDDHELP.VXD module if it is staticly loaded (as part - * of SciTech Display Doctor), otherwise we dynamically load the PMHELP.VXD - * public helper VxD. - */ - -#define PMHELP_DeviceID 0x0000 -#define SDDHELP_DeviceID 0x3DF8 -#define VXDLDR_DeviceID 0x0027 -#define SDDHELP_MODULE "SDDHELP" -#define SDDHELP_NAME "SDDHELP.VXD" -#define PMHELP_MODULE "PMHELP" -#define PMHELP_NAME "PMHELP.VXD" -#define PMHELP_DDBNAME "pmhelp " -#define SDDHELP_MODULE_PATH "\\\\.\\" SDDHELP_MODULE -#define PMHELP_MODULE_PATH "\\\\.\\" PMHELP_MODULE -#define PMHELP_VXD_PATH "\\\\.\\" PMHELP_NAME - -/* Macro definition for defining IOCTL function control codes for the PMHELP - * device drivers for Windows 9x and NT. This macro is basically derived from - * the CTL_CODE macro in the Windows 2000 DDK, but we hard code it here to - * avoid having to #include any of the Windows 2000 DDK header files. We also - * define both a 16-bit and 32-bit version of the control code within the same - * macro to simplify future additions. - * - * Essentially the Win32 macro would normally expand to the following: - * - * CTL_CODE(FILE_DEVICE_VIDEO,0x800+value,METHOD_BUFFERED,FILE_ANY_ACCESS) - */ - -#define PMHELP_CTL_CODE(name,value) \ - PMHELP_##name = value, \ - PMHELP_##name##32 = ((0x23 << 16) | (0 << 14) | ((0x800+value) << 2) | (0)) - -typedef enum { - /* Include all the control codes. We keep them in a separate header - * file so we can include them in multiple places to make this - * more versatile. - */ - #include "pm_wctl.h" - } PMHELP_ctlCodes; - -/* For real mode VxD calls, we put the function number into the high - * order word of EAX, and a value of 0x4FFF in AX. This allows our - * VxD handler which is set up to handle Int 10's to recognise a native - * PMHELP API call from a real mode DOS program. - */ - -#ifdef REALMODE -#define API_NUM(num) (((ulong)(num) << 16) | 0x4FFF) -#else -#define API_NUM(num) (num) -#endif - -#endif /* !__OS2__ */ - -#endif /* __PMHELP_H */ diff --git a/board/MAI/bios_emulator/scitech/include/pm_wctl.h b/board/MAI/bios_emulator/scitech/include/pm_wctl.h deleted file mode 100644 index 20aa15e534..0000000000 --- a/board/MAI/bios_emulator/scitech/include/pm_wctl.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Win32, OS/2 -* -* Description: Header file to define all the control codes for the DOS -* and Win32 device driver API's for calling from ring 3 -* into the ring 0 device drivers. -* -****************************************************************************/ - -/* Version function used by all drivers */ -PMHELP_CTL_CODE(GETVER ,0x0000), - -/* Functions used by obsolete 16-bit DOS TSR */ -PMHELP_CTL_CODE(RDREGB ,0x0003), -PMHELP_CTL_CODE(WRREGB ,0x0004), -PMHELP_CTL_CODE(RDREGW ,0x0005), -PMHELP_CTL_CODE(WRREGW ,0x0006), -PMHELP_CTL_CODE(RDREGL ,0x0008), -PMHELP_CTL_CODE(WRREGL ,0x0009), - -/* Functions used by obsolete WinDirect */ -PMHELP_CTL_CODE(MAPPHYS ,0x000F), -PMHELP_CTL_CODE(GETVESABUF ,0x0013), - -/* Functions used by PM library */ -PMHELP_CTL_CODE(DPMIINT86 ,0x0014), -PMHELP_CTL_CODE(INT86 ,0x0015), -PMHELP_CTL_CODE(INT86X ,0x0016), -PMHELP_CTL_CODE(CALLREALMODE ,0x0017), -PMHELP_CTL_CODE(ALLOCLOCKED ,0x0018), -PMHELP_CTL_CODE(FREELOCKED ,0x0019), -PMHELP_CTL_CODE(ENABLELFBCOMB ,0x001A), -PMHELP_CTL_CODE(GETPHYSICALADDR ,0x001B), -PMHELP_CTL_CODE(MALLOCSHARED ,0x001D), -PMHELP_CTL_CODE(FREESHARED ,0x001F), -PMHELP_CTL_CODE(LOCKDATAPAGES ,0x0020), -PMHELP_CTL_CODE(UNLOCKDATAPAGES ,0x0021), -PMHELP_CTL_CODE(LOCKCODEPAGES ,0x0022), -PMHELP_CTL_CODE(UNLOCKCODEPAGES ,0x0023), -PMHELP_CTL_CODE(GETCALLGATE ,0x0024), -PMHELP_CTL_CODE(SETCNTPATH ,0x0025), -PMHELP_CTL_CODE(GETPDB ,0x0026), -PMHELP_CTL_CODE(FLUSHTLB ,0x0027), -PMHELP_CTL_CODE(GETPHYSICALADDRRANGE ,0x0028), -PMHELP_CTL_CODE(ALLOCPAGE ,0x0029), -PMHELP_CTL_CODE(FREEPAGE ,0x002A), -PMHELP_CTL_CODE(ENABLERING3IOPL ,0x002B), -PMHELP_CTL_CODE(DISABLERING3IOPL ,0x002C), -PMHELP_CTL_CODE(GASETLOCALPATH ,0x002D), -PMHELP_CTL_CODE(GAGETEXPORTS ,0x002E), -PMHELP_CTL_CODE(GATHUNK ,0x002F), -PMHELP_CTL_CODE(SETNUCLEUSPATH ,0x0030), diff --git a/board/MAI/bios_emulator/scitech/include/pmapi.h b/board/MAI/bios_emulator/scitech/include/pmapi.h deleted file mode 100644 index 7ddace7080..0000000000 --- a/board/MAI/bios_emulator/scitech/include/pmapi.h +++ /dev/null @@ -1,1148 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Header file for the OS Portability Manager Library, which -* contains functions to implement OS specific services in a -* generic, cross platform API. Porting the OS Portability -* Manager library is the first step to porting any SciTech -* products to a new platform. -* -****************************************************************************/ - -#ifndef __PMAPI_H -#define __PMAPI_H - -#include "scitech.h" -#include "pcilib.h" -#include "ztimerc.h" -#if !defined(__WIN32_VXD__) && !defined(__OS2_VDD__) && !defined(__NT_DRIVER__) -#include -#include -#endif - -/*--------------------------- Macros and Typedefs -------------------------*/ - -/* You will need to define one of the following before you compile this - * library for it to work correctly with the DOS extender that you are - * using when compiling for extended DOS: - * - * TNT - Phar Lap TNT DOS Extender - * DOS4GW - Rational DOS/4GW, DOS/4GW Pro, Causeway and PMODE/W - * DJGPP - DJGPP port of GNU C++ - * - * If none is specified, we will automatically determine which operating - * system is being targetted and the following will be defined (provided by - * scitech.h header file): - * - * __MSDOS16__ - Default for 16 bit MSDOS mode - * __MSDOS32__ - Default for 32 bit MSDOS - * __WINDOWS16__ - Default for 16 bit Windows - * __WINDOWS32__ - Default for 32 bit Windows - * - * One of the following will be defined automatically for you to select - * which memory model is in effect: - * - * REALMODE - 16 bit real mode (large memory model) - * PM286 - 16 protected mode (large memory model) - * PM386 - 32 protected mode (flat memory model) - */ - -#if defined(__UNIX__) && !defined(_MAX_PATH) -#define _MAX_PATH 256 -#endif - -#if defined(TNT) || defined(DOSX) || defined(X32VM) || defined(DPMI32) \ - || defined(DOS4GW) || defined(DJGPP) || defined(__WINDOWS32__) \ - || defined(__MSDOS32__) || defined(__UNIX__) || defined(__WIN32_VXD__) \ - || defined(__32BIT__) || defined(__SMX32__) || defined(__RTTARGET__) -#define PM386 -#elif defined(DPMI16) || defined(__WINDOWS16__) -#define PM286 -#else -#define REALMODE -#endif - -#pragma pack(1) - -/* Provide the typedefs for the PM_int386 functions, which issue native - * interrupts in real or protected mode and can pass extended registers - * around. - */ - -struct _PMDWORDREGS { - ulong eax,ebx,ecx,edx,esi,edi,cflag; - }; - -struct _PMWORDREGS { - ushort ax,ax_hi; - ushort bx,bx_hi; - ushort cx,cx_hi; - ushort dx,dx_hi; - ushort si,si_hi; - ushort di,di_hi; - ushort cflag,cflag_hi; - }; - -struct _PMBYTEREGS { - uchar al, ah; ushort ax_hi; - uchar bl, bh; ushort bx_hi; - uchar cl, ch; ushort cx_hi; - uchar dl, dh; ushort dx_hi; - }; - -typedef union { - struct _PMDWORDREGS e; - struct _PMWORDREGS x; - struct _PMBYTEREGS h; - } PMREGS; - -typedef struct { - ushort es; - ushort cs; - ushort ss; - ushort ds; - ushort fs; - ushort gs; - } PMSREGS; - -/* Provide definitions for the real mode register structures passed to - * the PM_int86() and PM_int86x() routines. Note that we provide our own - * functions to do this for 16-bit code that calls the PM_int386 functions. - */ - -typedef PMREGS RMREGS; -typedef PMSREGS RMSREGS; - -typedef struct { - long edi; - long esi; - long ebp; - long reserved; - long ebx; - long edx; - long ecx; - long eax; - short flags; - short es,ds,fs,gs,ip,cs,sp,ss; - } DPMI_regs; - -#ifdef __MSDOS__ -/* Register structure passed to PM_VxDCall function */ -typedef struct { - ulong eax; - ulong ebx; - ulong ecx; - ulong edx; - ulong esi; - ulong edi; - ushort ds,es; - } VXD_regs; -#endif - -#define PM_MAX_DRIVE 3 -#define PM_MAX_PATH 256 -#define PM_FILE_INVALID (void*)0xFFFFFFFF - -/* Structure for generic directory traversal and management. Also the same - * values are passed to PM_setFileAttr to change the file attributes. - */ - -typedef struct { - ulong dwSize; - ulong attrib; - ulong sizeLo; - ulong sizeHi; - char name[PM_MAX_PATH]; - } PM_findData; - -/* Macro to compute the byte offset of a field in a structure of type type */ - -#define PM_FIELD_OFFSET(type,field) ((long)&(((type*)0)->field)) - -/* Marcto to compute the address of the base of the structure given its type, - * and an address of a field within the structure. - */ - -#define PM_CONTAINING_RECORD(address, type, field) \ - ((type*)( \ - (char*)(address) - \ - (char*)(&((type*)0)->field))) - -/* Flags stored in the PM_findData structure, and also values passed to - * PM_setFileAttr to change the file attributes. - */ - -#define PM_FILE_NORMAL 0x00000000 -#define PM_FILE_READONLY 0x00000001 -#define PM_FILE_DIRECTORY 0x00000002 -#define PM_FILE_ARCHIVE 0x00000004 -#define PM_FILE_HIDDEN 0x00000008 -#define PM_FILE_SYSTEM 0x00000010 - -/* Flags returned by the PM_splitpath function */ - -#define PM_HAS_WILDCARDS 0x01 -#define PM_HAS_EXTENSION 0x02 -#define PM_HAS_FILENAME 0x04 -#define PM_HAS_DIRECTORY 0x08 -#define PM_HAS_DRIVE 0x10 - -/* Structure passed to the PM_setFileTime functions */ -typedef struct { - short sec; /* Seconds */ - short min; /* Minutes */ - short hour; /* Hour (0--23) */ - short day; /* Day of month (1--31) */ - short mon; /* Month (0--11) */ - short year; /* Year (calendar year minus 1900) */ - } PM_time; - -/* Define a macro for creating physical base addresses from segment:offset */ - -#define MK_PHYS(s,o) (((ulong)(s) << 4) + (ulong)(o)) - -/* Define the different types of modes supported. This is a global variable - * that can be used to determine the type at runtime which will contain - * one of these values. - */ - -typedef enum { - PM_realMode, - PM_286, - PM_386 - } PM_mode_enum; - -/* Define types passed to PM_enableWriteCombine */ - -#define PM_MTRR_UNCACHABLE 0 -#define PM_MTRR_WRCOMB 1 -#define PM_MTRR_WRTHROUGH 4 -#define PM_MTRR_WRPROT 5 -#define PM_MTRR_WRBACK 6 -#define PM_MTRR_MAX 6 - -/* Error codes returned by PM_enableWriteCombine */ - -#define PM_MTRR_ERR_OK 0 -#define PM_MTRR_NOT_SUPPORTED -1 -#define PM_MTRR_ERR_PARAMS -2 -#define PM_MTRR_ERR_NOT_4KB_ALIGNED -3 -#define PM_MTRR_ERR_BELOW_1MB -4 -#define PM_MTRR_ERR_NOT_ALIGNED -5 -#define PM_MTRR_ERR_OVERLAP -6 -#define PM_MTRR_ERR_TYPE_MISMATCH -7 -#define PM_MTRR_ERR_NONE_FREE -8 -#define PM_MTRR_ERR_NOWRCOMB -9 -#define PM_MTRR_ERR_NO_OS_SUPPORT -10 - -/* Values passed to the PM_DMACProgram function */ - -#define PM_DMA_READ_ONESHOT 0x44 /* One-shot DMA read */ -#define PM_DMA_WRITE_ONESHOT 0x48 /* One-shot DMA write */ -#define PM_DMA_READ_AUTOINIT 0x54 /* Auto-init DMA read */ -#define PM_DMA_WRITE_AUTOINIT 0x58 /* Auto-init DMA write */ - -/* Flags passed to suspend application callback */ - -#define PM_DEACTIVATE 1 -#define PM_REACTIVATE 2 - -/* Return codes that the application can return from the suspend application - * callback registered with the PM library. See the MGL documentation for - * more details. - */ -#define PM_SUSPEND_APP 0 -#define PM_NO_SUSPEND_APP 1 - -/**************************************************************************** -REMARKS: -This enumeration defines the type values passed to the PM_agpReservePhysical -function, to define how the physical memory mapping should be handled. - -The PM_agpUncached type indicates that the memory should be allocated as -uncached memory. - -The PM_agpWriteCombine type indicates that write combining should be enabled -for physical memory mapping. This is used for framebuffer write combing and -speeds up direct framebuffer writes to the memory. - -The PM_agpIntelDCACHE type indicates that memory should come from the Intel -i81x Display Cache (or DCACHE) memory pool. This flag is specific to the -Intel i810 and i815 controllers, and should not be passed for any other -controller type. - -HEADER: -pmapi.h - -MEMBERS: -PM_agpUncached - Indicates that the memory should be uncached -PM_agpWriteCombine - Indicates that the memory should be write combined -PM_agpIntelDCACHE - Indicates that the memory should come from DCACHE pool -****************************************************************************/ -typedef enum { - PM_agpUncached, - PM_agpWriteCombine, - PM_agpIntelDCACHE - } PM_agpMemoryType; - -/* Defines the size of an system memory page */ - -#define PM_PAGE_SIZE 4096 - -/* Type definition for a physical memory address */ - -typedef unsigned long PM_physAddr; - -/* Define a bad physical address returned by map physical functions */ - -#define PM_BAD_PHYS_ADDRESS 0xFFFFFFFF - -/* Type definition for the 12-byte lock handle for locking linear memory */ - -typedef struct { - ulong h[3]; - } PM_lockHandle; - -/* 'C' calling conventions always */ - -#define PMAPI _ASMAPI -#define PMAPIP _ASMAPIP - -/* Internal typedef to override DPMI_int86 handler */ - -typedef ibool (PMAPIP DPMI_handler_t)(DPMI_regs *regs); -void PMAPI DPMI_setInt10Handler(DPMI_handler_t handler); - -/* Type definitions for a window handle for console modes */ - -#if defined(__DRIVER__) || defined(__WIN32_VXD__) || defined(__NT_DRIVER__) -typedef void *PM_HWND; /* Pointer for portable drivers */ -typedef void *PM_MODULE; /* Module handle for portable drivers */ -#elif defined(__WINDOWS__) -#ifdef DECLARE_HANDLE -typedef HWND PM_HWND; /* Real window handle */ -typedef HINSTANCE PM_MODULE; /* Win32 DLL handle */ -#else -typedef void *PM_HWND; /* Place holder if windows.h not included */ -typedef void *PM_MODULE; /* Place holder if windows.h not included */ -#endif -#elif defined(__USE_X11__) -typedef struct { - Window *window; - Display *display; - } PM_HWND; /* X11 window handle */ -#elif defined(__OS2__) -typedef void *PM_HWND; -typedef void *PM_MODULE; -#elif defined(__LINUX__) -typedef int PM_HWND; /* Console id for fullscreen Linux */ -typedef void *PM_MODULE; -#elif defined(__QNX__) -typedef int PM_HWND; /* Console id for fullscreen QNX */ -typedef void *PM_MODULE; -#elif defined(__RTTARGET__) -typedef int PM_HWND; /* Placeholder for RTTarget-32 */ -typedef void *PM_MODULE; -#elif defined(__REALDOS__) -typedef int PM_HWND; /* Placeholder for fullscreen DOS */ -typedef void *PM_MODULE; /* Placeholder for fullscreen DOS */ -#elif defined(__SMX32__) -typedef int PM_HWND; /* Placeholder for fullscreen SMX */ -typedef void *PM_MODULE; -#elif defined(__SNAP__) -typedef void *PM_HWND; -typedef void *PM_MODULE; -#else -#error PM library not ported to this platform yet! -#endif - -/* Type definition for code pointers */ - -typedef void (*__codePtr)(); - -/* Type definition for a C based interrupt handler */ - -typedef void (PMAPIP PM_intHandler)(void); -typedef ibool (PMAPIP PM_irqHandler)(void); - -/* Hardware IRQ handle used to save and restore the hardware IRQ */ - -typedef void *PM_IRQHandle; - -/* Type definition for the fatal cleanup handler */ - -typedef void (PMAPIP PM_fatalCleanupHandler)(void); - -/* Type defifinition for save state callback function */ - -typedef int (PMAPIP PM_saveState_cb)(int flags); - -/* Type definintion for enum write combined callback function */ - -typedef void (PMAPIP PM_enumWriteCombine_t)(ulong base,ulong length,uint type); - -/* Structure defining all the PM API functions as exported to - * the binary portable DLL's. - */ - -typedef struct { - ulong dwSize; - int (PMAPIP PM_getModeType)(void); - void * (PMAPIP PM_getBIOSPointer)(void); - void * (PMAPIP PM_getA0000Pointer)(void); - void * (PMAPIP PM_mapPhysicalAddr)(ulong base,ulong limit,ibool isCached); - void * (PMAPIP PM_mallocShared)(long size); - void * reserved1; - void (PMAPIP PM_freeShared)(void *ptr); - void * (PMAPIP PM_mapToProcess)(void *linear,ulong limit); - void * (PMAPIP PM_mapRealPointer)(uint r_seg,uint r_off); - void * (PMAPIP PM_allocRealSeg)(uint size,uint *r_seg,uint *r_off); - void (PMAPIP PM_freeRealSeg)(void *mem); - void * (PMAPIP PM_allocLockedMem)(uint size,ulong *physAddr,ibool contiguous,ibool below16Meg); - void (PMAPIP PM_freeLockedMem)(void *p,uint size,ibool contiguous); - void (PMAPIP PM_callRealMode)(uint seg,uint off, RMREGS *regs,RMSREGS *sregs); - int (PMAPIP PM_int86)(int intno, RMREGS *in, RMREGS *out); - int (PMAPIP PM_int86x)(int intno, RMREGS *in, RMREGS *out,RMSREGS *sregs); - void (PMAPIP DPMI_int86)(int intno, DPMI_regs *regs); - void (PMAPIP PM_availableMemory)(ulong *physical,ulong *total); - void * (PMAPIP PM_getVESABuf)(uint *len,uint *rseg,uint *roff); - long (PMAPIP PM_getOSType)(void); - void (PMAPIP PM_fatalError)(const char *msg); - void (PMAPIP PM_setBankA)(int bank); - void (PMAPIP PM_setBankAB)(int bank); - void (PMAPIP PM_setCRTStart)(int x,int y,int waitVRT); - char * (PMAPIP PM_getCurrentPath)(char *path,int maxLen); - const char * (PMAPIP PM_getVBEAFPath)(void); - const char * (PMAPIP PM_getNucleusPath)(void); - const char * (PMAPIP PM_getNucleusConfigPath)(void); - const char * (PMAPIP PM_getUniqueID)(void); - const char * (PMAPIP PM_getMachineName)(void); - ibool (PMAPIP VF_available)(void); - void * (PMAPIP VF_init)(ulong baseAddr,int bankSize,int codeLen,void *bankFunc); - void (PMAPIP VF_exit)(void); - PM_HWND (PMAPIP PM_openConsole)(PM_HWND hwndUser,int device,int xRes,int yRes,int bpp,ibool fullScreen); - int (PMAPIP PM_getConsoleStateSize)(void); - void (PMAPIP PM_saveConsoleState)(void *stateBuf,PM_HWND hwndConsole); - void (PMAPIP PM_restoreConsoleState)(const void *stateBuf,PM_HWND hwndConsole); - void (PMAPIP PM_closeConsole)(PM_HWND hwndConsole); - void (PMAPIP PM_setOSCursorLocation)(int x,int y); - void (PMAPIP PM_setOSScreenWidth)(int width,int height); - int (PMAPIP PM_enableWriteCombine)(ulong base,ulong length,uint type); - void (PMAPIP PM_backslash)(char *filename); - int (PMAPIP PM_lockDataPages)(void *p,uint len,PM_lockHandle *lockHandle); - int (PMAPIP PM_unlockDataPages)(void *p,uint len,PM_lockHandle *lockHandle); - int (PMAPIP PM_lockCodePages)(__codePtr p,uint len,PM_lockHandle *lockHandle); - int (PMAPIP PM_unlockCodePages)(__codePtr p,uint len,PM_lockHandle *lockHandle); - ibool (PMAPIP PM_setRealTimeClockHandler)(PM_intHandler ih,int frequency); - void (PMAPIP PM_setRealTimeClockFrequency)(int frequency); - void (PMAPIP PM_restoreRealTimeClockHandler)(void); - ibool (PMAPIP PM_doBIOSPOST)(ushort axVal,ulong BIOSPhysAddr,void *BIOSPtr,ulong BIOSLen); - char (PMAPIP PM_getBootDrive)(void); - void (PMAPIP PM_freePhysicalAddr)(void *ptr,ulong limit); - uchar (PMAPIP PM_inpb)(int port); - ushort (PMAPIP PM_inpw)(int port); - ulong (PMAPIP PM_inpd)(int port); - void (PMAPIP PM_outpb)(int port,uchar val); - void (PMAPIP PM_outpw)(int port,ushort val); - void (PMAPIP PM_outpd)(int port,ulong val); - void * reserved2; - void (PMAPIP PM_setSuspendAppCallback)(PM_saveState_cb saveState); - ibool (PMAPIP PM_haveBIOSAccess)(void); - int (PMAPIP PM_kbhit)(void); - int (PMAPIP PM_getch)(void); - ibool (PMAPIP PM_findBPD)(const char *dllname,char *bpdpath); - ulong (PMAPIP PM_getPhysicalAddr)(void *p); - void (PMAPIP PM_sleep)(ulong milliseconds); - int (PMAPIP PM_getCOMPort)(int port); - int (PMAPIP PM_getLPTPort)(int port); - PM_MODULE (PMAPIP PM_loadLibrary)(const char *szDLLName); - void * (PMAPIP PM_getProcAddress)(PM_MODULE hModule,const char *szProcName); - void (PMAPIP PM_freeLibrary)(PM_MODULE hModule); - int (PMAPIP PCI_enumerate)(PCIDeviceInfo info[]); - ulong (PMAPIP PCI_accessReg)(int index,ulong value,int func,PCIDeviceInfo *info); - ibool (PMAPIP PCI_setHardwareIRQ)(PCIDeviceInfo *info,uint intPin,uint IRQ); - void (PMAPIP PCI_generateSpecialCyle)(uint bus,ulong specialCycleData); - void * reserved3; - ulong (PMAPIP PCIBIOS_getEntry)(void); - uint (PMAPIP CPU_getProcessorType)(void); - ibool (PMAPIP CPU_haveMMX)(void); - ibool (PMAPIP CPU_have3DNow)(void); - ibool (PMAPIP CPU_haveSSE)(void); - ibool (PMAPIP CPU_haveRDTSC)(void); - ulong (PMAPIP CPU_getProcessorSpeed)(ibool accurate); - void (PMAPIP ZTimerInit)(void); - void (PMAPIP LZTimerOn)(void); - ulong (PMAPIP LZTimerLap)(void); - void (PMAPIP LZTimerOff)(void); - ulong (PMAPIP LZTimerCount)(void); - void (PMAPIP LZTimerOnExt)(LZTimerObject *tm); - ulong (PMAPIP LZTimerLapExt)(LZTimerObject *tm); - void (PMAPIP LZTimerOffExt)(LZTimerObject *tm); - ulong (PMAPIP LZTimerCountExt)(LZTimerObject *tm); - void (PMAPIP ULZTimerOn)(void); - ulong (PMAPIP ULZTimerLap)(void); - void (PMAPIP ULZTimerOff)(void); - ulong (PMAPIP ULZTimerCount)(void); - ulong (PMAPIP ULZReadTime)(void); - ulong (PMAPIP ULZElapsedTime)(ulong start,ulong finish); - void (PMAPIP ULZTimerResolution)(ulong *resolution); - void * (PMAPIP PM_findFirstFile)(const char *filename,PM_findData *findData); - ibool (PMAPIP PM_findNextFile)(void *handle,PM_findData *findData); - void (PMAPIP PM_findClose)(void *handle); - void (PMAPIP PM_makepath)(char *p,const char *drive,const char *dir,const char *name,const char *ext); - int (PMAPIP PM_splitpath)(const char *fn,char *drive,char *dir,char *name,char *ext); - ibool (PMAPIP PM_driveValid)(char drive); - void (PMAPIP PM_getdcwd)(int drive,char *dir,int len); - void (PMAPIP PM_setFileAttr)(const char *filename,uint attrib); - ibool (PMAPIP PM_mkdir)(const char *filename); - ibool (PMAPIP PM_rmdir)(const char *filename); - uint (PMAPIP PM_getFileAttr)(const char *filename); - ibool (PMAPIP PM_getFileTime)(const char *filename,ibool gmtTime,PM_time *time); - ibool (PMAPIP PM_setFileTime)(const char *filename,ibool gmtTime,PM_time *time); - char * (PMAPIP CPU_getProcessorName)(void); - int (PMAPIP PM_getVGAStateSize)(void); - void (PMAPIP PM_saveVGAState)(void *stateBuf); - void (PMAPIP PM_restoreVGAState)(const void *stateBuf); - void (PMAPIP PM_vgaBlankDisplay)(void); - void (PMAPIP PM_vgaUnblankDisplay)(void); - void (PMAPIP PM_blockUntilTimeout)(ulong milliseconds); - void (PMAPIP _PM_add64)(u32 a_low,s32 a_high,u32 b_low,s32 b_high,__i64 *result); - void (PMAPIP _PM_sub64)(u32 a_low,s32 a_high,u32 b_low,s32 b_high,__i64 *result); - void (PMAPIP _PM_mul64)(u32 a_low,s32 a_high,u32 b_low,s32 b_high,__i64 *result); - void (PMAPIP _PM_div64)(u32 a_low,s32 a_high,u32 b_low,s32 b_high,__i64 *result); - void (PMAPIP _PM_shr64)(u32 a_low,s32 a_high,s32 shift,__i64 *result); - void (PMAPIP _PM_sar64)(u32 a_low,s32 a_high,s32 shift,__i64 *result); - void (PMAPIP _PM_shl64)(u32 a_low,s32 a_high,s32 shift,__i64 *result); - void (PMAPIP _PM_neg64)(u32 a_low,s32 a_high,__i64 *result); - ulong (PMAPIP PCI_findBARSize)(int bar,PCIDeviceInfo *pci); - void (PMAPIP PCI_readRegBlock)(PCIDeviceInfo *info,int index,void *dst,int count); - void (PMAPIP PCI_writeRegBlock)(PCIDeviceInfo *info,int index,void *src,int count); - void (PMAPIP PM_flushTLB)(void); - void (PMAPIP PM_useLocalMalloc)(void * (*malloc)(size_t size),void * (*calloc)(size_t nelem,size_t size),void * (*realloc)(void *ptr,size_t size),void (*free)(void *p)); - void * (PMAPIP PM_malloc)(size_t size); - void * (PMAPIP PM_calloc)(size_t nelem,size_t size); - void * (PMAPIP PM_realloc)(void *ptr,size_t size); - void (PMAPIP PM_free)(void *p); - ibool (PMAPIP PM_getPhysicalAddrRange)(void *p,ulong length,ulong *physAddress); - void * (PMAPIP PM_allocPage)(ibool locked); - void (PMAPIP PM_freePage)(void *p); - ulong (PMAPIP PM_agpInit)(void); - void (PMAPIP PM_agpExit)(void); - ibool (PMAPIP PM_agpReservePhysical)(ulong numPages,int type,void **physContext,PM_physAddr *physAddr); - ibool (PMAPIP PM_agpReleasePhysical)(void *physContext); - ibool (PMAPIP PM_agpCommitPhysical)(void *physContext,ulong numPages,ulong startOffset,PM_physAddr *physAddr); - ibool (PMAPIP PM_agpFreePhysical)(void *physContext,ulong numPages,ulong startOffset); - int (PMAPIP PCI_getNumDevices)(void); - void (PMAPIP PM_setLocalBPDPath)(const char *path); - void * (PMAPIP PM_loadDirectDraw)(int device); - void (PMAPIP PM_unloadDirectDraw)(int device); - PM_HWND (PMAPIP PM_getDirectDrawWindow)(void); - void (PMAPIP PM_doSuspendApp)(void); - } PM_imports; - -#pragma pack() - -/*---------------------------- Global variables ---------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -#ifdef __WIN32_VXD__ -#define VESA_BUF_SIZE 1024 -extern uchar *_PM_rmBufAddr; -#endif - -/* {secret} Pointer to global exports structure. - * Should not be used by application programs. - */ -extern PM_imports _VARAPI _PM_imports; - -/* {secret} */ -extern void * (*__PM_malloc)(size_t size); -/* {secret} */ -extern void * (*__PM_calloc)(size_t nelem,size_t size); -/* {secret} */ -extern void * (*__PM_realloc)(void *ptr,size_t size); -/* {secret} */ -extern void (*__PM_free)(void *p); - -/*--------------------------- Function Prototypes -------------------------*/ - -/* Routine to initialise the host side PM library. Note used from DLL's */ - -void PMAPI PM_init(void); - -/* Routine to return either PM_realMode, PM_286 or PM_386 */ - -int PMAPI PM_getModeType(void); - -/* Routine to return a selector to the BIOS data area at segment 0x40 */ - -void * PMAPI PM_getBIOSPointer(void); - -/* Routine to return a linear pointer to the VGA frame buffer memory */ - -void * PMAPI PM_getA0000Pointer(void); - -/* Routines to map/free physical memory into the current DS segment. In - * some environments (32-bit DOS is one), after the mapping has been - * allocated, it cannot be freed. Hence you should only allocate the - * mapping once and cache the value for use by other parts of your - * application. If the mapping cannot be createed, this function will - * return a NULL pointer. - * - * This routine will also work for memory addresses below 1Mb, but the - * mapped address cannot cross the 1Mb boundary. - */ - -void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached); -void PMAPI PM_freePhysicalAddr(void *ptr,ulong limit); - -/* Routine to determine the physical address of a linear address. It is - * up to the caller to ensure the entire address range for a linear - * block of memory is page aligned if that is required. - */ - -ulong PMAPI PM_getPhysicalAddr(void *p); -ibool PMAPI PM_getPhysicalAddrRange(void *p,ulong length,ulong *physAddress); - -/* Routines for memory allocation. By default these functions use the regular - * C runtime library malloc/free functions, but you can use the - * PM_useLocalMalloc function to override the default memory allocator with - * your own memory allocator. This will ensure that all memory allocation - * used by SciTech products will use your overridden memory allocator - * functions. - * - * Note that BPD files automatically map the C runtime library - * malloc/calloc/realloc/free calls from inside the BPD to the PM library - * versions by default. - */ - -void PMAPI PM_useLocalMalloc(void * (*malloc)(size_t size),void * (*calloc)(size_t nelem,size_t size),void * (*realloc)(void *ptr,size_t size),void (*free)(void *p)); -void * PMAPI PM_malloc(size_t size); -void * PMAPI PM_calloc(size_t nelem,size_t size); -void * PMAPI PM_realloc(void *ptr,size_t size); -void PMAPI PM_free(void *p); - -/* Routine to allocate a memory block in the global shared region that - * is common to all tasks and accessible from ring 0 code. - */ - -void * PMAPI PM_mallocShared(long size); - -/* Routine to free the allocated shared memory block */ - -void PMAPI PM_freeShared(void *ptr); - -/* Attach a previously allocated linear mapping to a new process */ - -void * PMAPI PM_mapToProcess(void *linear,ulong limit); - -/* Macros to extract byte, word and long values from a char pointer */ - -#define PM_getByte(p) *((volatile uchar*)(p)) -#define PM_getWord(p) *((volatile ushort*)(p)) -#define PM_getLong(p) *((volatile ulong*)(p)) -#define PM_setByte(p,v) PM_getByte(p) = (v) -#define PM_setWord(p,v) PM_getWord(p) = (v) -#define PM_setLong(p,v) PM_getLong(p) = (v) - -/* Routine for accessing a low 1Mb memory block. You dont need to free this - * pointer, but in 16 bit protected mode the selector allocated will be - * re-used the next time this routine is called. - */ - -void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off); - -/* Routine to allocate a block of conventional memory below the 1Mb - * limit so that it can be accessed from real mode. Ensure that you free - * the segment when you are done with it. - * - * This routine returns a selector and offset to the segment that has been - * allocated, and also returns the real mode segment and offset which can - * be passed to real mode routines. Will return 0 if memory could not be - * allocated. - * - * Please note that with some DOS extenders, memory allocated with the - * following function cannot be freed, hence it will be allocated for the - * life of your program. Thus if you need to call a bunch of different - * real-mode routines in your program, allocate a single large buffer at - * program startup that can be re-used throughout the program execution. - */ - -void * PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off); -void PMAPI PM_freeRealSeg(void *mem); - -/* Routine to allocate a block of locked memory, and return both the - * linear and physical addresses of the memory. You should always - * allocate locked memory blocks in page sized chunks (ie: 4K on IA32). - * If the memory is not contiguous, you will need to use the - * PM_getPhysicalAddr function to get the physical address of linear - * pages within the memory block (the returned physical address will be - * for the first address in the memory block only). - */ - -void * PMAPI PM_allocLockedMem(uint size,ulong *physAddr,ibool contiguous,ibool below16Meg); -void PMAPI PM_freeLockedMem(void *p,uint size,ibool contiguous); - -/* Routine to allocate and free paged sized blocks of shared memory. - * Addressable from all processes, but not from a ring 0 context - * under OS/2. Note that under OS/2 PM_mapSharedPages must be called - * to map the memory blocks into the shared memory address space - * of each connecting process. - */ - -void * PMAPI PM_allocPage(ibool locked); -void PMAPI PM_freePage(void *p); -#ifdef __OS2__ -void PMAPI PM_mapSharedPages(void); -#endif - -/* Routine to return true if we have access to the BIOS on the host OS */ - -ibool PMAPI PM_haveBIOSAccess(void); - -/* Routine to call a real mode assembly language procedure. Register - * values are passed in and out in the 'regs' and 'sregs' structures. We - * do not provide any method of copying data from the protected mode stack - * to the real mode stack, so if you need to pass data to real mode, you will - * need to write a real mode assembly language hook to recieve the values - * in registers, and to pass the data through a real mode block allocated - * with the PM_allocRealSeg() routine. - */ - -void PMAPI PM_callRealMode(uint seg,uint off, RMREGS *regs,RMSREGS *sregs); - -/* Routines to generate real mode interrupts using the same interface that - * is used by int86() and int86x() in realmode. This routine is need to - * call certain BIOS and DOS functions that are not supported by some - * DOS extenders. No translation is done on any of the register values, - * so they must be correctly set up and translated by the calling program. - * - * Normally the DOS extenders will allow you to use the normal int86() - * function directly and will pass on unhandled calls to real mode to be - * handled by the real mode handler. However calls to int86x() with real - * mode segment values to be loaded will cause a GPF if used with the - * standard int86x(), so you should use these routines if you know you - * want to call a real mode handler. - */ - -int PMAPI PM_int86(int intno, RMREGS *in, RMREGS *out); -int PMAPI PM_int86x(int intno, RMREGS *in, RMREGS *out,RMSREGS *sregs); - -/* Routine to generate a real mode interrupt. This is identical to the - * above function, but takes a DPMI_regs structure for the registers - * which has a lot more information. It is only available from 32-bit - * protected mode. - */ - -void PMAPI DPMI_int86(int intno, DPMI_regs *regs); - -/* Function to return the amount of available physical and total memory. - * The results of this function are *only* valid before you have made any - * calls to malloc() and free(). If you need to keep track of exactly how - * much memory is currently allocated, you need to call this function to - * get the total amount of memory available and then keep track of - * the available memory every time you call malloc() and free(). - */ - -void PMAPI PM_availableMemory(ulong *physical,ulong *total); - -/* Return the address of a global VESA real mode transfer buffer for use - * by applications. - */ - -void * PMAPI PM_getVESABuf(uint *len,uint *rseg,uint *roff); - -/* Handle fatal error conditions */ - -void PMAPI PM_fatalError(const char *msg); - -/* Function to set a cleanup error handler called when PM_fatalError - * is called. This allows us to the console back into a normal state - * if we get a failure from deep inside a BPD file. This function is - * not exported to BPD files, and is only used by code compiled for the - * OS. - */ - -void PMAPI PM_setFatalErrorCleanup(PM_fatalCleanupHandler cleanup); - -/* Return the OS type flag as defined in */ - -long PMAPI PM_getOSType(void); - -/* Functions to set a VBE bank via an Int 10h */ - -void PMAPI PM_setBankA(int bank); -void PMAPI PM_setBankAB(int bank); -void PMAPI PM_setCRTStart(int x,int y,int waitVRT); - -/* Return the current working directory */ - -char * PMAPI PM_getCurrentPath(char *path,int maxLen); - -/* Return paths to the VBE/AF and Nucleus directories */ - -const char * PMAPI PM_getVBEAFPath(void); -const char * PMAPI PM_getNucleusPath(void); -const char * PMAPI PM_getNucleusConfigPath(void); - -/* Find the path to a binary portable DLL */ - -void PMAPI PM_setLocalBPDPath(const char *path); -ibool PMAPI PM_findBPD(const char *dllname,char *bpdpath); - -/* Returns the drive letter of the boot drive for DOS, OS/2 and Windows */ - -char PMAPI PM_getBootDrive(void); - -/* Return a network unique machine identifier as a string */ - -const char * PMAPI PM_getUniqueID(void); - -/* Return the network machine name as a string */ - -const char * PMAPI PM_getMachineName(void); - -/* Functions to install and remove the virtual linear framebuffer - * emulation code. For unsupported DOS extenders and when running under - * a DPMI host like Windows or OS/2, this function will return a NULL. - */ - -ibool PMAPI VF_available(void); -void * PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc); -void PMAPI VF_exit(void); - -/* Functions to wait for a keypress and read a key for command line - * environments such as DOS, Win32 console and Unix. - */ - -int PMAPI PM_kbhit(void); -int PMAPI PM_getch(void); - -/* Functions to create either a fullscreen or windowed console on the - * desktop, and to allow the resolution of fullscreen consoles to be - * changed on the fly without closing the console. For non-windowed - * environments (such as a Linux or OS/2 fullscreen console), these - * functions enable console graphics mode and restore console text mode. - * - * The suspend application callback is used to allow the application to - * save the state of the fullscreen console mode to allow temporary - * switching to another console or back to the regular GUI desktop. It - * is also called to restore the fullscreen graphics state after the - * fullscreen console regains the focus. - * - * The device parameter allows for the console to be opened on a different - * display controllers (0 is always the primary controller). - */ - -PM_HWND PMAPI PM_openConsole(PM_HWND hwndUser,int device,int xRes,int yRes,int bpp,ibool fullScreen); -int PMAPI PM_getConsoleStateSize(void); -void PMAPI PM_saveConsoleState(void *stateBuf,PM_HWND hwndConsole); -void PMAPI PM_setSuspendAppCallback(PM_saveState_cb saveState); -void PMAPI PM_restoreConsoleState(const void *stateBuf,PM_HWND hwndConsole); -void PMAPI PM_closeConsole(PM_HWND hwndConsole); - -/* Functions to modify OS console information */ - -void PMAPI PM_setOSCursorLocation(int x,int y); -void PMAPI PM_setOSScreenWidth(int width,int height); - -/* Function to emable Intel PPro/PII write combining */ - -int PMAPI PM_enableWriteCombine(ulong base,ulong length,uint type); -int PMAPI PM_enumWriteCombine(PM_enumWriteCombine_t callback); - -/* Function to add a path separator to the end of a filename (if not present) */ - -void PMAPI PM_backslash(char *filename); - -/* Routines to lock and unlock regions of memory under a virtual memory - * environment. These routines _must_ be used to lock all hardware - * and mouse interrupt handlers installed, _AND_ any global data that - * these handler manipulate, so that they will always be present in memory - * to handle the incoming interrupts. - * - * Note that it is important to call the correct routine depending on - * whether the area being locked is code or data, so that under 32 bit - * PM we will get the selector value correct. - */ - -int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lockHandle); -int PMAPI PM_unlockDataPages(void *p,uint len,PM_lockHandle *lockHandle); -int PMAPI PM_lockCodePages(__codePtr p,uint len,PM_lockHandle *lockHandle); -int PMAPI PM_unlockCodePages(__codePtr p,uint len,PM_lockHandle *lockHandle); - -/* Routines to install and remove Real Time Clock interrupt handlers. The - * frequency of the real time clock can be changed by calling - * PM_setRealTimeClockFrequeny, and the value can be any power of 2 value - * from 2Hz to 8192Hz. - * - * Note that you _must_ lock the memory containing the interrupt - * handlers with the PM_lockPages() function otherwise you may encounter - * problems in virtual memory environments. - * - * NOTE: User space versions of the PM library should fail these functions. - */ - -ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler ih,int frequency); -void PMAPI PM_setRealTimeClockFrequency(int frequency); -void PMAPI PM_restoreRealTimeClockHandler(void); - -/* Routines to install and remove hardware interrupt handlers. - * - * Note that you _must_ lock the memory containing the interrupt - * handlers with the PM_lockPages() function otherwise you may encounter - * problems in virtual memory environments. - * - * NOTE: User space versions of the PM library should fail these functions. - */ - -PM_IRQHandle PMAPI PM_setIRQHandler(int IRQ,PM_irqHandler ih); -void PMAPI PM_restoreIRQHandler(PM_IRQHandle irqHandle); - -/* Functions to program DMA using the legacy ISA DMA controller */ - -void PMAPI PM_DMACEnable(int channel); -void PMAPI PM_DMACDisable(int channel); -void PMAPI PM_DMACProgram(int channel,int mode,ulong bufferPhys,int count); -ulong PMAPI PM_DMACPosition(int channel); - -/* Function to post secondary graphics controllers using the BIOS */ - -ibool PMAPI PM_doBIOSPOST(ushort axVal,ulong BIOSPhysAddr,void *mappedBIOS,ulong BIOSLen); - -/* Function to init the AGP functions and return the AGP aperture size in MB */ - -ulong PMAPI PM_agpInit(void); -void PMAPI PM_agpExit(void); - -/* Functions to reserve and release physical AGP memory ranges */ - -ibool PMAPI PM_agpReservePhysical(ulong numPages,int type,void **physContext,PM_physAddr *physAddr); -ibool PMAPI PM_agpReleasePhysical(void *physContext); - -/* Functions to commit and free physical AGP memory ranges */ - -ibool PMAPI PM_agpCommitPhysical(void *physContext,ulong numPages,ulong startOffset,PM_physAddr *physAddr); -ibool PMAPI PM_agpFreePhysical(void *physContext,ulong numPages,ulong startOffset); - -/* Functions to do I/O port manipulation directly from C code. These - * functions are portable and will work on any processor architecture - * to access I/O space registers on PCI devices. - */ - -uchar PMAPI PM_inpb(int port); -ushort PMAPI PM_inpw(int port); -ulong PMAPI PM_inpd(int port); -void PMAPI PM_outpb(int port,uchar val); -void PMAPI PM_outpw(int port,ushort val); -void PMAPI PM_outpd(int port,ulong val); - -/* Functions to determine the I/O port locations for COM and LPT ports. - * The functions are zero based, so for COM1 or LPT1 pass in a value of 0, - * for COM2 or LPT2 pass in a value of 1 etc. - */ - -int PMAPI PM_getCOMPort(int port); -int PMAPI PM_getLPTPort(int port); - -/* Internal functions that need prototypes */ - -void PMAPI _PM_getRMvect(int intno, long *realisr); -void PMAPI _PM_setRMvect(int intno, long realisr); -void PMAPI _PM_freeMemoryMappings(void); - -/* Function to override the default debug log file location */ - -void PMAPI PM_setDebugLog(const char *logFilePath); - -/* Function to put the process to sleep for the specified milliseconds */ - -void PMAPI PM_sleep(ulong milliseconds); - -/* Function to block until 'milliseconds' have passed since last call */ - -void PMAPI PM_blockUntilTimeout(ulong milliseconds); - -/* Functions for directory traversal and management */ - -void * PMAPI PM_findFirstFile(const char *filename,PM_findData *findData); -ibool PMAPI PM_findNextFile(void *handle,PM_findData *findData); -void PMAPI PM_findClose(void *handle); -void PMAPI PM_makepath(char *p,const char *drive,const char *dir,const char *name,const char *ext); -int PMAPI PM_splitpath(const char *fn,char *drive,char *dir,char *name,char *ext); -ibool PMAPI PM_driveValid(char drive); -void PMAPI PM_getdcwd(int drive,char *dir,int len); -uint PMAPI PM_getFileAttr(const char *filename); -void PMAPI PM_setFileAttr(const char *filename,uint attrib); -ibool PMAPI PM_getFileTime(const char *filename,ibool gmTime,PM_time *time); -ibool PMAPI PM_setFileTime(const char *filename,ibool gmTime,PM_time *time); -ibool PMAPI PM_mkdir(const char *filename); -ibool PMAPI PM_rmdir(const char *filename); - -/* Functions to handle loading OS specific shared libraries */ - -PM_MODULE PMAPI PM_loadLibrary(const char *szDLLName); -void * PMAPI PM_getProcAddress(PM_MODULE hModule,const char *szProcName); -void PMAPI PM_freeLibrary(PM_MODULE hModule); - -/* Functions and macros for 64-bit arithmetic */ - -void PMAPI _PM_add64(u32 a_low,s32 a_high,u32 b_low,s32 b_high,__i64 *result); -void PMAPI _PM_sub64(u32 a_low,s32 a_high,u32 b_low,s32 b_high,__i64 *result); -void PMAPI _PM_mul64(u32 a_low,s32 a_high,u32 b_low,s32 b_high,__i64 *result); -void PMAPI _PM_div64(u32 a_low,s32 a_high,u32 b_low,s32 b_high,__i64 *result); -void PMAPI _PM_shr64(u32 a_low,s32 a_high,s32 shift,__i64 *result); -void PMAPI _PM_sar64(u32 a_low,s32 a_high,s32 shift,__i64 *result); -void PMAPI _PM_shl64(u32 a_low,s32 a_high,s32 shift,__i64 *result); -void PMAPI _PM_neg64(u32 a_low,s32 a_high,__i64 *result); -#ifdef __NATIVE_INT64__ -#define PM_add64(r,a,b) (r) = (a) + (b) -#define PM_add64_32(r,a,b) (r) = (a) + (b) -#define PM_sub64(r,a,b) (r) = (a) - (b) -#define PM_sub64_32(r,a,b) (r) = (a) - (b) -#define PM_mul64(r,a,b) (r) = (a) * (b) -#define PM_mul64_32(r,a,b) (r) = (a) * (b) -#define PM_div64(r,a,b) (r) = (a) / (b) -#define PM_div64_32(r,a,b) (r) = (a) / (b) -#define PM_shr64(r,a,s) (r) = (a) >> (s) -#define PM_sar64(r,a,s) (r) = ((s64)(a)) >> (s) -#define PM_shl64(r,a,s) (r) = (u64)(a) << (s) -#define PM_neg64(r,a,s) (r) = -(a) -#define PM_not64(r,a,s) (r) = ~(a) -#define PM_eq64(a,b) (a) == (b) -#define PM_gt64(a,b) (a) > (b) -#define PM_lt64(a,b) (a) < (b) -#define PM_geq64(a,b) (a) >= (b) -#define PM_leq64(a,b) (a) <= (b) -#define PM_64to32(a) (u32)(a) -#define PM_64tos32(a) (s32)(a) -#define PM_set64(a,b,c) (a) = ((u64)(b) << 32) + (c) -#define PM_set64_32(a,b) (a) = (b) -#else -#define PM_add64(r,a,b) _PM_add64((a).low,(a).high,(b).low,(b).high,&(r)) -#define PM_add64_32(r,a,b) _PM_add64((a).low,(a).high,b,0,&(r)) -#define PM_sub64(r,a,b) _PM_sub64((a).low,(a).high,(b).low,(b).high,&(r)) -#define PM_sub64_32(r,a,b) _PM_sub64((a).low,(a).high,b,0,&(r)) -#define PM_mul64(r,a,b) _PM_mul64((a).low,(a).high,(b).low,(b).high,&(r)) -#define PM_mul64_32(r,a,b) _PM_mul64((a).low,(a).high,b,0,&(r)) -#define PM_div64(r,a,b) _PM_div64((a).low,(a).high,(b).low,(b).high,&(r)) -#define PM_div64_32(r,a,b) _PM_div64((a).low,(a).high,b,0,&(r)) -#define PM_shr64(r,a,s) _PM_shr64((a).low,(a).high,s,&(r)) -#define PM_sar64(r,a,s) _PM_sar64((a).low,(a).high,s,&(r)) -#define PM_shl64(r,a,s) _PM_shl64((a).low,(a).high,s,&(r)) -#define PM_neg64(r,a,s) _PM_neg64((a).low,(a).high,&(r)) -#define PM_not64(r,a,s) (r).low = ~(a).low, (r).high = ~(a).high -#define PM_eq64(a,b) ((a).low == (b).low && (a).high == (b).high) -#define PM_gt64(a,b) (((a).high > (b).high) || ((a).high == (b).high && (a).low > (b).low)) -#define PM_lt64(a,b) (((a).high < (b).high) || ((a).high == (b).high && (a).low < (b).low)) -#define PM_geq64(a,b) (PM_eq64(a,b) || PM_gt64(a,b)) -#define PM_leq64(a,b) (PM_eq64(a,b) || PM_lt64(a,b)) -#define PM_64to32(a) (u32)(a.low) -#define PM_64tos32(a) ((a).high < 0) ? -(a).low : (a).low) -#define PM_set64(a,b,c) (a).high = (b), (a).low = (c) -#define PM_set64_32(a,b) (a).high = 0, (a).low = (b) -#endif - -/* Function to enable IOPL access if required */ - -int PMAPI PM_setIOPL(int iopl); - -/* Function to flush the TLB and CPU caches */ - -void PMAPI PM_flushTLB(void); - -/* DOS specific fucntions */ - -#ifdef __MSDOS__ -uint PMAPI PMHELP_getVersion(void); -void PMAPI PM_VxDCall(VXD_regs *regs); -#endif - -/* Functions to save and restore the VGA hardware state */ - -int PMAPI PM_getVGAStateSize(void); -void PMAPI PM_saveVGAState(void *stateBuf); -void PMAPI PM_restoreVGAState(const void *stateBuf); -void PMAPI PM_vgaBlankDisplay(void); -void PMAPI PM_vgaUnblankDisplay(void); - -/* Functions to load and unload DirectDraw libraries. Only used on - * Windows platforms. - */ - -void * PMAPI PM_loadDirectDraw(int device); -void PMAPI PM_unloadDirectDraw(int device); -PM_HWND PMAPI PM_getDirectDrawWindow(void); -void PMAPI PM_doSuspendApp(void); - -/* Functions to install, start, stop and remove NT services. Valid only - * for Win32 apps running on Windows NT. - */ - -#ifdef __WINDOWS32__ -ulong PMAPI PM_installService(const char *szDriverName,const char *szServiceName,const char *szLoadGroup,ulong dwServiceType); -ulong PMAPI PM_startService(const char *szServiceName); -ulong PMAPI PM_stopService(const char *szServiceName); -ulong PMAPI PM_removeService(const char *szServiceName); -#endif - -/* Routines to generate native interrupts (ie: protected mode interrupts - * for protected mode apps) using an interface the same as that use by - * int86() and int86x() in realmode. These routines are required because - * many 32 bit compilers use different register structures and different - * functions causing major portability headaches. Thus we provide our - * own and solve it all in one fell swoop, and we also get a routine to - * put stuff into 32 bit registers from real mode ;-) - */ - -void PMAPI PM_segread(PMSREGS *sregs); -int PMAPI PM_int386(int intno, PMREGS *in, PMREGS *out); -int PMAPI PM_int386x(int intno, PMREGS *in, PMREGS *out,PMSREGS *sregs); - -/* Call the X86 emulator or the real BIOS in our test harness */ - -#if defined(TEST_HARNESS) && !defined(PMLIB) -#define PM_mapRealPointer(r_seg,r_off) _PM_imports.PM_mapRealPointer(r_seg,r_off) -#define PM_getVESABuf(len,rseg,roff) _PM_imports.PM_getVESABuf(len,rseg,roff) -#define PM_callRealMode(seg,off,regs,sregs) _PM_imports.PM_callRealMode(seg,off,regs,sregs) -#define PM_int86(intno,in,out) _PM_imports.PM_int86(intno,in,out) -#define PM_int86x(intno,in,out,sregs) _PM_imports.PM_int86x(intno,in,out,sregs) -#endif - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif - -/* Include OS extensions for interrupt handling */ - -#if defined(__REALDOS__) || defined(__SMX32__) -#include "pmint.h" -#endif - -#endif /* __PMAPI_H */ diff --git a/board/MAI/bios_emulator/scitech/include/pmimp.h b/board/MAI/bios_emulator/scitech/include/pmimp.h deleted file mode 100644 index 817f5e6a21..0000000000 --- a/board/MAI/bios_emulator/scitech/include/pmimp.h +++ /dev/null @@ -1,193 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Header file declaring all the PM imports structure for the -* current version of the PM library. Included in all code -* that needs to pass the PM imports to BPD files. -* -****************************************************************************/ - -PM_imports _VARAPI _PM_imports = { - sizeof(PM_imports), - PM_getModeType, - PM_getBIOSPointer, - PM_getA0000Pointer, - PM_mapPhysicalAddr, - PM_mallocShared, - NULL, - PM_freeShared, - PM_mapToProcess, - PM_mapRealPointer, - PM_allocRealSeg, - PM_freeRealSeg, - PM_allocLockedMem, - PM_freeLockedMem, - PM_callRealMode, - PM_int86, - PM_int86x, - DPMI_int86, - PM_availableMemory, - PM_getVESABuf, - PM_getOSType, - PM_fatalError, - PM_setBankA, - PM_setBankAB, - PM_setCRTStart, - PM_getCurrentPath, - PM_getVBEAFPath, - PM_getNucleusPath, - PM_getNucleusConfigPath, - PM_getUniqueID, - PM_getMachineName, - VF_available, - VF_init, - VF_exit, - PM_openConsole, - PM_getConsoleStateSize, - PM_saveConsoleState, - PM_restoreConsoleState, - PM_closeConsole, - PM_setOSCursorLocation, - PM_setOSScreenWidth, - PM_enableWriteCombine, - PM_backslash, - PM_lockDataPages, - PM_unlockDataPages, - PM_lockCodePages, - PM_unlockCodePages, - PM_setRealTimeClockHandler, - PM_setRealTimeClockFrequency, - PM_restoreRealTimeClockHandler, - PM_doBIOSPOST, - PM_getBootDrive, - PM_freePhysicalAddr, - PM_inpb, - PM_inpw, - PM_inpd, - PM_outpb, - PM_outpw, - PM_outpd, - NULL, - PM_setSuspendAppCallback, - PM_haveBIOSAccess, - PM_kbhit, - PM_getch, - PM_findBPD, - PM_getPhysicalAddr, - PM_sleep, - PM_getCOMPort, - PM_getLPTPort, - PM_loadLibrary, - PM_getProcAddress, - PM_freeLibrary, - PCI_enumerate, - PCI_accessReg, - PCI_setHardwareIRQ, - PCI_generateSpecialCyle, - NULL, - PCIBIOS_getEntry, - CPU_getProcessorType, - CPU_haveMMX, - CPU_have3DNow, - CPU_haveSSE, - CPU_haveRDTSC, - CPU_getProcessorSpeed, - ZTimerInit, - LZTimerOn, - LZTimerLap, - LZTimerOff, - LZTimerCount, - LZTimerOnExt, - LZTimerLapExt, - LZTimerOffExt, - LZTimerCountExt, - ULZTimerOn, - ULZTimerLap, - ULZTimerOff, - ULZTimerCount, - ULZReadTime, - ULZElapsedTime, - ULZTimerResolution, - PM_findFirstFile, - PM_findNextFile, - PM_findClose, - PM_makepath, - PM_splitpath, - PM_driveValid, - PM_getdcwd, - PM_setFileAttr, - PM_mkdir, - PM_rmdir, - PM_getFileAttr, - PM_getFileTime, - PM_setFileTime, - CPU_getProcessorName, - PM_getVGAStateSize, - PM_saveVGAState, - PM_restoreVGAState, - PM_vgaBlankDisplay, - PM_vgaUnblankDisplay, - PM_blockUntilTimeout, - _PM_add64, - _PM_sub64, - _PM_mul64, - _PM_div64, - _PM_shr64, - _PM_sar64, - _PM_shl64, - _PM_neg64, - PCI_findBARSize, - PCI_readRegBlock, - PCI_writeRegBlock, - PM_flushTLB, - PM_useLocalMalloc, - PM_malloc, - PM_calloc, - PM_realloc, - PM_free, - PM_getPhysicalAddrRange, - PM_allocPage, - PM_freePage, - PM_agpInit, - PM_agpExit, - PM_agpReservePhysical, - PM_agpReleasePhysical, - PM_agpCommitPhysical, - PM_agpFreePhysical, - PCI_getNumDevices, - PM_setLocalBPDPath, -#ifdef __WINDOWS32__ - PM_loadDirectDraw, - PM_unloadDirectDraw, - PM_getDirectDrawWindow, - PM_doSuspendApp, -#else - NULL, - NULL, - NULL, - NULL, -#endif - }; diff --git a/board/MAI/bios_emulator/scitech/include/pmint.h b/board/MAI/bios_emulator/scitech/include/pmint.h deleted file mode 100644 index 7d76dad50c..0000000000 --- a/board/MAI/bios_emulator/scitech/include/pmint.h +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Real mode and 16/32 bit Protected Mode -* -* Description: Header file for the interrupt handling extensions to the OS -* Portability Manager Library. These extensions includes -* simplified interrupt handling, allowing all common interrupt -* handlers to be hooked and handled directly with normal C -* functions, both in 16 bit and 32 bit modes. Note however that -* simplified handling does not mean slow performance! All low -* level interrupt handling is done efficiently in assembler -* for speed (well actually necessary to insulate the -* application from the lack of far pointers in 32 bit PM). The -* interrupt handlers currently supported are: -* -* Mouse (0x33 callback) -* Timer Tick (0x8) -* Keyboard (0x9 and 0x15) -* Control C/Break (0x23/0x1B) -* Critical Error (0x24) -* -****************************************************************************/ - -#ifndef __PMINT_H -#define __PMINT_H - -/*--------------------------- Macros and Typedefs -------------------------*/ - -#ifdef __SMX32__ -/* PC interrupts (Ensure consistent with pme.inc) */ -#define PM_IRQ0 0x40 -#define PM_IRQ1 (PM_IRQ0+1) -#define PM_IRQ6 (PM_IRQ0+6) -#define PM_IRQ14 (PM_IRQ0+14) -#endif - -/* Define the different types of interrupt handlers that we support */ - -typedef uint (PMAPIP PM_criticalHandler)(uint axValue,uint diValue); -typedef void (PMAPIP PM_breakHandler)(uint breakHit); -typedef short (PMAPIP PM_key15Handler)(short scanCode); -typedef void (PMAPIP PM_mouseHandler)(uint event, uint butstate,int x,int y,int mickeyX,int mickeyY); - -/* Create a type for representing far pointers in both 16 and 32 bit - * protected mode. - */ - -#ifdef PM386 -typedef struct { - long off; - short sel; - } PMFARPTR; -#define PMNULL {0,0} -#else -typedef void *PMFARPTR; -#define PMNULL NULL -#endif - -/*--------------------------- Function Prototypes -------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -/* Routine to load save default data segment selector value into a code - * segment variable, and another to load the value into the DS register. - */ - -void PMAPI PM_loadDS(void); -void PMAPI PM_saveDS(void); - -/* Routine to install a mouse interrupt handling routine. The - * mouse handler routine is a normal C function, and the PM library - * will take care of passing the correct parameters to the function, - * and switching to a local stack. - * - * Note that you _must_ lock the memory containing the mouse interrupt - * handler with the PM_lockPages() function otherwise you may encounter - * problems in virtual memory environments. - */ - -int PMAPI PM_setMouseHandler(int mask,PM_mouseHandler mh); -void PMAPI PM_restoreMouseHandler(void); - -/* Routine to reset the mouse driver, and re-install the current - * mouse interrupt handler if one was currently installed (since the - * mouse reset will automatically remove this handler. - */ - -void PMAPI PM_resetMouseDriver(int hardReset); - -/* Routine to reset the mouse driver, and re-install the current - * mouse interrupt handler if one was currently installed (since the - * mouse reset will automatically remove this handler. - */ - -void PMAPI PM_resetMouseDriver(int hardReset); - -/* Routines to install and remove timer interrupt handlers. - * - * Note that you _must_ lock the memory containing the interrupt - * handlers with the PM_lockPages() function otherwise you may encounter - * problems in virtual memory environments. - */ - -void PMAPI PM_setTimerHandler(PM_intHandler ih); -void PMAPI PM_chainPrevTimer(void); -void PMAPI PM_restoreTimerHandler(void); - -/* Routines to install and keyboard interrupt handlers. - * - * Note that you _must_ lock the memory containing the interrupt - * handlers with the PM_lockPages() function otherwise you may encounter - * problems in virtual memory environments. - */ - -void PMAPI PM_setKeyHandler(PM_intHandler ih); -void PMAPI PM_chainPrevKey(void); -void PMAPI PM_restoreKeyHandler(void); - -/* Routines to hook and unhook the alternate Int 15h keyboard intercept - * callout routine. Your event handler will need to return the following: - * - * scanCode - Let the BIOS process scan code (chains to previous handler) - * 0 - You have processed the scan code so flush from BIOS - * - * Note that this is not available under all DOS extenders, but does - * work under real mode, DOS4GW and X32-VM. It does not work under the - * PowerPack 32 bit DOS extenders. If you figure out how to do it let us know! - */ - -void PMAPI PM_setKey15Handler(PM_key15Handler ih); -void PMAPI PM_restoreKey15Handler(void); - -/* Routines to install and remove the control c/break interrupt handlers. - * Interrupt handling is performed by the PM/Pro library, and you can call - * the supplied routines to test the status of the Ctrl-C and Ctrl-Break - * flags. If you pass the value TRUE for 'clearFlag' to these routines, - * the internal flags will be reset in order to catch another Ctrl-C or - * Ctrl-Break interrupt. - */ - -void PMAPI PM_installBreakHandler(void); -int PMAPI PM_ctrlCHit(int clearFlag); -int PMAPI PM_ctrlBreakHit(int clearFlag); -void PMAPI PM_restoreBreakHandler(void); - -/* Routine to install an alternate break handler that will call your - * code directly. This is not available under all DOS extenders, but does - * work under real mode, DOS4GW and X32-VM. It does not work under the - * PowerPack 32 bit DOS extenders. If you figure out how to do it let us know! - * - * Note that you should either install one or the other, but not both! - */ - -void PMAPI PM_installAltBreakHandler(PM_breakHandler bh); - -/* Routines to install and remove the critical error handler. The interrupt - * is handled by the PM/Pro library, and the operation will always be failed. - * You can check the status of the critical error handler with the - * appropriate function. If you pass the value TRUE for 'clearFlag', the - * internal flag will be reset ready to catch another critical error. - */ - -void PMAPI PM_installCriticalHandler(void); -int PMAPI PM_criticalError(int *axValue, int *diValue, int clearFlag); -void PMAPI PM_restoreCriticalHandler(void); - -/* Routine to install an alternate critical handler that will call your - * code directly. This is not available under all DOS extenders, but does - * work under real mode, DOS4GW and X32-VM. It does not work under the - * PowerPack 32 bit DOS extenders. If you figure out how to do it let us know! - * - * Note that you should either install one or the other, but not both! - */ - -void PMAPI PM_installAltCriticalHandler(PM_criticalHandler); - -/* Functions to manage protected mode only interrupt handlers */ - -void PMAPI PM_getPMvect(int intno, PMFARPTR *isr); -void PMAPI PM_setPMvect(int intno, PM_intHandler ih); -void PMAPI PM_restorePMvect(int intno, PMFARPTR isr); - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif - -#endif /* __PMINT_H */ diff --git a/board/MAI/bios_emulator/scitech/include/scitech.h b/board/MAI/bios_emulator/scitech/include/scitech.h deleted file mode 100644 index 8d5eee9443..0000000000 --- a/board/MAI/bios_emulator/scitech/include/scitech.h +++ /dev/null @@ -1,712 +0,0 @@ -/**************************************************************************** -* -* SciTech Multi-platform Graphics Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: any -* -* Description: General header file for operating system portable code. -* -****************************************************************************/ - -#ifndef __SCITECH_H -#define __SCITECH_H - -/* We have the following defines to identify the compilation environment: - * - * __16BIT__ Compiling for 16 bit code (any environment) - * __32BIT__ Compiling for 32 bit code (any environment) - * __MSDOS__ Compiling for MS-DOS (includes __WINDOWS16__, __WIN386__) - * __REALDOS__ Compiling for MS-DOS (excludes __WINDOWS16__) - * __MSDOS16__ Compiling for 16 bit MS-DOS - * __MSDOS32__ Compiling for 32 bit MS-DOS - * __WINDOWS__ Compiling for Windows - * __WINDOWS16__ Compiling for 16 bit Windows (__MSDOS__ also defined) - * __WINDOWS32__ Compiling for 32 bit Windows - * __WIN32_VXD__ Compiling for a 32-bit C based VxD - * __NT_DRIVER__ Compiling for a 32-bit C based NT device driver - * __OS2__ Compiling for OS/2 - * __OS2_16__ Compiling for 16 bit OS/2 - * __OS2_32__ Compiling for 32 bit OS/2 - * __UNIX__ Compiling for Unix - * __QNX__ Compiling for the QNX realtime OS (Unix compatible) - * __LINUX__ Compiling for the Linux OS (Unix compatible) - * __FREEBSD__ Compiling for the FreeBSD OS (Unix compatible) - * __BEOS__ Compiling for the BeOS (Unix compatible) - * __SMX32__ Compiling for the SMX 32-bit Real Time OS - * __ENEA_OSE__ Compiling for the OSE embedded OS - * __RTTARGET__ Compiling for the RTTarget 32-bit embedded OS - * __MACOS__ Compiling for the MacOS platform (PowerPC) - * __DRIVER__ Compiling for a 32-bit binary compatible driver - * __CONSOLE__ Compiling for a fullscreen OS console mode - * __SNAP__ Compiling as a Snap executeable or dynamic library - * - * __INTEL__ Compiling for Intel CPU's - * __ALPHA__ Compiling for DEC Alpha CPU's - * __MIPS__ Compiling for MIPS CPU's - * __PPC__ Compiling for PowerPC CPU's - * __MC68K__ Compiling for Motorola 680x0 - * - * __BIG_ENDIAN__ Compiling for a big endian processor - * - */ - -#ifdef __SC__ -#if __INTSIZE == 4 -#define __SC386__ -#endif -#endif - -/* Determine some things that are compiler specific */ - -#ifdef __GNUC__ -#ifdef __cplusplus -/* G++ currently fucks this up! */ -#define __cdecl -#define __stdcall -#else -#undef __cdecl -#undef __stdcall -#define __cdecl __attribute__ ((cdecl)) -#define __stdcall __attribute__ ((stdcall)) -#endif -#define __FLAT__ /* GCC is always 32 bit flat model */ -#define __HAS_BOOL__ /* Latest GNU C++ has ibool type */ -#define __HAS_LONG_LONG__ /* GNU C supports long long type */ -#include /* Bring in for definition of NULL */ -#endif - -#ifdef __BORLANDC__ -#if (__BORLANDC__ >= 0x500) || defined(CLASSLIB_DEFS_H) -#define __HAS_BOOL__ /* Borland C++ 5.0 defines ibool type */ -#endif -#if (__BORLANDC__ >= 0x502) && !defined(VTOOLSD) && !defined(__SMX32__) -#define __HAS_INT64__ /* Borland C++ 5.02 supports __int64 type */ -#endif -#endif - -#if defined(_MSC_VER) && !defined(__SC__) && !defined(VTOOLSD) && !defined(__SMX32__) -#define __HAS_INT64__ /* Visual C++ supports __int64 type */ -#endif - -#if defined(__WATCOMC__) && (__WATCOMC__ >= 1100) && !defined(VTOOLSD) && !defined(__SMX32__) -#define __HAS_INT64__ /* Watcom C++ 11.0 supports __int64 type */ -#endif - -/*--------------------------------------------------------------------------- - * Determine the compile time environment. This must be done for each - * supported platform so that we can determine at compile time the target - * environment, hopefully without requiring #define's from the user. - *-------------------------------------------------------------------------*/ - -/* 32-bit binary compatible driver. Compiled as Win32, but as OS neutral */ -#ifdef __DRIVER__ -#ifndef __32BIT__ -#define __32BIT__ -#endif -#undef __WINDOWS__ -#undef _WIN32 -#undef __WIN32__ -#undef __NT__ - -/* 32-bit Snap exe or dll. Compiled as Win32, but as OS neutral */ -#elif defined(__SNAP__) -#ifndef __32BIT__ -#define __32BIT__ -#endif -#undef __WINDOWS__ -#undef _WIN32 -#undef __WIN32__ -#undef __NT__ - -/* 32-bit Windows VxD compile environment */ -#elif defined(__vtoolsd_h_) || defined(VTOOLSD) -#include -#define __WIN32_VXD__ -#ifndef __32BIT__ -#define __32BIT__ -#endif -#define _MAX_PATH 256 -#undef __WINDOWS32__ - -/* 32-bit Windows NT driver compile environment: TODO!! */ -#elif defined(__NT_DRIVER__) -#include "ntdriver.h" -#ifndef __32BIT__ -#define __32BIT__ -#endif -#define _MAX_PATH 256 -#undef __WINDOWS32__ - -/* 32-bit SMX compile environment */ -#elif defined(__SMX32__) -#ifndef __MSDOS__ -#define __MSDOS__ -#endif -#ifndef __32BIT__ -#define __32BIT__ -#endif -#ifndef __CONSOLE__ -#define __CONSOLE__ -#endif - -/* 32-bit Enea OSE environment */ -#elif defined(__ENEA_OSE__) -#ifndef __32BIT__ -#define __32BIT__ -#endif -#ifndef __CONSOLE__ -#define __CONSOLE__ -#endif - -/* 32-bit RTTarget-32 environment */ -#elif defined(__RTTARGET__) -#ifndef __32BIT__ -#define __32BIT__ -#endif -#ifndef __CONSOLE__ -#define __CONSOLE__ -#endif - -/* 32-bit extended DOS compile environment */ -#elif defined(__MSDOS__) || defined(__MSDOS32__) || defined(__DOS__) || defined(__DPMI32__) || (defined(M_I86) && (!defined(__SC386__) && !defined(M_I386))) || defined(TNT) -#ifndef __MSDOS__ -#define __MSDOS__ -#endif -#if defined(__MSDOS32__) || defined(__386__) || defined(__FLAT__) || defined(__NT__) || defined(__SC386__) -#ifndef __MSDOS32__ -#define __MSDOS32__ -#endif -#ifndef __32BIT__ -#define __32BIT__ -#endif -#ifndef __REALDOS__ -#define __REALDOS__ -#endif -#ifndef __CONSOLE__ -#define __CONSOLE__ -#endif - -/* 16-bit Windows compile environment */ -#elif (defined(_Windows) || defined(_WINDOWS)) && !defined(__DPMI16__) -#ifndef __16BIT__ -#define __16BIT__ -#endif -#ifndef __WINDOWS16__ -#define __WINDOWS16__ -#endif -#ifndef __WINDOWS__ -#define __WINDOWS__ -#endif -#ifndef __MSDOS__ -#define __MSDOS__ -#endif - -/* 16-bit DOS compile environment */ -#else -#ifndef __16BIT__ -#define __16BIT__ -#endif -#ifndef __MSDOS16__ -#define __MSDOS16__ -#endif -#ifndef __REALDOS__ -#define __REALDOS__ -#endif -#ifndef __CONSOLE__ -#define __CONSOLE__ -#endif -#endif - -/* 32-bit Windows compile environment */ -#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) -#ifndef __32BIT__ -#define __32BIT__ -#endif -#ifndef __WINDOWS32__ -#define __WINDOWS32__ -#endif -#ifndef _WIN32 -#define _WIN32 /* Microsoft Win32 SDK headers use _WIN32 */ -#endif -#ifndef WIN32 -#define WIN32 /* OpenGL headers use WIN32 */ -#endif -#ifndef __WINDOWS__ -#define __WINDOWS__ -#endif - -/* 32-bit OS/2 VDD compile environment */ -/* We're assuming (for now) that CL386 must be used */ -#elif defined(MSDOS) && defined(M_I386) -/* fixes necessary to compile with CL386 */ -#define __cdecl _cdecl -typedef unsigned int size_t; - -#include - -/* This should probably be somewhere else... */ -/* Inline eligible functions (we have no CRT libs for CL386) */ -#pragma intrinsic (strcpy, strcmp, strlen, strcat) -#pragma intrinsic (memcmp, memcpy, memset) - -#define __OS2_VDD__ -#ifndef __32BIT__ -#define __32BIT__ -#endif -#define CCHMAXPATH 256 -#define _MAX_PATH 256 -#ifndef __OS2__ -#define __OS2__ -#endif -#ifndef __OS2_32__ -#define __OS2_32__ -#endif - -/* 16-bit OS/2 compile environment */ -#elif defined(__OS2_16__) -#ifndef __OS2__ -#define __OS2__ -#endif -#ifndef __16BIT__ -#define __16BIT__ -#endif -#ifndef __OS2_PM__ -#ifndef __CONSOLE__ -#define __CONSOLE__ -#endif -#endif - -/* 32-bit OS/2 compile environment */ -#elif defined(__OS2__) || defined(__OS2_32__) -#ifndef __OS2__ -#define __OS2__ -#endif -#ifndef __OS2_32__ -#define __OS2_32__ -#endif -#ifndef __32BIT__ -#define __32BIT__ -#endif -#ifndef __OS2_PM__ -#ifndef __CONSOLE__ -#define __CONSOLE__ -#endif -#endif - -/* 32-bit QNX compile environment */ -#elif defined(__QNX__) -#ifndef __32BIT__ -#define __32BIT__ -#endif -#ifndef __UNIX__ -#define __UNIX__ -#endif -#ifdef __GNUC__ -#define stricmp strcasecmp -#endif -#if !defined(__PHOTON__) && !defined(__X11__) -#ifndef __CONSOLE__ -#define __CONSOLE__ -#endif -#endif - -/* 32-bit Linux compile environment */ -#elif defined(__LINUX__) || defined(linux) -#ifndef __LINUX__ -#define __LINUX__ -#endif -#ifndef __32BIT__ -#define __32BIT__ -#endif -#ifndef __UNIX__ -#define __UNIX__ -#endif -#ifdef __GNUC__ -#define stricmp strcasecmp -#endif -#ifndef __X11__ -#ifndef __CONSOLE__ -#define __CONSOLE__ -#endif -#endif - -/* 32-bit FreeBSD compile environment */ -#elif defined(__FREEBSD__) -#ifndef __FREEBSD__ -#define __FREEBSD__ -#endif -#ifndef __32BIT__ -#define __32BIT__ -#endif -#ifndef __UNIX__ -#define __UNIX__ -#endif -#ifdef __GNUC__ -#define stricmp strcasecmp -#endif -#ifndef __X11__ -#ifndef __CONSOLE__ -#define __CONSOLE__ -#endif -#endif - -/* 32-bit BeOS compile environment */ -#elif defined(__BEOS__) -#ifndef __32BIT__ -#define __32BIT__ -#endif -#ifndef __UNIX__ -#define __UNIX__ -#endif -#ifdef __GNUC__ -#define stricmp strcasecmp -#endif - -/* Unsupported OS! */ -#else -#error This platform is not currently supported! -#endif - -/* Determine the CPU type that we are compiling for */ - -#if defined(__M_ALPHA) || defined(__ALPHA_) || defined(__ALPHA) || defined(__alpha) -#ifndef __ALPHA__ -#define __ALPHA__ -#endif -#elif defined(__M_PPC) || defined(__POWERC) -#ifndef __PPC__ -#define __PPC__ -#endif -#elif defined(__M_MRX000) -#ifndef __MIPS__ -#define __MIPS__ -#endif -#else -#ifndef __INTEL__ -#define __INTEL__ /* Assume Intel if nothing found */ -#endif -#endif - -/* We have the following defines to define the calling conventions for - * publicly accesible functions: - * - * _PUBAPI - Compiler default calling conventions for all public 'C' functions - * _ASMAPI - Calling conventions for all public assembler functions - * _VARAPI - Modifiers for variables; Watcom C++ mangles C++ globals - * _STDCALL - Win32 __stdcall where possible, __cdecl if not supported - */ - -#if defined(_MSC_VER) && defined(_WIN32) && !defined(__SC__) -#define __PASCAL __stdcall -#else -#define __PASCAL __pascal -#endif - -#if defined(NO_STDCALL) -#define _STDCALL __cdecl -#else -#define _STDCALL __stdcall -#endif - -#ifdef __WATCOMC__ -#if (__WATCOMC__ >= 1050) -#define _VARAPI __cdecl -#else -#define _VARAPI -#endif -#else -#define _VARAPI -#endif - -#if defined(__IBMC__) || defined(__IBMCPP__) -#define PTR_DECL_IN_FRONT -#endif - -/* Define the calling conventions for all public functions. For simplicity - * we define all public functions as __cdecl calling conventions, so that - * they are the same across all compilers and runtime DLL's. - */ - -#define _PUBAPI __cdecl -#define _ASMAPI __cdecl - -/* Determine the syntax for declaring a function pointer with a - * calling conventions override. Most compilers require the calling - * convention to be declared in front of the '*', but others require - * it to be declared after the '*'. We handle both in here depending - * on what the compiler requires. - */ - -#ifdef PTR_DECL_IN_FRONT -#define _PUBAPIP * _PUBAPI -#define _ASMAPIP * _ASMAPI -#else -#define _PUBAPIP _PUBAPI * -#define _ASMAPIP _ASMAPI * -#endif - -/* Useful macros */ - -#define PRIVATE static -#define PUBLIC - -/* This HAS to be 0L for 16-bit real mode code to work!!! */ - -#ifndef NULL -# define _NULL 0L -# define NULL _NULL -#endif - -#ifndef MAX -# define MAX(a,b) ( ((a) > (b)) ? (a) : (b)) -#endif -#ifndef MIN -# define MIN(a,b) ( ((a) < (b)) ? (a) : (b)) -#endif -#ifndef ABS -# define ABS(a) ((a) >= 0 ? (a) : -(a)) -#endif -#ifndef SIGN -# define SIGN(a) ((a) > 0 ? 1 : -1) -#endif - -/* General typedefs */ - -#ifndef __GENDEFS -#define __GENDEFS -#if defined(__BEOS__) -#include -#else -#ifdef __LINUX__ -#include -#ifdef __STRICT_ANSI__ -typedef unsigned short ushort; -typedef unsigned long ulong; -typedef unsigned int uint; -#endif -#ifdef __KERNEL__ -#define __GENDEFS_2 -#endif -#else -#if !(defined(__QNXNTO__) && defined(GENERAL_STRUCT)) -typedef unsigned short ushort; -typedef unsigned long ulong; -#endif -typedef unsigned int uint; -#endif -typedef unsigned char uchar; -#endif -typedef int ibool; /* Integer boolean type */ -#ifdef USE_BOOL /* Only for older code */ -#ifndef __cplusplus -#define bool ibool /* Standard C */ -#else -#ifndef __HAS_BOOL__ -#define bool ibool /* Older C++ compilers */ -#endif -#endif /* __cplusplus */ -#endif /* USE_BOOL */ -#endif /* __GENDEFS */ - -/* More general typedefs compatible with Linux kernel code */ - -#ifndef __GENDEFS_2 -#define __GENDEFS_2 -typedef char s8; -typedef unsigned char u8; -typedef short s16; -typedef unsigned short u16; -#ifdef __16BIT__ -typedef long s32; -typedef unsigned long u32; -#else -typedef int s32; -typedef unsigned int u32; -#endif -typedef struct { - u32 low; - s32 high; - } __i64; -#ifdef __HAS_LONG_LONG__ -#define __NATIVE_INT64__ -typedef long long s64; -typedef unsigned long long u64; -#elif defined(__HAS_INT64__) && !defined(__16BIT__) -#define __NATIVE_INT64__ -typedef __int64 s64; -typedef unsigned __int64 u64; -#else -typedef __i64 s64; -typedef __i64 u64; -#endif -#endif - -/* Boolean truth values */ - -#undef false -#undef true -#undef NO -#undef YES -#undef FALSE -#undef TRUE -#define false 0 -#define true 1 -#define NO 0 -#define YES 1 -#define FALSE 0 -#define TRUE 1 - -/* Inline debugger interrupts for Watcom C++ and Borland C++ */ - -#ifdef __WATCOMC__ -void DebugInt(void); -#pragma aux DebugInt = \ - "int 3"; -void DebugVxD(void); -#pragma aux DebugVxD = \ - "int 1"; -#elif defined(__BORLANDC__) -#define DebugInt() __emit__(0xCC) -#define DebugVxD() {__emit__(0xCD); __emit__(0x01);} -#elif defined(_MSC_VER) -#define DebugInt() _asm int 0x3 -#define DebugVxD() _asm int 0x1 -#elif defined(__GNUC__) -#define DebugInt() asm volatile ("int $0x3") -#define DebugVxD() asm volatile ("int $0x1") -#else -void _ASMAPI DebugInt(void); -void _ASMAPI DebugVxD(void); -#endif - -/* Macros to break once and never break again */ - -#define DebugIntOnce() \ -{ \ - static ibool firstTime = true; \ - if (firstTime) { \ - firstTime = false; \ - DebugInt(); \ - } \ -} - -#define DebugVxDOnce() \ -{ \ - static ibool firstTime = true; \ - if (firstTime) { \ - firstTime = false; \ - DebugVxD(); \ - } \ -} - -/* Macros for linux string compatibility functions */ - -#ifdef __LINUX__ -#define stricmp strcasecmp -#define strnicmp strncasecmp -#endif - -/* Macros for NT driver string compatibility functions */ - -#ifdef __NT_DRIVER__ -#define stricmp _stricmp -#define strnicmp _strnicmp -#endif - -/* Get rid of some helaciously annoying Visual C++ warnings! */ - -#if defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__SC__) -#pragma warning(disable:4761) /* integral size mismatch in argument; conversion supplied */ -#pragma warning(disable:4244) /* conversion from 'unsigned short ' to 'unsigned char ', possible loss of data */ -#pragma warning(disable:4018) /* '<' : signed/unsigned mismatch */ -#pragma warning(disable:4305) /* 'initializing' : truncation from 'const double' to 'float' */ -#endif - -/*--------------------------------------------------------------------------- - * Set of debugging macros used by the libraries. If the debug flag is - * set, they are turned on depending on the setting of the flag. User code - * can override the default functions called when a check fails, and the - * MGL does this so it can restore the system from graphics mode to display - * an error message. These functions also log information to the - * scitech.log file in the root directory of the hard drive when problems - * show up. - * - * If you set the value of CHECKED to be 2, it will also enable code to - * insert hard coded debugger interrupt into the source code at the line of - * code where the check fail. This is useful if you run the code under a - * debugger as it will break inside the debugger before exiting with a - * failure condition. - * - * Also for code compiled to run under Windows, we also call the - * OutputDebugString function to send the message to the system debugger - * such as Soft-ICE or WDEB386. Hence if you get any non-fatal warnings you - * will see those on the debugger terminal as well as in the log file. - *-------------------------------------------------------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -extern void (*_CHK_fail)(int fatal,const char *msg,const char *cond,const char *file,int line); -void _CHK_defaultFail(int fatal,const char *msg,const char *cond,const char *file,int line); - -#ifdef CHECKED -# define CHK(x) x -#if CHECKED > 1 -# define CHECK(p) \ - ((p) ? (void)0 : DebugInt(), \ - _CHK_fail(1,"Check failed: '%s', file %s, line %d\n", \ - #p, __FILE__, __LINE__)) -# define WARN(p) \ - ((p) ? (void)0 : DebugInt(), \ - _CHK_fail(0,"Warning: '%s', file %s, line %d\n", \ - #p, __FILE__, __LINE__)) -#else -# define CHECK(p) \ - ((p) ? (void)0 : \ - _CHK_fail(1,"Check failed: '%s', file %s, line %d\n", \ - #p, __FILE__, __LINE__)) -# define WARN(p) \ - ((p) ? (void)0 : \ - _CHK_fail(0,"Warning: '%s', file %s, line %d\n", \ - #p, __FILE__, __LINE__)) -#endif -# define LOGFATAL(msg) \ - _CHK_fail(1,"Fatal error: '%s', file %s, line %d\n", \ - msg, __FILE__, __LINE__) -# define LOGWARN(msg) \ - _CHK_fail(0,"Warning: '%s', file %s, line %d\n", \ - msg, __FILE__, __LINE__) -#else -# define CHK(x) -# define CHECK(p) ((void)0) -# define WARN(p) ((void)0) -# define LOGFATAL(msg) ((void)0) -# define LOGWARN(msg) ((void)0) -#endif - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif - -#endif /* __SCITECH_H */ diff --git a/board/MAI/bios_emulator/scitech/include/scitech.mac b/board/MAI/bios_emulator/scitech/include/scitech.mac deleted file mode 100644 index 27a2fc06e8..0000000000 --- a/board/MAI/bios_emulator/scitech/include/scitech.mac +++ /dev/null @@ -1,1321 +0,0 @@ -;**************************************************************************** -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: NetWide Assembler (NASM) or Turbo Assembler (TASM) -;* Environment: Any Intel Environment -;* -;* Description: Macros to provide memory model independant assembly language -;* module for C programming. Supports the large and flat memory -;* models. -;* -;* The defines that you should use when assembling modules that -;* use this macro package are: -;* -;* __LARGE__ Assemble for 16-bit large model -;* __FLAT__ Assemble for 32-bit FLAT memory model -;* __NOU__ No underscore for all external C labels -;* __NOU_VAR__ No underscore for global variables only -;* -;* The default settings are for 16-bit large memory model with -;* leading underscores for symbol names. -;* -;* The main intent of the macro file is to enable programmers -;* to write _one_ set of source that can be assembled to run -;* in either 16 bit real and protected modes or 32 bit -;* protected mode without the need to riddle the code with -;* 'if flatmodel' style conditional assembly (it is still there -;* but nicely hidden by a macro layer that enhances the -;* readability and understandability of the resulting code). -;* -;**************************************************************************** - -; Include the appropriate version in here depending on the assembler. NASM -; appears to always try and parse code, even if it is in a non-compiling -; block of a ifdef expression, and hence crashes if we include the TASM -; macro package in the same header file. Hence we split the macros up into -; two separate header files. - -ifdef __NASM_MAJOR__ - -;============================================================================ -; Macro package when compiling with NASM. -;============================================================================ - -; Turn off underscores for globals if disabled for all externals - -%ifdef __NOU__ -%define __NOU_VAR__ -%endif - -; Define the __WINDOWS__ symbol if we are compiling for any Windows -; environment - -%ifdef __WINDOWS16__ -%define __WINDOWS__ 1 -%endif -%ifdef __WINDOWS32__ -%define __WINDOWS__ 1 -%define __WINDOWS32_386__ 1 -%endif - -; Macros for accessing 'generic' registers - -%ifdef __FLAT__ -%idefine _ax eax -%idefine _bx ebx -%idefine _cx ecx -%idefine _dx edx -%idefine _si esi -%idefine _di edi -%idefine _bp ebp -%idefine _sp esp -%idefine _es -%idefine UCHAR BYTE ; Size of a character -%idefine USHORT WORD ; Size of a short -%idefine UINT DWORD ; Size of an integer -%idefine ULONG DWORD ; Size of a long -%idefine BOOL DWORD ; Size of a boolean -%idefine DPTR DWORD ; Size of a data pointer -%idefine FDPTR FWORD ; Size of a far data pointer -%idefine NDPTR DWORD ; Size of a near data pointer -%idefine CPTR DWORD ; Size of a code pointer -%idefine FCPTR FWORD ; Size of a far code pointer -%idefine NCPTR DWORD ; Size of a near code pointer -%idefine FPTR NEAR ; Distance for function pointers -%idefine DUINT dd ; Declare a integer variable -%idefine intsize 4 -%idefine flatmodel 1 -%else -%idefine _ax ax -%idefine _bx bx -%idefine _cx cx -%idefine _dx dx -%idefine _si si -%idefine _di di -%idefine _bp bp -%idefine _sp sp -%idefine _es es: -%idefine UCHAR BYTE ; Size of a character -%idefine USHORT WORD ; Size of a short -%idefine UINT WORD ; Size of an integer -%idefine ULONG DWORD ; Size of a long -%idefine BOOL WORD ; Size of a boolean -%idefine DPTR DWORD ; Size of a data pointer -%idefine FDPTR DWORD ; Size of a far data pointer -%idefine NDPTR WORD ; Size of a near data pointer -%idefine CPTR DWORD ; Size of a code pointer -%idefine FCPTR DWORD ; Size of a far code pointer -%idefine NCPTR WORD ; Size of a near code pointer -%idefine FPTR FAR ; Distance for function pointers -%idefine DUINT dw ; Declare a integer variable -%idefine intsize 2 -%endif -%idefine invert ~ -%idefine offset -%idefine use_nasm - -; Convert all jumps to near jumps, since NASM does not so this automatically - -%idefine jo jo near -%idefine jno jno near -%idefine jz jz near -%idefine jnz jnz near -%idefine je je near -%idefine jne jne near -%idefine jb jb near -%idefine jbe jbe near -%idefine ja ja near -%idefine jae jae near -%idefine jl jl near -%idefine jle jle near -%idefine jg jg near -%idefine jge jge near -%idefine jc jc near -%idefine jnc jnc near -%idefine js js near -%idefine jns jns near - -%ifdef DOUBLE -%idefine REAL QWORD -%idefine DREAL dq -%else -%idefine REAL DWORD -%idefine DREAL dd -%endif - -; Boolean truth values (same as those in debug.h) - -%idefine False 0 -%idefine True 1 -%idefine No 0 -%idefine Yes 1 -%idefine Yes 1 - -; Macro to be invoked at the start of all modules to set up segments for -; later use. Does nothing for NASM. - -%imacro header 1 -%endmacro - -; Macro to begin a data segment - -%imacro begdataseg 1 -%ifdef __GNUC__ -segment .data public class=DATA use32 flat -%else -%ifdef flatmodel -segment _DATA public align=4 class=DATA use32 flat -%else -segment _DATA public align=4 class=DATA use16 -%endif -%endif -%endmacro - -; Macro to end a data segment - -%imacro enddataseg 1 -%endmacro - -; Macro to begin a code segment - -%imacro begcodeseg 1 -%ifdef __PIC__ -%ifdef __LINUX__ - extern _GLOBAL_OFFSET_TABLE_ -%else - extern __GLOBAL_OFFSET_TABLE_ -%endif -%endif -%ifdef __GNUC__ -segment .text public class=CODE use32 flat -%else -%ifdef flatmodel -segment _TEXT public align=16 class=CODE use32 flat -%else -segment %1_TEXT public align=16 class=CODE use16 -%endif -%endif -%endmacro - -; Macro to begin a near code segment - -%imacro begcodeseg_near 0 -%ifdef __GNUC__ -segment .text public class=CODE use32 flat -%else -%ifdef flatmodel -segment _TEXT public align=16 class=CODE use32 flat -%else -segment _TEXT public align=16 class=CODE use16 -%endif -%endif -%endmacro - -; Macro to end a code segment - -%imacro endcodeseg 1 -%endmacro - -; Macro to end a near code segment - -%imacro endcodeseg_near 0 -%endmacro - -; Macro for an extern C symbol. If the C compiler requires leading -; underscores, then the underscores are added to the symbol names, otherwise -; they are left off. The symbol name is referenced in the assembler code -; using the non-underscored symbol name. - -%imacro cextern 2 -%ifdef __NOU_VAR__ -extern %1 -%else -extern _%1 -%define %1 _%1 -%endif -%endmacro - -%imacro cexternfunc 2 -%ifdef __NOU__ -extern %1 -%else -extern _%1 -%define %1 _%1 -%endif -%endmacro - -; Macro for a public C symbol. If the C compiler requires leading -; underscores, then the underscores are added to the symbol names, otherwise -; they are left off. The symbol name is referenced in the assembler code -; using the non-underscored symbol name. - -%imacro cpublic 1 -%ifdef __NOU_VAR__ -global %1 -%1: -%else -global _%1 -_%1: -%define %1 _%1 -%endif -%endmacro - -; Macro for an global C symbol. If the C compiler requires leading -; underscores, then the underscores are added to the symbol names, otherwise -; they are left off. The symbol name is referenced in the assembler code -; using the non-underscored symbol name. - -%imacro cglobal 1 -%ifdef __NOU_VAR__ -global %1 -%else -global _%1 -%define %1 _%1 -%endif -%endmacro - -; Macro for an global C function symbol. If the C compiler requires leading -; underscores, then the underscores are added to the symbol names, otherwise -; they are left off. The symbol name is referenced in the assembler code -; using the non-underscored symbol name. - -%imacro cglobalfunc 1 -%ifdef __PIC__ -global %1:function -%else -%ifdef __NOU__ -global %1 -%else -global _%1 -%define %1 _%1 -%endif -%endif -%endmacro - -; Macro to start a C callable function. This will be a far function for -; 16-bit code, and a near function for 32-bit code. - -%imacro cprocstatic 1 -%push cproc -%1: -%ifdef flatmodel -%stacksize flat -%define ret retn -%else -%stacksize large -%define ret retf -%endif -%assign %$localsize 0 -%endmacro - -%imacro cprocstart 1 -%push cproc - cglobalfunc %1 -%1: -%ifdef flatmodel -%stacksize flat -%define ret retn -%else -%stacksize large -%define ret retf -%endif -%assign %$localsize 0 -%endmacro - -; This macro sets up a procedure to be exported from a 16 bit DLL. Since the -; calling conventions are always _far _pascal for 16 bit DLL's, we actually -; rename this routine with an extra underscore with 'C' calling conventions -; and a small DLL stub will be provided by the high level code to call the -; assembler routine. - -%imacro cprocstartdll16 1 -%ifdef __WINDOWS16__ -cprocstart _%1 -%else -cprocstart %1 -%endif -%endmacro - -; Macro to start a C callable near function. - -%imacro cprocnear 1 -%push cproc - cglobalfunc %1 -%1: -%define ret retn -%ifdef flatmodel -%stacksize flat -%else -%stacksize small -%endif -%assign %$localsize 0 -%endmacro - -; Macro to start a C callable far function. - -%imacro cprocfar 1 -%push cproc - cglobalfunc %1 -%1: -%define ret retf -%ifdef flatmodel -%stacksize flat -%else -%stacksize large -%endif -%assign %$localsize 0 -%endmacro - -; Macro to end a C function - -%imacro cprocend 0 -%pop -%endmacro - -; Macros for entering and exiting C callable functions. Note that we must -; always save and restore the SI and DI registers for C functions, and for -; 32 bit C functions we also need to save and restore EBX and clear the -; direction flag. - -%imacro enter_c 0 - push _bp - mov _bp,_sp -%ifnidn %$localsize,0 - sub _sp,%$localsize -%endif -%ifdef flatmodel - push ebx -%endif - push _si - push _di -%endmacro - -%imacro leave_c 0 - pop _di - pop _si -%ifdef flatmodel - pop ebx - cld -%endif -%ifnidn %$localsize,0 - mov _sp,_bp -%endif - pop _bp -%endmacro - -%imacro use_ebx 0 -%ifdef flatmodel - push ebx -%endif -%endmacro - -%imacro unuse_ebx 0 -%ifdef flatmodel - pop ebx -%endif -%endmacro - -; Macros for saving and restoring the value of DS,ES,FS,GS when it is to -; be used in assembly routines. This evaluates to nothing in the flat memory -; model, but is saves and restores DS in the large memory model. - -%imacro use_ds 0 -%ifndef flatmodel - push ds -%endif -%endmacro - -%imacro unuse_ds 0 -%ifndef flatmodel - pop ds -%endif -%endmacro - -%imacro use_es 0 -%ifndef flatmodel - push es -%endif -%endmacro - -%imacro unuse_es 0 -%ifndef flatmodel - pop es -%endif -%endmacro - -; Macros for loading the address of a data pointer into a segment and -; index register pair. The %imacro explicitly loads DS or ES in the 16 bit -; memory model, or it simply loads the offset into the register in the flat -; memory model since DS and ES always point to all addressable memory. You -; must use the correct _REG (ie: _BX) %imacros for documentation purposes. - -%imacro _lds 2 -%ifdef flatmodel - mov %1,%2 -%else - lds %1,%2 -%endif -%endmacro - -%imacro _les 2 -%ifdef flatmodel - mov %1,%2 -%else - les %1,%2 -%endif -%endmacro - -; Macros for adding and subtracting a value from registers. Two value are -; provided, one for 16 bit modes and another for 32 bit modes (the extended -; register is used in 32 bit modes). - -%imacro _add 3 -%ifdef flatmodel - add e%1, %3 -%else - add %1, %2 -%endif -%endmacro - -%imacro _sub 3 -%ifdef flatmodel - sub e%1, %3 -%else - sub %1, %2 -%endif -%endmacro - -; Macro to clear the high order word for the 32 bit extended registers. -; This is used to convert an unsigned 16 bit value to an unsigned 32 bit -; value, and will evaluate to nothing in 16 bit modes. - -%imacro clrhi 1 -%ifdef flatmodel - movzx e%1,%1 -%endif -%endmacro - -%imacro sgnhi 1 -%ifdef flatmodel - movsx e%1,%1 -%endif -%endmacro - -; Macro to load an extended register with an integer value in either mode - -%imacro loadint 2 -%ifdef flatmodel - mov e%1,%2 -%else - xor e%1,e%1 - mov %1,%2 -%endif -%endmacro - -; Macros to load and store integer values with string instructions - -%imacro LODSINT 0 -%ifdef flatmodel - lodsd -%else - lodsw -%endif -%endmacro - -%imacro STOSINT 0 -%ifdef flatmodel - stosd -%else - stosw -%endif -%endmacro - -; Macros to provide resb, resw, resd compatibility with NASM - -%imacro dclb 1 -times %1 db 0 -%endmacro - -%imacro dclw 1 -times %1 dw 0 -%endmacro - -%imacro dcld 1 -times %1 dd 0 -%endmacro - -; Macro to get the addres of the GOT for Linux/FreeBSD shared -; libraries into the EBX register. - -%imacro get_GOT 1 - call %%getgot -%%getgot: pop %1 - add %1,_GLOBAL_OFFSET_TABLE_+$$-%%getgot wrt ..gotpc -%endmacro - -; Macro to get the address of a *local* variable that is global to -; a single module in a manner that will work correctly when compiled -; into a Linux shared library. Note that this will *not* work for -; variables that are defined as global to all modules. For that -; use the LEA_G macro - -%macro LEA_L 2 -%ifdef __PIC__ - get_GOT %1 - lea %1,[%1+%2 wrt ..gotoff] -%else - lea %1,[%2] -%endif -%endmacro - -; Same macro as above but for global variables public to *all* -; modules. - -%macro LEA_G 2 -%ifdef __PIC__ - get_GOT %1 - mov %1,[%1+%2 wrt ..got] -%else - lea %1,[%2] -%endif -%endmacro - -; macros to declare assembler function stubs for function structures - -%imacro BEGIN_STUBS_DEF 2 -begdataseg _STUBS -%ifdef __NOU_VAR__ -extern %1 -%define STUBS_START %1 -%else -extern _%1 -%define STUBS_START _%1 -%endif -enddataseg _STUBS -begcodeseg _STUBS -%assign off %2 -%endmacro - -%imacro DECLARE_STUB 1 -%ifdef __PIC__ - global %1:function -%1: - get_GOT eax - mov eax,[eax+STUBS_START wrt ..got] - jmp [eax+off] -%else -%ifdef __NOU__ - global %1 -%1: -%else - global _%1 -_%1: -%endif - jmp [DWORD STUBS_START+off] -%endif -%assign off off+4 -%endmacro - -%imacro SKIP_STUB 1 -%assign off off+4 -%endmacro - -%imacro DECLARE_STDCALL 2 -%ifdef STDCALL_MANGLE - global _%1@%2 -_%1@%2: -%else -%ifdef STDCALL_USCORE - global _%1 -_%1: -%else - global %1 -%1: -%endif -%endif - jmp [DWORD STUBS_START+off] -%assign off off+4 -%endmacro - -%imacro END_STUBS_DEF 0 -endcodeseg _STUBS -%endmacro - -; macros to declare assembler import stubs for binary loadable drivers - -%imacro BEGIN_IMPORTS_DEF 1 -BEGIN_STUBS_DEF %1,4 -%endmacro - -%imacro DECLARE_IMP 2 -DECLARE_STUB %1 -%endmacro - -%imacro SKIP_IMP 2 -SKIP_STUB %1 -%endmacro - -%imacro SKIP_IMP2 1 -DECLARE_STUB %1 -%endmacro - -%imacro SKIP_IMP3 1 -SKIP_STUB %1 -%endmacro - -%imacro END_IMPORTS_DEF 0 -END_STUBS_DEF -%endmacro - -else ; __NASM_MAJOR__ - -;============================================================================ -; Macro package when compiling with TASM. -;============================================================================ - -; Turn off underscores for globals if disabled for all externals - -ifdef __NOU__ -__NOU_VAR__ = 1 -endif - -; Define the __WINDOWS__ symbol if we are compiling for any Windows -; environment - -ifdef __WINDOWS16__ -__WINDOWS__ = 1 -endif -ifdef __WINDOWS32__ -__WINDOWS__ = 1 -__WINDOWS32_386__ = 1 -endif -ifdef __WIN386__ -__WINDOWS__ = 1 -__WINDOWS32_386__ = 1 -endif -ifdef __VXD__ -__WINDOWS__ = 1 -__WINDOWS32_386__ = 1 - MASM - .386 - NO_SEGMENTS = 1 - include vmm.inc ; IGNORE DEPEND - include vsegment.inc ; IGNORE DEPEND - IDEAL -endif - -; Macros for accessing 'generic' registers - -ifdef __FLAT__ - _ax EQU eax ; EAX is used for accumulator - _bx EQU ebx ; EBX is used for accumulator - _cx EQU ecx ; ECX is used for looping - _dx EQU edx ; EDX is used for data register - _si EQU esi ; ESI is the source index register - _di EQU edi ; EDI is the destination index register - _bp EQU ebp ; EBP is used for base pointer register - _sp EQU esp ; ESP is used for stack pointer register - _es EQU ; ES and DS are the same in 32 bit PM - typedef UCHAR BYTE ; Size of a character - typedef USHORT WORD ; Size of a short - typedef UINT DWORD ; Size of an integer - typedef ULONG DWORD ; Size of a long - typedef BOOL DWORD ; Size of a boolean - typedef DPTR DWORD ; Size of a data pointer - typedef FDPTR FWORD ; Size of a far data pointer - typedef NDPTR DWORD ; Size of a near data pointer - typedef CPTR DWORD ; Size of a code pointer - typedef FCPTR FWORD ; Size of a far code pointer - typedef NCPTR DWORD ; Size of a near code pointer - typedef DUINT DWORD ; Declare a integer variable - FPTR EQU NEAR ; Distance for function pointers - intsize = 4 ; Size of an integer - flatmodel = 1 ; This is a flat memory model - P386 ; Turn on 386 code generation - MODEL FLAT ; Set up for 32 bit simplified FLAT model -else - _ax EQU ax ; AX is used for accumulator - _bx EQU bx ; BX is used for accumulator - _cx EQU cx ; CX is used for looping - _dx EQU dx ; DX is used for data register - _si EQU si ; SI is the source index register - _di EQU di ; DI is the destination index register - _bp EQU bp ; BP is used for base pointer register - _sp EQU sp ; SP is used for stack pointer register - _es EQU es: ; ES is used for segment override - typedef UCHAR BYTE ; Size of a character - typedef USHORT WORD ; Size of a short - typedef UINT WORD ; Size of an integer - typedef ULONG DWORD ; Size of a long - typedef BOOL WORD ; Size of a boolean - typedef DPTR DWORD ; Size of a data pointer - typedef FDPTR DWORD ; Size of a far data pointer - typedef NDPTR WORD ; Size of a near data pointer - typedef CPTR DWORD ; Size of a code pointer - typedef FCPTR DWORD ; Size of a far code pointer - typedef NCPTR WORD ; Size of a near code pointer - typedef DUINT WORD ; Declare a integer variable - FPTR EQU FAR ; Distance for function pointers - intsize = 2 ; Size of an integer - P386 ; Turn on 386 code generation -endif - invert EQU not - -; Provide a typedef for real floating point numbers - -ifdef DOUBLE -typedef REAL QWORD -typedef DREAL QWORD -else -typedef REAL DWORD -typedef DREAL DWORD -endif - -; Macros to access the floating point stack registers to convert them -; from NASM style to TASM style - -st0 EQU st(0) -st1 EQU st(1) -st2 EQU st(2) -st3 EQU st(3) -st4 EQU st(4) -st5 EQU st(5) -st6 EQU st(6) -st7 EQU st(7) -st8 EQU st(8) - -; Boolean truth values (same as those in debug.h) - -ifndef __VXD__ -False = 0 -True = 1 -No = 0 -Yes = 1 -Yes = 1 -endif - -; Macros for the _DATA data segment. This segment contains initialised data. - -MACRO begdataseg name -ifdef __VXD__ - MASM -VXD_LOCKED_DATA_SEG - IDEAL -else -ifdef flatmodel - DATASEG -else -SEGMENT _DATA DWORD PUBLIC USE16 'DATA' -endif -endif -ENDM - -MACRO enddataseg name -ifdef __VXD__ - MASM -VXD_LOCKED_DATA_ENDS - IDEAL -else -ifndef flatmodel -ENDS _DATA -endif -endif -ENDM - -; Macro for the main code segment. - -MACRO begcodeseg name -ifdef __VXD__ - MASM -VXD_LOCKED_CODE_SEG - IDEAL -else -ifdef flatmodel - CODESEG - ASSUME CS:FLAT,DS:FLAT,SS:FLAT -else -SEGMENT &name&_TEXT PARA PUBLIC USE16 'CODE' - ASSUME CS:&name&_TEXT,DS:_DATA -endif -endif -ENDM - -; Macro for a near code segment - -MACRO begcodeseg_near -ifdef flatmodel - CODESEG - ASSUME CS:FLAT,DS:FLAT,SS:FLAT -else -SEGMENT _TEXT PARA PUBLIC USE16 'CODE' - ASSUME CS:_TEXT,DS:_DATA -endif -ENDM - -MACRO endcodeseg name -ifdef __VXD__ - MASM -VXD_LOCKED_CODE_ENDS - IDEAL -else -ifndef flatmodel -ENDS &name&_TEXT -endif -endif -ENDM - -MACRO endcodeseg_near -ifndef flatmodel -ENDS _TEXT -endif -ENDM - -; Macro to be invoked at the start of all modules to set up segments for -; later use. - -MACRO header name -begdataseg name -enddataseg name -ENDM - -; Macro for an extern C symbol. If the C compiler requires leading -; underscores, then the underscores are added to the symbol names, otherwise -; they are left off. The symbol name is referenced in the assembler code -; using the non-underscored symbol name. - -MACRO cextern name,size -ifdef __NOU_VAR__ - EXTRN name:size -else - EXTRN _&name&:size -name EQU _&name& -endif -ENDM - -MACRO cexternfunc name,size -ifdef __NOU__ - EXTRN name:size -else - EXTRN _&name&:size -name EQU _&name& -endif -ENDM - -MACRO stdexternfunc name,num_args,size -ifdef STDCALL_MANGLE - EXTRN _&name&@&num_args&:size -name EQU _&name&@&num_args -else - EXTRN name:size -endif -ENDM - -; Macro for a public C symbol. If the C compiler requires leading -; underscores, then the underscores are added to the symbol names, otherwise -; they are left off. The symbol name is referenced in the assembler code -; using the non-underscored symbol name. - -MACRO cpublic name -ifdef __NOU_VAR__ -name: - PUBLIC name -else -_&name&: - PUBLIC _&name& -name EQU _&name& -endif -ENDM - -; Macro for an global C symbol. If the C compiler requires leading -; underscores, then the underscores are added to the symbol names, otherwise -; they are left off. The symbol name is referenced in the assembler code -; using the non-underscored symbol name. - -MACRO cglobal name -ifdef __NOU_VAR__ - PUBLIC name -else - PUBLIC _&name& -name EQU _&name& -endif -ENDM - -; Macro for an global C function symbol. If the C compiler requires leading -; underscores, then the underscores are added to the symbol names, otherwise -; they are left off. The symbol name is referenced in the assembler code -; using the non-underscored symbol name. - -MACRO cglobalfunc name -ifdef __NOU__ - PUBLIC name -else - PUBLIC _&name& -name EQU _&name& -endif -ENDM - -; Macro to start a C callable function. This will be a far function for -; 16-bit code, and a near function for 32-bit code. - -MACRO cprocstatic name ; Set up model independant private proc -ifdef flatmodel -PROC name NEAR -else -PROC name FAR -endif -LocalSize = 0 -ENDM - -MACRO cprocstart name ; Set up model independant proc -ifdef flatmodel -ifdef __NOU__ -PROC name NEAR -else -PROC _&name& NEAR -endif -else -ifdef __NOU__ -PROC name FAR -else -PROC _&name& FAR -endif -endif -LocalSize = 0 - cglobalfunc name -ENDM - -MACRO cprocnear name ; Set up near proc -ifdef __NOU__ -PROC name NEAR -else -PROC _&name& NEAR -endif -LocalSize = 0 - cglobalfunc name -ENDM - -MACRO cprocfar name ; Set up far proc -ifdef __NOU__ -PROC name FAR -else -PROC _&name& FAR -endif -LocalSize = 0 - cglobalfunc name -ENDM - -MACRO cprocend ; End procedure macro -ENDP -ENDM - -; This macro sets up a procedure to be exported from a 16 bit DLL. Since the -; calling conventions are always _far _pascal for 16 bit DLL's, we actually -; rename this routine with an extra underscore with 'C' calling conventions -; and a small DLL stub will be provided by the high level code to call the -; assembler routine. - -MACRO cprocstartdll16 name -ifdef __WINDOWS16__ -cprocstart _&name& -else -cprocstart name -endif -ENDM - -; Macros for entering and exiting C callable functions. Note that we must -; always save and restore the SI and DI registers for C functions, and for -; 32 bit C functions we also need to save and restore EBX and clear the -; direction flag. - -MACRO save_c_regs -ifdef flatmodel - push ebx -endif - push _si - push _di -ENDM - -MACRO enter_c - push _bp - mov _bp,_sp - IFDIFI ,<0> - sub _sp,LocalSize - ENDIF - save_c_regs -ENDM - -MACRO restore_c_regs - pop _di - pop _si -ifdef flatmodel - pop ebx -endif -ENDM - -MACRO leave_c - restore_c_regs - cld - IFDIFI ,<0> - mov _sp,_bp - ENDIF - pop _bp -ENDM - -MACRO use_ebx -ifdef flatmodel - push ebx -endif -ENDM - -MACRO unuse_ebx -ifdef flatmodel - pop ebx -endif -ENDM - -; Macros for saving and restoring the value of DS,ES,FS,GS when it is to -; be used in assembly routines. This evaluates to nothing in the flat memory -; model, but is saves and restores DS in the large memory model. - -MACRO use_ds -ifndef flatmodel - push ds -endif -ENDM - -MACRO unuse_ds -ifndef flatmodel - pop ds -endif -ENDM - -MACRO use_es -ifndef flatmodel - push es -endif -ENDM - -MACRO unuse_es -ifndef flatmodel - pop es -endif -ENDM - -; Macros for loading the address of a data pointer into a segment and -; index register pair. The macro explicitly loads DS or ES in the 16 bit -; memory model, or it simply loads the offset into the register in the flat -; memory model since DS and ES always point to all addressable memory. You -; must use the correct _REG (ie: _BX) macros for documentation purposes. - -MACRO _lds reg, addr -ifdef flatmodel - mov reg,addr -else - lds reg,addr -endif -ENDM - -MACRO _les reg, addr -ifdef flatmodel - mov reg,addr -else - les reg,addr -endif -ENDM - -; Macros for adding and subtracting a value from registers. Two value are -; provided, one for 16 bit modes and another for 32 bit modes (the extended -; register is used in 32 bit modes). - -MACRO _add reg, val16, val32 -ifdef flatmodel - add e®&, val32 -else - add reg, val16 -endif -ENDM - -MACRO _sub reg, val16, val32 -ifdef flatmodel - sub e®&, val32 -else - sub reg, val16 -endif -ENDM - -; Macro to clear the high order word for the 32 bit extended registers. -; This is used to convert an unsigned 16 bit value to an unsigned 32 bit -; value, and will evaluate to nothing in 16 bit modes. - -MACRO clrhi reg -ifdef flatmodel - movzx e®&,reg -endif -ENDM - -MACRO sgnhi reg -ifdef flatmodel - movsx e®&,reg -endif -ENDM - -; Macro to load an extended register with an integer value in either mode - -MACRO loadint reg,val -ifdef flatmodel - mov e®&,val -else - xor e®&,e®& - mov reg,val -endif -ENDM - -; Macros to load and store integer values with string instructions - -MACRO LODSINT -ifdef flatmodel - lodsd -else - lodsw -endif -ENDM - -MACRO STOSINT -ifdef flatmodel - stosd -else - stosw -endif -ENDM - -; Macros to provide resb, resw, resd compatibility with NASM - -MACRO dclb count -db count dup (0) -ENDM - -MACRO dclw count -dw count dup (0) -ENDM - -MACRO dcld count -dd count dup (0) -ENDM - -; Macros to provide resb, resw, resd compatibility with NASM - -MACRO resb count -db count dup (?) -ENDM - -MACRO resw count -dw count dup (?) -ENDM - -MACRO resd count -dd count dup (?) -ENDM - -; Macros to declare assembler stubs for function structures - -MACRO BEGIN_STUBS_DEF name, firstOffset -begdataseg _STUBS -ifdef __NOU_VAR__ - EXTRN name:DWORD -STUBS_START = name -else - EXTRN _&name&:DWORD -name EQU _&name& -STUBS_START = _&name -endif -enddataseg _STUBS -begcodeseg _STUBS -off = firstOffset -ENDM - -MACRO DECLARE_STUB name -ifdef __NOU__ -name: - PUBLIC name -else -_&name: - PUBLIC _&name -endif - jmp [DWORD STUBS_START+off] -off = off + 4 -ENDM - -MACRO SKIP_STUB name -off = off + 4 -ENDM - -MACRO DECLARE_STDCALL name,num_args -ifdef STDCALL_MANGLE -_&name&@&num_args&: - PUBLIC _&name&@&num_args& -else -name: - PUBLIC name -endif - jmp [DWORD STUBS_START+off] -off = off + 4 -ENDM - -MACRO END_STUBS_DEF -endcodeseg _STUBS -ENDM - -MACRO BEGIN_IMPORTS_DEF name -BEGIN_STUBS_DEF name,4 -ENDM - -ifndef LOCAL_DECLARE_IMP -MACRO DECLARE_IMP name, numArgs -DECLARE_STUB name -ENDM - -MACRO SKIP_IMP name -SKIP_STUB name -ENDM - -MACRO SKIP_IMP2 name, numArgs -DECLARE_STUB name -ENDM - -MACRO SKIP_IMP3 name -SKIP_STUB name -ENDM -endif - -MACRO END_IMPORTS_DEF -END_STUBS_DEF -ENDM - -MACRO LEA_L reg,name - lea reg,[name] -ENDM - -MACRO LEA_G reg,name - lea reg,[name] -ENDM - -endif - diff --git a/board/MAI/bios_emulator/scitech/include/x86emu.h b/board/MAI/bios_emulator/scitech/include/x86emu.h deleted file mode 100644 index 1d87d4e57f..0000000000 --- a/board/MAI/bios_emulator/scitech/include/x86emu.h +++ /dev/null @@ -1,194 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Header file for public specific functions. -* Any application linking against us should only -* include this header -* -****************************************************************************/ - -#ifndef __X86EMU_X86EMU_H -#define __X86EMU_X86EMU_H - -#ifdef SCITECH -#include "scitech.h" -#define X86API _ASMAPI -#define X86APIP _ASMAPIP -typedef int X86EMU_pioAddr; -#else -#include "x86emu/types.h" -#define X86API -#define X86APIP * -#endif -#include "x86emu/regs.h" - -/*---------------------- Macros and type definitions ----------------------*/ - -#pragma pack(1) - -/**************************************************************************** -REMARKS: -Data structure containing ponters to programmed I/O functions used by the -emulator. This is used so that the user program can hook all programmed -I/O for the emulator to handled as necessary by the user program. By -default the emulator contains simple functions that do not do access the -hardware in any way. To allow the emualtor access the hardware, you will -need to override the programmed I/O functions using the X86EMU_setupPioFuncs -function. - -HEADER: -x86emu.h - -MEMBERS: -inb - Function to read a byte from an I/O port -inw - Function to read a word from an I/O port -inl - Function to read a dword from an I/O port -outb - Function to write a byte to an I/O port -outw - Function to write a word to an I/O port -outl - Function to write a dword to an I/O port -****************************************************************************/ -typedef struct { - u8 (X86APIP inb)(X86EMU_pioAddr addr); - u16 (X86APIP inw)(X86EMU_pioAddr addr); - u32 (X86APIP inl)(X86EMU_pioAddr addr); - void (X86APIP outb)(X86EMU_pioAddr addr, u8 val); - void (X86APIP outw)(X86EMU_pioAddr addr, u16 val); - void (X86APIP outl)(X86EMU_pioAddr addr, u32 val); - } X86EMU_pioFuncs; - -/**************************************************************************** -REMARKS: -Data structure containing ponters to memory access functions used by the -emulator. This is used so that the user program can hook all memory -access functions as necessary for the emulator. By default the emulator -contains simple functions that only access the internal memory of the -emulator. If you need specialised functions to handle access to different -types of memory (ie: hardware framebuffer accesses and BIOS memory access -etc), you will need to override this using the X86EMU_setupMemFuncs -function. - -HEADER: -x86emu.h - -MEMBERS: -rdb - Function to read a byte from an address -rdw - Function to read a word from an address -rdl - Function to read a dword from an address -wrb - Function to write a byte to an address -wrw - Function to write a word to an address -wrl - Function to write a dword to an address -****************************************************************************/ -typedef struct { - u8 (X86APIP rdb)(u32 addr); - u16 (X86APIP rdw)(u32 addr); - u32 (X86APIP rdl)(u32 addr); - void (X86APIP wrb)(u32 addr, u8 val); - void (X86APIP wrw)(u32 addr, u16 val); - void (X86APIP wrl)(u32 addr, u32 val); - } X86EMU_memFuncs; - -/**************************************************************************** - Here are the default memory read and write - function in case they are needed as fallbacks. -***************************************************************************/ -extern u8 X86API rdb(u32 addr); -extern u16 X86API rdw(u32 addr); -extern u32 X86API rdl(u32 addr); -extern void X86API wrb(u32 addr, u8 val); -extern void X86API wrw(u32 addr, u16 val); -extern void X86API wrl(u32 addr, u32 val); - -#pragma pack() - -/*--------------------- type definitions -----------------------------------*/ - -typedef void (X86APIP X86EMU_intrFuncs)(int num); -extern X86EMU_intrFuncs _X86EMU_intrTab[256]; - -/*-------------------------- Function Prototypes --------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -void X86EMU_setupMemFuncs(X86EMU_memFuncs *funcs); -void X86EMU_setupPioFuncs(X86EMU_pioFuncs *funcs); -void X86EMU_setupIntrFuncs(X86EMU_intrFuncs funcs[]); -void X86EMU_prepareForInt(int num); - -/* decode.c */ - -void X86EMU_exec(void); -void X86EMU_halt_sys(void); - -#ifdef DEBUG -#define HALT_SYS() \ - printk("halt_sys: file %s, line %d\n", __FILE__, __LINE__), \ - X86EMU_halt_sys() -#else -#define HALT_SYS() X86EMU_halt_sys() -#endif - -/* Debug options */ - -#define DEBUG_DECODE_F 0x0001 /* print decoded instruction */ -#define DEBUG_TRACE_F 0x0002 /* dump regs before/after execution */ -#define DEBUG_STEP_F 0x0004 -#define DEBUG_DISASSEMBLE_F 0x0008 -#define DEBUG_BREAK_F 0x0010 -#define DEBUG_SVC_F 0x0020 -#define DEBUG_SAVE_CS_IP 0x0040 -#define DEBUG_FS_F 0x0080 -#define DEBUG_PROC_F 0x0100 -#define DEBUG_SYSINT_F 0x0200 /* bios system interrupts. */ -#define DEBUG_TRACECALL_F 0x0400 -#define DEBUG_INSTRUMENT_F 0x0800 -#define DEBUG_MEM_TRACE_F 0x1000 -#define DEBUG_IO_TRACE_F 0x2000 -#define DEBUG_TRACECALL_REGS_F 0x4000 -#define DEBUG_DECODE_NOPRINT_F 0x8000 -#define DEBUG_EXIT 0x10000 -#define DEBUG_SYS_F (DEBUG_SVC_F|DEBUG_FS_F|DEBUG_PROC_F) - -void X86EMU_trace_regs(void); -void X86EMU_trace_xregs(void); -void X86EMU_dump_memory(u16 seg, u16 off, u32 amt); -int X86EMU_trace_on(void); -int X86EMU_trace_off(void); - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif - -#endif /* __X86EMU_X86EMU_H */ diff --git a/board/MAI/bios_emulator/scitech/include/x86emu/fpu_regs.h b/board/MAI/bios_emulator/scitech/include/x86emu/fpu_regs.h deleted file mode 100644 index 777b03cd71..0000000000 --- a/board/MAI/bios_emulator/scitech/include/x86emu/fpu_regs.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Header file for FPU register definitions. -* -****************************************************************************/ - -#ifndef __X86EMU_FPU_REGS_H -#define __X86EMU_FPU_REGS_H - -#ifdef X86_FPU_SUPPORT - -#pragma pack(1) - -/* Basic 8087 register can hold any of the following values: */ - -union x86_fpu_reg_u { - s8 tenbytes[10]; - double dval; - float fval; - s16 sval; - s32 lval; - }; - -struct x86_fpu_reg { - union x86_fpu_reg_u reg; - char tag; - }; - -/* - * Since we are not going to worry about the problems of aliasing - * registers, every time a register is modified, its result type is - * set in the tag fields for that register. If some operation - * attempts to access the type in a way inconsistent with its current - * storage format, then we flag the operation. If common, we'll - * attempt the conversion. - */ - -#define X86_FPU_VALID 0x80 -#define X86_FPU_REGTYP(r) ((r) & 0x7F) - -#define X86_FPU_WORD 0x0 -#define X86_FPU_SHORT 0x1 -#define X86_FPU_LONG 0x2 -#define X86_FPU_FLOAT 0x3 -#define X86_FPU_DOUBLE 0x4 -#define X86_FPU_LDBL 0x5 -#define X86_FPU_BSD 0x6 - -#define X86_FPU_STKTOP 0 - -struct x86_fpu_registers { - struct x86_fpu_reg x86_fpu_stack[8]; - int x86_fpu_flags; - int x86_fpu_config; /* rounding modes, etc. */ - short x86_fpu_tos, x86_fpu_bos; - }; - -#pragma pack() - -/* - * There are two versions of the following macro. - * - * One version is for opcode D9, for which there are more than 32 - * instructions encoded in the second byte of the opcode. - * - * The other version, deals with all the other 7 i87 opcodes, for - * which there are only 32 strings needed to describe the - * instructions. - */ - -#endif /* X86_FPU_SUPPORT */ - -#ifdef DEBUG -# define DECODE_PRINTINSTR32(t,mod,rh,rl) \ - DECODE_PRINTF(t[(mod<<3)+(rh)]); -# define DECODE_PRINTINSTR256(t,mod,rh,rl) \ - DECODE_PRINTF(t[(mod<<6)+(rh<<3)+(rl)]); -#else -# define DECODE_PRINTINSTR32(t,mod,rh,rl) -# define DECODE_PRINTINSTR256(t,mod,rh,rl) -#endif - -#endif /* __X86EMU_FPU_REGS_H */ diff --git a/board/MAI/bios_emulator/scitech/include/x86emu/regs.h b/board/MAI/bios_emulator/scitech/include/x86emu/regs.h deleted file mode 100644 index a12017b00f..0000000000 --- a/board/MAI/bios_emulator/scitech/include/x86emu/regs.h +++ /dev/null @@ -1,331 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Header file for x86 register definitions. -* -****************************************************************************/ - -#ifndef __X86EMU_REGS_H -#define __X86EMU_REGS_H - -/*---------------------- Macros and type definitions ----------------------*/ - -#pragma pack(1) - -/* - * General EAX, EBX, ECX, EDX type registers. Note that for - * portability, and speed, the issue of byte swapping is not addressed - * in the registers. All registers are stored in the default format - * available on the host machine. The only critical issue is that the - * registers should line up EXACTLY in the same manner as they do in - * the 386. That is: - * - * EAX & 0xff === AL - * EAX & 0xffff == AX - * - * etc. The result is that alot of the calculations can then be - * done using the native instruction set fully. - */ - -#ifdef __BIG_ENDIAN__ - -typedef struct { - u32 e_reg; - } I32_reg_t; - -typedef struct { - u16 filler0, x_reg; - } I16_reg_t; - -typedef struct { - u8 filler0, filler1, h_reg, l_reg; - } I8_reg_t; - -#else /* !__BIG_ENDIAN__ */ - -typedef struct { - u32 e_reg; - } I32_reg_t; - -typedef struct { - u16 x_reg; - } I16_reg_t; - -typedef struct { - u8 l_reg, h_reg; - } I8_reg_t; - -#endif /* BIG_ENDIAN */ - -typedef union { - I32_reg_t I32_reg; - I16_reg_t I16_reg; - I8_reg_t I8_reg; - } i386_general_register; - -struct i386_general_regs { - i386_general_register A, B, C, D; - }; - -typedef struct i386_general_regs Gen_reg_t; - -struct i386_special_regs { - i386_general_register SP, BP, SI, DI, IP; - u32 FLAGS; - }; - -/* - * Segment registers here represent the 16 bit quantities - * CS, DS, ES, SS. - */ - -struct i386_segment_regs { - u16 CS, DS, SS, ES, FS, GS; - }; - -/* 8 bit registers */ -#define R_AH gen.A.I8_reg.h_reg -#define R_AL gen.A.I8_reg.l_reg -#define R_BH gen.B.I8_reg.h_reg -#define R_BL gen.B.I8_reg.l_reg -#define R_CH gen.C.I8_reg.h_reg -#define R_CL gen.C.I8_reg.l_reg -#define R_DH gen.D.I8_reg.h_reg -#define R_DL gen.D.I8_reg.l_reg - -/* 16 bit registers */ -#define R_AX gen.A.I16_reg.x_reg -#define R_BX gen.B.I16_reg.x_reg -#define R_CX gen.C.I16_reg.x_reg -#define R_DX gen.D.I16_reg.x_reg - -/* 32 bit extended registers */ -#define R_EAX gen.A.I32_reg.e_reg -#define R_EBX gen.B.I32_reg.e_reg -#define R_ECX gen.C.I32_reg.e_reg -#define R_EDX gen.D.I32_reg.e_reg - -/* special registers */ -#define R_SP spc.SP.I16_reg.x_reg -#define R_BP spc.BP.I16_reg.x_reg -#define R_SI spc.SI.I16_reg.x_reg -#define R_DI spc.DI.I16_reg.x_reg -#define R_IP spc.IP.I16_reg.x_reg -#define R_FLG spc.FLAGS - -/* special registers */ -#define R_SP spc.SP.I16_reg.x_reg -#define R_BP spc.BP.I16_reg.x_reg -#define R_SI spc.SI.I16_reg.x_reg -#define R_DI spc.DI.I16_reg.x_reg -#define R_IP spc.IP.I16_reg.x_reg -#define R_FLG spc.FLAGS - -/* special registers */ -#define R_ESP spc.SP.I32_reg.e_reg -#define R_EBP spc.BP.I32_reg.e_reg -#define R_ESI spc.SI.I32_reg.e_reg -#define R_EDI spc.DI.I32_reg.e_reg -#define R_EIP spc.IP.I32_reg.e_reg -#define R_EFLG spc.FLAGS - -/* segment registers */ -#define R_CS seg.CS -#define R_DS seg.DS -#define R_SS seg.SS -#define R_ES seg.ES -#define R_FS seg.FS -#define R_GS seg.GS - -/* flag conditions */ -#define FB_CF 0x0001 /* CARRY flag */ -#define FB_PF 0x0004 /* PARITY flag */ -#define FB_AF 0x0010 /* AUX flag */ -#define FB_ZF 0x0040 /* ZERO flag */ -#define FB_SF 0x0080 /* SIGN flag */ -#define FB_TF 0x0100 /* TRAP flag */ -#define FB_IF 0x0200 /* INTERRUPT ENABLE flag */ -#define FB_DF 0x0400 /* DIR flag */ -#define FB_OF 0x0800 /* OVERFLOW flag */ - -/* 80286 and above always have bit#1 set */ -#define F_ALWAYS_ON (0x0002) /* flag bits always on */ - -/* - * Define a mask for only those flag bits we will ever pass back - * (via PUSHF) - */ -#define F_MSK (FB_CF|FB_PF|FB_AF|FB_ZF|FB_SF|FB_TF|FB_IF|FB_DF|FB_OF) - -/* following bits masked in to a 16bit quantity */ - -#define F_CF 0x0001 /* CARRY flag */ -#define F_PF 0x0004 /* PARITY flag */ -#define F_AF 0x0010 /* AUX flag */ -#define F_ZF 0x0040 /* ZERO flag */ -#define F_SF 0x0080 /* SIGN flag */ -#define F_TF 0x0100 /* TRAP flag */ -#define F_IF 0x0200 /* INTERRUPT ENABLE flag */ -#define F_DF 0x0400 /* DIR flag */ -#define F_OF 0x0800 /* OVERFLOW flag */ - -#define TOGGLE_FLAG(flag) (M.x86.R_FLG ^= (flag)) -#define SET_FLAG(flag) (M.x86.R_FLG |= (flag)) -#define CLEAR_FLAG(flag) (M.x86.R_FLG &= ~(flag)) -#define ACCESS_FLAG(flag) (M.x86.R_FLG & (flag)) -#define CLEARALL_FLAG(m) (M.x86.R_FLG = 0) - -#define CONDITIONAL_SET_FLAG(COND,FLAG) \ - if (COND) SET_FLAG(FLAG); else CLEAR_FLAG(FLAG) - -#define F_PF_CALC 0x010000 /* PARITY flag has been calced */ -#define F_ZF_CALC 0x020000 /* ZERO flag has been calced */ -#define F_SF_CALC 0x040000 /* SIGN flag has been calced */ - -#define F_ALL_CALC 0xff0000 /* All have been calced */ - -/* - * Emulator machine state. - * Segment usage control. - */ -#define SYSMODE_SEG_DS_SS 0x00000001 -#define SYSMODE_SEGOVR_CS 0x00000002 -#define SYSMODE_SEGOVR_DS 0x00000004 -#define SYSMODE_SEGOVR_ES 0x00000008 -#define SYSMODE_SEGOVR_FS 0x00000010 -#define SYSMODE_SEGOVR_GS 0x00000020 -#define SYSMODE_SEGOVR_SS 0x00000040 -#define SYSMODE_PREFIX_REPE 0x00000080 -#define SYSMODE_PREFIX_REPNE 0x00000100 -#define SYSMODE_PREFIX_DATA 0x00000200 -#define SYSMODE_PREFIX_ADDR 0x00000400 -#define SYSMODE_INTR_PENDING 0x10000000 -#define SYSMODE_EXTRN_INTR 0x20000000 -#define SYSMODE_HALTED 0x40000000 - -#define SYSMODE_SEGMASK (SYSMODE_SEG_DS_SS | \ - SYSMODE_SEGOVR_CS | \ - SYSMODE_SEGOVR_DS | \ - SYSMODE_SEGOVR_ES | \ - SYSMODE_SEGOVR_FS | \ - SYSMODE_SEGOVR_GS | \ - SYSMODE_SEGOVR_SS) -#define SYSMODE_CLRMASK (SYSMODE_SEG_DS_SS | \ - SYSMODE_SEGOVR_CS | \ - SYSMODE_SEGOVR_DS | \ - SYSMODE_SEGOVR_ES | \ - SYSMODE_SEGOVR_FS | \ - SYSMODE_SEGOVR_GS | \ - SYSMODE_SEGOVR_SS | \ - SYSMODE_PREFIX_DATA | \ - SYSMODE_PREFIX_ADDR) - -#define INTR_SYNCH 0x1 -#define INTR_ASYNCH 0x2 -#define INTR_HALTED 0x4 - -typedef struct { - struct i386_general_regs gen; - struct i386_special_regs spc; - struct i386_segment_regs seg; - /* - * MODE contains information on: - * REPE prefix 2 bits repe,repne - * SEGMENT overrides 5 bits normal,DS,SS,CS,ES - * Delayed flag set 3 bits (zero, signed, parity) - * reserved 6 bits - * interrupt # 8 bits instruction raised interrupt - * BIOS video segregs 4 bits - * Interrupt Pending 1 bits - * Extern interrupt 1 bits - * Halted 1 bits - */ - long mode; - u8 intno; - volatile int intr; /* mask of pending interrupts */ - int debug; -#ifdef DEBUG - int check; - u16 saved_ip; - u16 saved_cs; - int enc_pos; - int enc_str_pos; - char decode_buf[32]; /* encoded byte stream */ - char decoded_buf[256]; /* disassembled strings */ -#endif - } X86EMU_regs; - -/**************************************************************************** -REMARKS: -Structure maintaining the emulator machine state. - -MEMBERS: -x86 - X86 registers -mem_base - Base real mode memory for the emulator -mem_size - Size of the real mode memory block for the emulator -****************************************************************************/ -typedef struct { - X86EMU_regs x86; - unsigned long mem_base; - unsigned long mem_size; - void* private; - } X86EMU_sysEnv; - -#pragma pack() - -/*----------------------------- Global Variables --------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -/* Global emulator machine state. - * - * We keep it global to avoid pointer dereferences in the code for speed. - */ - -extern X86EMU_sysEnv _X86EMU_env; -#define M _X86EMU_env - -/*-------------------------- Function Prototypes --------------------------*/ - -/* Function to log information at runtime */ - -/*void printk(const char *fmt, ...); */ - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif - -#endif /* __X86EMU_REGS_H */ diff --git a/board/MAI/bios_emulator/scitech/include/x86emu/types.h b/board/MAI/bios_emulator/scitech/include/x86emu/types.h deleted file mode 100644 index 0a17c547ee..0000000000 --- a/board/MAI/bios_emulator/scitech/include/x86emu/types.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Header file for x86 emulator type definitions. -* -****************************************************************************/ - -#ifndef __X86EMU_TYPES_H -#define __X86EMU_TYPES_H - -#include - -/*---------------------- Macros and type definitions ----------------------*/ - -/* Currently only for Linux/32bit */ -#if defined(__GNUC__) && !defined(NO_LONG_LONG) -#define __HAS_LONG_LONG__ -#endif - -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -#ifdef __HAS_LONG_LONG__ -typedef unsigned long long u64; -#endif - -typedef char s8; -typedef short s16; -typedef long s32; -#ifdef __HAS_LONG_LONG__ -typedef long long s64; -#endif - -/*typedef unsigned int uint;*/ -typedef int sint; - -typedef u16 X86EMU_pioAddr; - -#endif /* __X86EMU_TYPES_H */ diff --git a/board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/glibc.so/readme.txt b/board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/glibc.so/readme.txt deleted file mode 100644 index 0d87effa99..0000000000 --- a/board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/glibc.so/readme.txt +++ /dev/null @@ -1 +0,0 @@ -This file is just to ensure that the directory is created. diff --git a/board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/glibc/readme.txt b/board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/glibc/readme.txt deleted file mode 100644 index 0d87effa99..0000000000 --- a/board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/glibc/readme.txt +++ /dev/null @@ -1 +0,0 @@ -This file is just to ensure that the directory is created. diff --git a/board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/libc.so/readme.txt b/board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/libc.so/readme.txt deleted file mode 100644 index 0d87effa99..0000000000 --- a/board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/libc.so/readme.txt +++ /dev/null @@ -1 +0,0 @@ -This file is just to ensure that the directory is created. diff --git a/board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/libc/readme.txt b/board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/libc/readme.txt deleted file mode 100644 index 0d87effa99..0000000000 --- a/board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/libc/readme.txt +++ /dev/null @@ -1 +0,0 @@ -This file is just to ensure that the directory is created. diff --git a/board/MAI/bios_emulator/scitech/lib/release/linux/gcc/glibc.so/readme.txt b/board/MAI/bios_emulator/scitech/lib/release/linux/gcc/glibc.so/readme.txt deleted file mode 100644 index 0d87effa99..0000000000 --- a/board/MAI/bios_emulator/scitech/lib/release/linux/gcc/glibc.so/readme.txt +++ /dev/null @@ -1 +0,0 @@ -This file is just to ensure that the directory is created. diff --git a/board/MAI/bios_emulator/scitech/lib/release/linux/gcc/glibc/readme.txt b/board/MAI/bios_emulator/scitech/lib/release/linux/gcc/glibc/readme.txt deleted file mode 100644 index 0d87effa99..0000000000 --- a/board/MAI/bios_emulator/scitech/lib/release/linux/gcc/glibc/readme.txt +++ /dev/null @@ -1 +0,0 @@ -This file is just to ensure that the directory is created. diff --git a/board/MAI/bios_emulator/scitech/lib/release/linux/gcc/libc.so/readme.txt b/board/MAI/bios_emulator/scitech/lib/release/linux/gcc/libc.so/readme.txt deleted file mode 100644 index 0d87effa99..0000000000 --- a/board/MAI/bios_emulator/scitech/lib/release/linux/gcc/libc.so/readme.txt +++ /dev/null @@ -1 +0,0 @@ -This file is just to ensure that the directory is created. diff --git a/board/MAI/bios_emulator/scitech/lib/release/linux/gcc/libc/readme.txt b/board/MAI/bios_emulator/scitech/lib/release/linux/gcc/libc/readme.txt deleted file mode 100644 index 0d87effa99..0000000000 --- a/board/MAI/bios_emulator/scitech/lib/release/linux/gcc/libc/readme.txt +++ /dev/null @@ -1 +0,0 @@ -This file is just to ensure that the directory is created. diff --git a/board/MAI/bios_emulator/scitech/makedefs/bc16.mk b/board/MAI/bios_emulator/scitech/makedefs/bc16.mk deleted file mode 100644 index aa4fe76a40..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/bc16.mk +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Borland C++ 4.x 16 bit version. Supports 16 bit DOS, -# DPMI16 DOS extender and 16 bit Windows development. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Import enivornment variables that we use -.IMPORT .IGNORE : USE_WIN16 USE_BC5 BC_LIBBASE USE_WIN95 - -# Default commands for compiling, assembling linking and archiving - CC := bcc - CFLAGS := -ml -H=bcc.sym -i60 -d -dc -4 -f287 -.IF $(USE_TASM32) - AS := tasm32 -.ELIF $(USE_TASMX) - AS := tasmx -.ELSE - AS := tasm -.ENDIF - ASFLAGS := /t /mx /m /iINCLUDE /iINCLUDE /i$(SCITECH)\INCLUDE - LD := bclink tlink.exe - LDFLAGS := -c - RC := brc - RCFLAGS := -.IF $(USE_BC5) -.IF $(USE_WIN95) - WIN_VERSION := -V4.0 -.ENDIF -.ENDIF - LIBR := tlib - LIBFLAGS := /C /P32 - ILIB := implib - ILIBFLAGS := -c - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -v - LDFLAGS += -v - ASFLAGS += /zi - LIBFLAGS += /P128 -.ELSE - LDFLAGS += -x - ASFLAGS += /q -.END - -# Optionally turn on optimisations -.IF $(OPT) - CFLAGS += -O2 -k- -.ELIF $(OPT_SIZE) - CFLAGS += -O1 -k- -.END - -# Optionally turn on direct i387 FPU instructions - -.IF $(FPU) - CFLAGS += -DFPU387 - ASFLAGS += -DFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -DBETA -.END - -# Optionally compile as Win16 -.IF $(USE_WIN16) -.IF $(BUILD_DLL) - CFLAGS += -WD -Fs- -DBUILD_DLL - ASFLAGS += -DBUILD_DLL -.ELSE - CFLAGS += -W -Fs- -.ENDIF - DEF_LIBS := import.lib mathwl.lib cwl.lib - DX_ASFLAGS += -D__WINDOWS16__ - LIB_OS = WIN16 -.ELSE - USE_REALDOS := 1 - DEF_LIBS := mathl.lib fp87.lib cl.lib - LIB_OS = DOS16 -.END - -# Place to look for PMODE library files - -.IF $(USE_DPMI16) -PMLIB := dpmi16\pm.lib -.ELSE -PMLIB := pm.lib -.END - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_BASE := $(LIB_BASE_DIR)\$(LIB_OS)\$(BC_LIBBASE) - LIB_DEST := $(LIB_BASE) - -# Define which file contains our rules - - RULES_MAK := bc16.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/bc3.mk b/board/MAI/bios_emulator/scitech/makedefs/bc3.mk deleted file mode 100644 index 133d80edf7..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/bc3.mk +++ /dev/null @@ -1,102 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Borland C++ 3.1 version. Supports 16 bit DOS development. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Default commands for compiling, assembling linking and archiving - CC := bcc - CFLAGS := -ml -H=bcc.sym -i60 -d -.IF $(USE_TASM32) - AS := tasm32 -.ELIF $(USE_TASMX) - AS := tasmx -.ELSE - AS := tasm -.ENDIF - ASFLAGS := /t /mx /m /iINCLUDE /i$(SCITECH)\INCLUDE - LD := bclink tlink.exe - LDFLAGS := -c - LIB := tlib - LIBFLAGS := /C - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -v - LDFLAGS += -v - ASFLAGS += /zi - LIBFLAGS += /P128 -.ELSE - LDFLAGS += -x - ASFLAGS += /q -.END - -# Optionally turn on optimisations -.IF $(OPT) - CFLAGS += -3 -O2 -.ELIF $(OPT_SIZE) - CFLAGS += -3 -O1 -.END - -# Optionally turn on direct i387 FPU instructions - -.IF $(FPU) - CFLAGS += -f287 -DFPU387 - ASFLAGS += -DFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -DBETA -.END - USE_REALDOS := 1 - -# Define the default libraries to link with - DEF_LIBS := mathl.lib cl.lib - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_DEST := $(LIB_BASE_DIR)\dos16\bc3 - -# Define which file contains our rules - - RULES_MAK := bc3.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/bc32.mk b/board/MAI/bios_emulator/scitech/makedefs/bc32.mk deleted file mode 100644 index 246de1dfc5..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/bc32.mk +++ /dev/null @@ -1,201 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Borland C++ 4.0 32 bit version. Supports Borland's DOS Power -# Pack DPMI32 DOS extender, Phar Lap's TNT DOS Extender and -# 32 bit Windows development. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Import enivornment variables that we use -.IMPORT .IGNORE : USE_SMX32 USE_TNT USE_WIN32 USE_BC5 USE_VXD BC_LIBBASE -.IMPORT .IGNORE : VTOOLSD - -# We are compiling for a 32 bit envionment - _32BIT_ := 1 - -# Default commands for compiling, assembling linking and archiving - CC := bcc32 -.IF $(USE_VXD) - CFLAGS := -4 -i60 -d -w-stu -.ELSE - CFLAGS := -4 -H=bcc32.sym -i60 -d -w-stu -.ENDIF -.IF $(USE_NASM) - AS := nasm - ASFLAGS := -t -f obj -d__FLAT__ -iINCLUDE -i$(SCITECH)\INCLUDE -.ELSE -.IF $(USE_TASM32) - AS := tasm32 -.ELIF $(USE_TASMX) - AS := tasmx -.ELSE - AS := tasm -.ENDIF - ASFLAGS := /t /mx /m /w-res /w-mcp /D__FLAT__ /iINCLUDE /i$(SCITECH)\INCLUDE -.ENDIF - LD := bclink tlink32.exe - LDFLAGS := -c - RC := brc32 -.IF $(USE_BC5) - WIN_VERSION := -V4.0 - RCFLAGS := -32 -.ELSE - RCFLAGS := -w32 -.ENDIF - LIB := tlib - LIBFLAGS := /C - ILIB := implib - ILIBFLAGS := -c - INTEL_X86 := 1 - NMSYM := $(SOFTICE_PATH)\nmsym.exe - NMSYMFLAGS := /TRANSLATE:source,package,always /PROMPT /SOURCE:$(SCITECH)\src\pm;$(SCITECH)\src\pm\common;$(SCITECH)\src\pm\win32 - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -v - LDFLAGS += -v - LIBFLAGS += /P256 -.IF $(USE_NASM) - ASFLAGS += -F borland -g -.ELSE - ASFLAGS += /zi -.ENDIF -.ELSE - LDFLAGS += -x - LIBFLAGS += /P128 -.IF $(USE_NASM) - ASFLAGS += -F null -.ELSE - ASFLAGS += /q -.ENDIF -.END - -# Optionally disable nagging warnings if MAX_WARN is not on -.IF $(MAX_WARN) -.ELSE - CFLAGS += -w-aus -w-par -w-hid -w-pia -.ENDIF - -# Optionally turn on optimisations (-5 -O2 breaks BC++ 4.0-4.5 sometimes) -.IF $(OPT) - CFLAGS += -5 -O2 -k- -.ELIF $(OPT_SIZE) - CFLAGS += -5 -O1 -k- -.END - -# Optionally turn on direct i387 FPU instructions -.IF $(FPU) - CFLAGS += -DFPU387 - ASFLAGS += -dFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -dBETA -.END - -# Optionally use Phar Lap's TNT DOS Extender, otherwise use the DOS Power Pack -.IF $(USE_TNT) - CFLAGS += -D__MSDOS__ - DX_CFLAGS += -DTNT - DX_ASFLAGS += -dTNT - LIB_OS = DOS32 - DEF_LIBS := import32.lib cw32.lib dosx32.lib tntapi.lib -.ELIF $(USE_VXD) - LDFLAGS += -n -P- -x - CFLAGS += -RT- -x- -Oi -VC -I$(VTOOLSD)\INCLUDE -DIS_32 -DWANTVXDWRAPS -DVTOOLSD -DWIN40 -DWIN40_OR_LATER -DDEFSEG=1 -zC_LTEXT -zALCODE -zR_LDATA -zTLCODE - DEF_LIBS := $(VTOOLSD)\lib\cfbc440d.lib $(VTOOLSD)\lib\wr0bc440.lib $(VTOOLSD)\lib\wr1bc440.lib $(VTOOLSD)\lib\wr2bc440.lib $(VTOOLSD)\lib\wr3bc440.lib $(VTOOLSD)\lib\rtbc440d.lib - DX_ASFLAGS += -d__VXD__ -d__BORLANDC__=1 -I$(VTOOLSD)\INCLUDE -I$(VTOOLSD)\LIB\INCLUDE - LIB_OS = VXD -.ELIF $(USE_WIN32) -.IF $(WIN32_GUI) -.ELSE - CFLAGS += -D__CONSOLE__ -.ENDIF -.IF $(BUILD_DLL) - CFLAGS += -WD -DBUILD_DLL - ASFLAGS += -dBUILD_DLL -.ELSE - CFLAGS += -W -WM -.ENDIF -.IF $(USE_BC5) -.ELSE - CFLAGS += -D_WIN32 -.ENDIF - DEF_LIBS := import32.lib cw32mt.lib - DX_ASFLAGS += -d__WINDOWS32__ - LIB_OS = WIN32 -.ELIF $(USE_SMX32) - CFLAGS += -D__SMX32__ -DPME32 - DX_CFLAGS += - DX_ASFLAGS += -d__SMX32__ -dDPMI32 -dPME32 - USE_REALDOS := 1 - LIB_OS = SMX32 - DEF_LIBS := cw32mt.lib -.ELSE - USE_DPMI32 := 1 - CFLAGS += -D__MSDOS__ - DX_CFLAGS += -WX -DDPMI32 - DX_ASFLAGS += -dDPMI32 - USE_REALDOS := 1 - LIB_OS = DOS32 - DEF_LIBS := -.END - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_BASE := $(LIB_BASE_DIR)\$(LIB_OS)\$(BC_LIBBASE) - LIB_DEST := $(LIB_BASE) - -# Place to look for PMODE library files - -.IF $(USE_TNT) -PMLIB := $(LIB_BASE)\tnt\pm.lib -.ELIF $(USE_DPMI32) -PMLIB := $(LIB_BASE)\dpmi32\pm.lib -.ELSE -PMLIB := $(LIB_BASE)\pm.lib -.END - -# Define which file contains our rules - - RULES_MAK := bc32.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/bcos2.mk b/board/MAI/bios_emulator/scitech/makedefs/bcos2.mk deleted file mode 100644 index 23aeb7cde4..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/bcos2.mk +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Borland C++ 2.0 32-bit OS/2 version. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Import enivornment variables that we use -.IMPORT .IGNORE : USE_OS2GUI BC_LIBBASE - -# We are compiling for a 32 bit envionment - _32BIT_ := 1 - -# Default commands for compiling, assembling linking and archiving - CC := bcc - CFLAGS := -w- -4 -H=bcc32.sym -i60 -d -.IF $(USE_NASM) - AS := nasm - ASFLAGS := -t -f obj -d__FLAT__ -iINCLUDE -i$(SCITECH)\INCLUDE -.ELSE - AS := tasm - ASFLAGS := /t /mx /m /D__FLAT__ /D__OS2__ /iINCLUDE /i$(SCITECH)\INCLUDE -.ENDIF - LD := bclink tlink.exe - LDFLAGS := -c - RC := brcc - RCFLAGS := - LIB := tlib - LIBFLAGS := /C /P32 - ILIB := implib - ILIBFLAGS := -c -.IF $(USE_OS2GUI) - CFLAGS += -D__OS2_PM__ -.ENDIF - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -v - LDFLAGS += -v - LIBFLAGS += /P128 -.IF $(USE_NASM) - ASFLAGS += -F borland -.ELSE - ASFLAGS += /zi -.ENDIF -.ELSE - LDFLAGS += -x -.IF $(USE_NASM) - ASFLAGS += -F null -.ELSE - ASFLAGS += /q -.ENDIF -.END - -# Optionally turn on optimisations -.IF $(OPT) - CFLAGS += -5 -O2 -k- -.ELIF $(OPT_SIZE) - CFLAGS += -5 -O1 -k- -.END - -# Optionally turn on direct i387 FPU instructions -.IF $(FPU) - CFLAGS += -DFPU387 - ASFLAGS += -dFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -dBETA -.END - -# Optionally use Phar Lap's TNT DOS Extender, otherwise use the DOS Power Pack -.IF $(BUILD_DLL) - CFLAGS += -sd -sm -DBUILD_DLL - ASFLAGS += -dBUILD_DLL -.ELSE - CFLAGS += -sm -.ENDIF - DEF_LIBS := os2.lib c2mt.lib - DX_ASFLAGS += -d__OS2__ - LIB_OS = os232 - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_BASE := $(LIB_BASE_DIR)\$(LIB_OS)\$(BC_LIBBASE) - LIB_DEST := $(LIB_BASE) - -# Place to look for PMODE library files - -.IF $(USE_OS2GUI) -DEF_LIBS += pm_pm.lib -.ELSE -DEF_LIBS += pm.lib -.ENDIF - -# Define which file contains our rules - - RULES_MAK := bcos2.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/cl16.mk b/board/MAI/bios_emulator/scitech/makedefs/cl16.mk deleted file mode 100644 index 0f29a1521e..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/cl16.mk +++ /dev/null @@ -1,132 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Microsoft C 6.0 16 bit version. Supports 16 bit -# OS/2 development. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Import enivornment variables that we use -.IMPORT .IGNORE : VC_LIBBASE -.IMPORT .IGNORE : USE_MASM - -# Default commands for compiling, assembling linking and archiving - CC := cl # C-compiler and flags - CFLAGS := /w /Gs - ASFLAGS := /t /mx /m /D__COMM__ /iINCLUDE /i$(SCITECH)\INCLUDE -.IF $(USE_TASM32) - AS := tasm32 -.ELIF $(USE_TASMX) - AS := tasmx # Assembler and flags -.ELIF $(USE_MASM) - AS := masm # Assembler and flags - ASFLAGS := /D__COMM__ /iINCLUDE /i$(SCITECH)\INCLUDE -.ELSE - AS := tasm # Assembler and flags -.ENDIF - LD := cl # Loader and flags - LDFLAGS = $(CFLAGS) - RC := rc # WIndows resource compiler - RCFLAGS := - LIB := lib # Librarian - LIBFLAGS := /NOI /NOE - ILIB := implib # Import librarian - ILIBFLAGS := /noignorecase - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += /Zi # Turn on debugging for C compiler - ASFLAGS += /zi # Turn on debugging for assembler -.ELSE - ASFLAGS += /q # Suppress object records not needed for linking -.END - -# Optionally turn on optimisations -.IF $(OPT) - CFLAGS += /Ox -.END - -# Optionally turn on direct i387 FPU instructions - -.IF $(FPU) - CFLAGS += /FPi87 /DFPU387 - ASFLAGS += /DFPU387 /DFPU_REG_RTN -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += /DBETA - ASFLAGS += /DBETA -.END - -# Use a larger stack during linking if requested ???? How the fuck do you -# specify linker options on the CL command line????? - -.IF $(STKSIZE) -.ENDIF - -# Optionally compile for 16 bit Windows -.IF $(USE_WIN16) -.IF $(BUILD_DLL) - CFLAGS += /GD /Alfw /DBUILD_DLL - ASFLAGS += -DBUILD_DLL -.ELSE - CFLAGS += /GA /AL -.ENDIF - DX_ASFLAGS += -D__WINDOWS16__ - LIB_OS = WIN16 -.ELSE - USE_REALDOS := 1 - CFLAGS += /AL - LIB_OS = DOS16 -.END - -# Place to look for PMODE library files - -PMLIB := pm.lib - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_BASE := $(LIB_BASE_DIR)\$(LIB_OS)\$(VC_LIBBASE) - LIB_DEST := $(LIB_BASE) - -# Define which file contains our rules - - RULES_MAK := cl16.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/cl386.mk b/board/MAI/bios_emulator/scitech/makedefs/cl386.mk deleted file mode 100644 index 52157f91f4..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/cl386.mk +++ /dev/null @@ -1,120 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Microsoft 386 C 6.0 32 bit. Supports 32 bit -# OS/2 development. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Import enivornment variables that we use -.IMPORT .IGNORE : CL_LIBBASE USE_VDD -.IMPORT .IGNORE : USE_MASM - -# Default commands for compiling, assembling linking and archiving - CC := cl386 # C-compiler and flags - # NB: The -Zf flag is ABSOLUTELY NECESSARY to compile IBM's OS/2 headers. - # It isn't documented anywhere but obviously adds support for 48-bit - # far pointers (ie. _far is valid in 32-bit code). Great. - CFLAGS := -G3s -Zf -D__386__ - ASFLAGS := /t /mx /m /oi /D__FLAT__ /DSTDCALL_MANGLE /D__NOU_VAR__ /iINCLUDE /i$(SCITECH)\INCLUDE -.IF $(USE_TASM32) - AS := tasm32 -.ELIF $(USE_TASMX) - AS := tasmx # Assembler and flags -.ELIF $(USE_MASM) - AS := masm # Assembler and flags - ASFLAGS := /t /mx /D__FLAT__ /DSTDCALL_MANGLE /D__NOU_VAR__ /iINCLUDE /i$(SCITECH)\INCLUDE -.ELSE - AS := tasm # Assembler and flags -.ENDIF - LD := link386 # Linker and flags - LDFLAGS = $(CFLAGS) - RC := rc # Windows resource compiler - RCFLAGS := - LIB := lib # Librarian - LIBFLAGS := /NOI /NOE - ILIB := implib # Import librarian - ILIBFLAGS := /noignorecase - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -Zi # Turn on debugging for C compiler - ASFLAGS += /zi # Turn on debugging for assembler -.ELSE - ASFLAGS += /q # Suppress object records not needed for linking -.END - -# Optionally turn on optimisations -.IF $(OPT) - CFLAGS += /Ox -.END - -# Optionally turn on direct i387 FPU instructions - -.IF $(FPU) - CFLAGS += /FPi87 /DFPU387 - ASFLAGS += /DFPU387 /DFPU_REG_RTN -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += /DBETA - ASFLAGS += /DBETA -.END - -# Use a larger stack during linking if requested ???? How the fuck do you -# specify linker options on the CL command line????? - -.IF $(STKSIZE) -.ENDIF - -# Place to look for PMODE library files - -PMLIB := pm.lib - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_OS = os232 - LIB_BASE := $(LIB_BASE_DIR)\$(LIB_OS)\$(CL_LIBBASE) - LIB_DEST := $(LIB_BASE) - -# Define which file contains our rules - - RULES_MAK := cl386.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/common.mk b/board/MAI/bios_emulator/scitech/makedefs/common.mk deleted file mode 100644 index d337152e74..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/common.mk +++ /dev/null @@ -1,180 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Common makefile targets used by all SciTech Software -# makefiles. This file includes targets for cleaning the -# current directory, and maintaining the source files with -# RCS. -# -############################################################################# - -# Override global OpenGL includes when compiling against MGL version - -.IF $(USE_MGL_OPENGL) -.IF $(UNIX_HOST) -CFLAGS += -I$(SCITECH)/include/mglgl -DEPEND_INC += $(SCITECH)/include/mglgl -.ELSE -CFLAGS += -I$(SCITECH)\include\mglgl -DEPEND_INC += $(SCITECH)\include/mglgl -.ENDIF -.ENDIF - -# Define where to install all compiled DLL files - -.IF $(UNIX_HOST) -.IF $(CHECKED) -DLL_DEST := $(SCITECH_LIB)/redist/debug -.ELSE -DLL_DEST := $(SCITECH_LIB)/redist/release -.ENDIF -.ELSE -.IF $(CHECKED) -DLL_DEST := $(SCITECH_LIB)\redist\debug -.ELSE -DLL_DEST := $(SCITECH_LIB)\redist\release -.ENDIF -.ENDIF - -# Target to build the library and DLL file if specified - -.IF $(LIBFILE) - -lib: $(LIBFILE) - -.IF $(DLLFILE) - -# Build and install a DLL file, or simply build import library and install - -.IF $(BUILD_DLL) - -$(DLLFILE): $(OBJECTS) -$(LIBFILE): $(DLLFILE) -install: $(LIBFILE) $(DLLFILE) - $(INSTALL) $(LIBFILE) $(LIB_DEST)$(LIB_EXTENDER) - $(INSTALL) $(DLLFILE) $(DLL_DEST) -.IF $(USE_SOFTICE) - $(INSTALL) $(DLLFILE:s/.dll/.nms) $(DLL_DEST) -.ENDIF -.ELSE - -$(LIBFILE): $(DLL_DEST)\$(DLLFILE) -install: $(LIBFILE) - $(INSTALL) $(LIBFILE) $(LIB_DEST)$(LIB_EXTENDER) - -.ENDIF -.ELSE - -.IF $(BUILD_DLL) - -# Build and install a Unix shared library - -$(LIBFILE): $(OBJECTS) -install: $(LIBFILE) - $(INSTALL) $(LIBFILE) $(LIB_DEST)$(LIB_EXTENDER) - $(INSTALL) $(LIBFILE) $(DLL_DEST)/$(LIBFILE).$(VERSION) - -.ELSE - -# Build and install a normal library file - -.IF $(USE_DLL) -.ELSE -$(LIBFILE): $(OBJECTS) -install: $(LIBFILE) - $(INSTALL) $(LIBFILE) $(LIB_DEST)$(LIB_EXTENDER) -.ENDIF -.ENDIF -.ENDIF -.ENDIF - -# Build and install a VxD file, including debug information - -.IF $(VXDFILE) -$(VXDFILE:s/.vxd/.dll): $(OBJECTS) -$(VXDFILE): $(VXDFILE:s/.vxd/.dll) -install: $(VXDFILE) - $(INSTALL) $(VXDFILE) $(DLL_DEST) -.IF $(DBG) - $(INSTALL) $(VXDFILE:s/.vxd/.nms) $(DLL_DEST) -.ENDIF -.ENDIF - -# Clean up directory removing all files not needed to make the library. - -__CLEAN_FILES := *.obj *.o *.sym *.bak *.tdk *.swp *.map *.err *.csm *.lib *.aps *.nms *.sys -__CLEAN_FILES += *.~* *.td *.tr *.tr? *.td? *.rws *.res *.exp *.ilk *.pdb *.pch *.a bcc32.* -__CLEAN_FILES += $(LIBCLEAN) -__CLEANEXE_FILES := $(__CLEAN_FILES) *$E *.drv *.rex *.dll *.vxd *.nms *.pel *.smf *.so.* - -.PHONY clean: - @$(RM) -f -S $(mktmp $(__CLEAN_FILES:t"\n")) - -.PHONY cleanexe: - @$(RM) -f -S $(mktmp $(__CLEANEXE_FILES:t"\n")) - -# Define the source directories to find common files - -.IF $(NO_SCITECH_COMMON) -.ELSE -.SOURCE: $(SCITECH)/src/common -.ENDIF - -# Create the include file dependencies using the MKUTIL makedep program if -# the list of dependent object files is defined - -.IF $(DEPEND_OBJ) -depend: - @$(RM) -f makefile.dep -.IF $(DEPEND_SRC) -.IF $(DEPEND_INC) - @makedep -amakefile.dep -r -s -I@$(mktmp $(DEPEND_INC:s/\/\\)) -S@$(mktmp $(DEPEND_SRC:s/\/\\);$(SCITECH)/src/common) @$(mktmp $(DEPEND_OBJ:t"\n")\n) -.ELSE - @makedep -amakefile.dep -r -s -S@$(mktmp $(DEPEND_SRC:s/\/\\);$(SCITECH)/src/common) @$(mktmp $(DEPEND_OBJ:t"\n")\n) -.ENDIF -.ELSE -.IF $(DEPEND_INC) - @makedep -amakefile.dep -r -s -I@$(mktmp $(DEPEND_INC:s/\/\\)) -S@$(mktmp $(SCITECH)/src/common) @$(mktmp $(DEPEND_OBJ:t"\n")\n) -.ELSE - @makedep -amakefile.dep -r -s -S@$(mktmp $(SCITECH)/src/common) @$(mktmp $(DEPEND_OBJ:t"\n")\n) -.ENDIF -.ENDIF - @$(ECHO) Object file dependency information generated. -.ENDIF - -# Set up for compiling Snap executeables and dynamic link libraries - -.IF $(USE_SNAP) -#CFLAGS += -I$(PRIVATE)\include\drvlib -I$(SCITECH)\include\drvlib -D__SNAP__ -CFLAGS += -D__SNAP__ -ASFLAGS += -d__SNAP__ -#EXELIBS += snap$L -.ENDIF - -# Include rule definitions for the compiler - -.INCLUDE: "$(SCITECH)/makedefs/rules/$(RULES_MAK)" - -# Include file dependencies - -.INCLUDE .IGNORE: "makefile.dep" diff --git a/board/MAI/bios_emulator/scitech/makedefs/emx.mk b/board/MAI/bios_emulator/scitech/makedefs/emx.mk deleted file mode 100644 index f569790a3c..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/emx.mk +++ /dev/null @@ -1,194 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# OS/2 version for EMX/GNU C/C++. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Disable warnings for macros redefined here that were given -# on the command line. -__.SILENT := $(.SILENT) -.SILENT := yes - -# Import enivornment variables that we use common to all compilers -.IMPORT .IGNORE : TEMP SHELL INCLUDE LIB SCITECH PRIVATE SCITECH_LIB -.IMPORT .IGNORE : DBG OPT OPT_SIZE CRTDLL SHW BETA CHECKED NO_EXCEPT NO_RTTI -.IMPORT .IGNORE : FULLSCREEN SHOW_ARGS - TMPDIR := $(TEMP) - -# Standard file suffix definitions - L := .lib # Libraries - E := .exe # Executables - O := .obj # Objects - A := .asm # Assembler sources - S := .s # GNU assembler sources - P := .cpp # C++ sources - -# File prefix/suffix definitions. The following prefixes are defined, and are -# used primarily to abstract between the Unix style libXX.a naming convention -# and the DOS/Windows/OS2 naming convention of XX.lib. - LP := # LP - Library file prefix (name of file on disk) - LL := -l # Library link prefix (name of library on link command line) - LE := # Library link suffix (extension of library on link command line) - -# Import enivornment variables that we use -.IMPORT .IGNORE : EMX_LIBBASE USE_OS232 USE_OS2GUI - -# We are compiling for a 32 bit envionment - _32BIT_ := 1 - -# DMAKE uses this recipe to remove intermediate targets -.REMOVE :; $(RM) -f $< - -# Turn warnings back to previous setting. -.SILENT := $(__.SILENT) - -# We dont use TABS in our makefiles -.NOTABS := yes - -# Default commands for compiling, assembling linking and archiving. - CC := gcc - CFLAGS := -Zmt -Zomf -Wall -I. -I$(INCLUDE) - CXX := gcc -x c++ -fno-exceptions -fno-rtti -.IF $(USE_NASM) - AS := nasm - ASFLAGS := -t -f obj -F null -d__FLAT__ -d__NOU__ -iINCLUDE -i$(SCITECH)\INCLUDE -.ELSE - AS := tasm # Assembler and flags - ASFLAGS := /t /mx /m /oi /D__FLAT__ /D__NOU__ /iINCLUDE /i$(SCITECH)\INCLUDE -.ENDIF - LD := gcc - LDXX := gcc -x c++ - LDFLAGS := -L. -Zomf -Zmt - LIB := emxomfar - LIBFLAGS := -p32 rcv - - YACC := bison -y - LEX := flex - SED := sed - -# Optionally turn off exceptions and RTTI for C++ code -.IF $(NO_EXCEPT) - CXX += -fno-exceptions -.ENDIF -.IF $(NO_RTTI) - CXX += -fno-rtti -.ENDIF - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -g -.ELSE -# Without -s, emx always runs LINK386 with the /DEBUG option - CFLAGS += -s - LDFLAGS += -s -# NASM does not support debugging information yet - ASFLAGS += -.ENDIF - -# Optionally turn on optimisations -.IF $(OPT_MAX) - CFLAGS += -O6 -.ELIF $(OPT) - CFLAGS += -O3 -fomit-frame-pointer -.ELIF $(OPT_SIZE) - CFLAGS += -Os -.ENDIF - -# Optionally turn on direct i387 FPU instructions -.IF $(FPU) - CFLAGS += -DFPU387 - ASFLAGS += -dFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -dBETA -.ENDIF - -# Disable standard C runtime library -.IF $(NO_RUNTIME) -CFLAGS += -fno-builtin -nostdinc -.ENDIF - -# Link against EMX DLLs (CRTDLL=1) or link with static C runtime libraries -.IF $(CRTDLL) - LDFLAGS += -Zcrtdll -.ELSE - CFLAGS += -Zsys - LDFLAGS += -Zsys -.ENDIF - -# Target environment dependant flags - CFLAGS += -D__OS2_32__ - CFLAGS += -D__OS2__ - ASFLAGS += -d__OS2__ - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)/lib/debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)/lib/release -.ENDIF - -# Define where to install library files - LIB_DEST := $(LIB_BASE_DIR)\OS232\$(EMX_LIBBASE) - LDFLAGS += -L$(LIB_DEST) - -# Build 32-bit OS/2 apps -.IF $(BUILD_DLL) - CFLAGS += -Zdll -DBUILD_DLL - LDFLAGS += -Zdll - ASFLAGS += -dBUILD_DLL -.ELSE -.IF $(USE_OS2GUI) - CFLAGS += -D__OS2_PM__ - LDFLAGS += -Zlinker /PMTYPE:PM -.ELSE -.IF $(FULLSCREEN) - LDFLAGS += -Zlinker /PMTYPE:NOVIO -.ELSE - LDFLAGS += -Zlinker /PMTYPE:VIO -.ENDIF -.ENDIF -.ENDIF - -# Place to look for PMODE library files - -PMLIB := -lpm - -# Define which file contains our rules - - RULES_MAK := emx.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/gcc_beos.mk b/board/MAI/bios_emulator/scitech/makedefs/gcc_beos.mk deleted file mode 100644 index 0d62fdf1a8..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/gcc_beos.mk +++ /dev/null @@ -1,161 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# BeOS version for GNU C/C++. -# -############################################################################# - -# Disable warnings for macros redefined here that were given -# on the command line. -__.SILENT := $(.SILENT) -.SILENT := yes - -# Import enivornment variables that we use common to all compilers -.IMPORT .IGNORE : TEMP SHELL INCLUDE LIB SCITECH PRIVATE SCITECH_LIB -.IMPORT .IGNORE : DBG OPT OPT_SIZE SHW BETA CHECKED USE_X11 USE_LINUX -.IMPORT .IGNORE : USE_EGCS USE_PGCC STATIC_LIBS LIBC - TMPDIR := $(TEMP) - -# Standard file suffix definitions -# -# NOTE: BeOS does not require any extenion for executeable files, but you -# can use an extension if you wish. We use the .x extension for building -# executeable files so that we can use implicit rules to make the -# makefiles simpler and more portable between systems. When you install -# the files to a local bin directory, you will probably want to remove -# the .x extension. - L := .a # Libraries - E := .x # Executables - O := .o # Objects - A := .asm # Assembler sources - S := .s # GNU assembler sources - P := .cpp # C++ sources - -# File prefix/suffix definitions. The following prefixes are defined, and are -# used primarily to abstract between the Unix style libXX.a naming convention -# and the DOS/Windows/OS2 naming convention of XX.lib. - LP := lib # LP - Library file prefix (name of file on disk) - LL := -l # Library link prefix (name of library on link command line) - LE := # Library link suffix (extension of library on link command line) - -# We use the Unix shell at all times - SHELLFLAGS := -c - -# Definition of $(MAKE) macro for recursive makes. - MAKE = $(MAKECMD) $(MFLAGS) - -# Macro to install a library file - INSTALL := cp - -# DMAKE uses this recipe to remove intermediate targets -.REMOVE :; $(RM) -f $< - -# Turn warnings back to previous setting. -.SILENT := $(__.SILENT) - -# We dont use TABS in our makefiles -.NOTABS := yes - -# Define that we are compiling for BeOS - USE_BEOS := 1 - -# Default commands for compiling, assembling linking and archiving. - CC := gcc - CFLAGS := -Wall -I. -Iinclude $(INCLUDE) - CXX := g++ - AS := nasm - ASFLAGS := -f elf -d__FLAT__ -iinclude -i$(SCITECH)/include -d__NOU__ - LD := gcc - LDFLAGS := -L. - LIB := ar - LIBFLAGS := rcs - -# Link to static libraries if requested -.IF $(STATIC_LIBS) - LDFLAGS += -static -.ENDIF - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -g -.ELSE -# NASM does not support debugging information yet - ASFLAGS += -.ENDIF - -# Optionally turn on optimisations -.IF $(OPT_MAX) - CFLAGS += -O6 -.ELIF $(OPT) - CFLAGS += -O2 -.ELIF $(OPT_SIZE) - CFLAGS += -O1 -.ENDIF - -# Optionally turn on direct i387 FPU instructions -.IF $(FPU) - CFLAGS += -DFPU387 - ASFLAGS += -dFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -dBETA -.ENDIF - -# Disable standard C runtime library - -.IF $(NO_RUNTIME) -CFLAGS += -fno-builtin -nostdinc -.ENDIF - -# Target environment dependant flags - CFLAGS += -D__BEOS__ - ASFLAGS += -d__BEOS__ -d__UNIX__ - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)/lib/debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)/lib/release -.ENDIF - -# Define where to install library files -LIB_DEST := $(LIB_BASE_DIR)/beos/gcc -LDFLAGS += -L$(LIB_DEST) - -# Place to look for PMODE library files - -PMLIB := -lpm - -# Define which file contains our rules - - RULES_MAK := gcc_beos.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/gcc_dos.mk b/board/MAI/bios_emulator/scitech/makedefs/gcc_dos.mk deleted file mode 100644 index 65589c83a3..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/gcc_dos.mk +++ /dev/null @@ -1,112 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# DJGPP V2 port of GNU C/C++ to DOS with DPMI only. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Override some file suffix definitions - L := .a # Libraries - O := .o # Objects - -# Override the file prefix/suffix definitions for library naming. - LP := lib # LP - Library file prefix (name of file on disk) - LL := -l # Library link prefix (name of library on link command line) - LE := # Library link suffix (extension of library on link command line) - -# Import enivornment variables that we use -.IMPORT .IGNORE : DJ_LIBBASE - -# We are compiling for a 32 bit envionment - _32BIT_ := 1 - -# Default commands for compiling, assembling linking and archiving - CC := gcc # C-compiler and flags - CFLAGS := -Wall - AS := nasm - ASFLAGS := -t -f coff -F null -d__FLAT__ -d__GNUC__ -dSTDCALL_USCORE -iINCLUDE -i$(SCITECH)\INCLUDE - LD := dj_ld # Loader and flags - LDFLAGS := - LIB := ar # Librarian - LIBFLAGS := rs - USE_NASM := 1 - USE_GCC := 1 - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -g # Turn on debugging for C compiler -.END - -# Optionally turn on optimisations -.IF $(OPT) - CFLAGS += -O2 -.ELIF $(OPT_SIZE) - CFLAGS += -O1 -.END - -# Optionally turn on direct i387 FPU instructions - -.IF $(FPU) - CFLAGS += -DFPU387 - ASFLAGS += -dFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -dBETA -.END - -# DOS extender dependant flags - DX_CFLAGS += - DX_ASFLAGS += -dDJGPP - USE_REALDOS := 1 - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_DEST := $(LIB_BASE_DIR)\DOS32\$(DJ_LIBBASE) - -# Place to look for PMODE library files - -PMLIB := -lpm - -# Define which file contains our rules - - RULES_MAK := dj32.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/gcc_freebsd.mk b/board/MAI/bios_emulator/scitech/makedefs/gcc_freebsd.mk deleted file mode 100644 index 0cb4b8530b..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/gcc_freebsd.mk +++ /dev/null @@ -1,174 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Linux version for GNU C/C++. -# -############################################################################# - -# Disable warnings for macros redefined here that were given -# on the command line. -__.SILENT := $(.SILENT) -.SILENT := yes - -# Import enivornment variables that we use common to all compilers -.IMPORT .IGNORE : TEMP SHELL INCLUDE LIB SCITECH PRIVATE SCITECH_LIB -.IMPORT .IGNORE : DBG OPT OPT_SIZE SHW BETA CHECKED USE_X11 USE_FREEBSD -.IMPORT .IGNORE : USE_EGCS USE_PGCC STATIC_LIBS - TMPDIR := $(TEMP) - -# Standard file suffix definitions -# -# NOTE: Linux does not require any extenion for executeable files, but you -# can use an extension if you wish. We use the .x extension for building -# executeable files so that we can use implicit rules to make the -# makefiles simpler and more portable between systems. When you install -# the files to a local bin directory, you will probably want to remove -# the .x extension. - L := .a # Libraries - E := .x # Executables - O := .o # Objects - A := .asm # Assembler sources - S := .s # GNU assembler sources - P := .cpp # C++ sources - -# File prefix/suffix definitions. The following prefixes are defined, and are -# used primarily to abstract between the Unix style libXX.a naming convention -# and the DOS/Windows/OS2 naming convention of XX.lib. - LP := lib # LP - Library file prefix (name of file on disk) - LL := -l # Library link prefix (name of library on link command line) - LE := # Library link suffix (extension of library on link command line) - -# We use the Unix shell at all times - SHELL := /bin/sh - SHELLFLAGS := -c - -# Definition of $(MAKE) macro for recursive makes. - MAKE = $(MAKECMD) $(MFLAGS) - -# Macro to install a library file - INSTALL := cp - -# DMAKE uses this recipe to remove intermediate targets -.REMOVE :; $(RM) -f $< - -# Turn warnings back to previous setting. -.SILENT := $(__.SILENT) - -# We dont use TABS in our makefiles -.NOTABS := yes - -# Define that we are compiling for FreeBSD - USE_LINUX := 1 - -# Default commands for compiling, assembling linking and archiving. -.IF $(USE_EGCS) - CC := egcs -.ELIF $(USE_PGCC) - CC := pgcc -.ELSE - CC := gcc -.ENDIF - CFLAGS := -Wall -I. -Iinclude $(INCLUDE) - CXX := g++ - AS := nasm -# TODO: On earlier versions of FreeBSD (<3.0) a.out is used instead of ELF - ASFLAGS := -f elf -d__FLAT__ -iinclude -i$(SCITECH)/include -d__NOU__ - LD := g++ - LDFLAGS := -L. - LIB := ar - LIBFLAGS := rcs - -# Link to static libraries if requested -.IF $(STATIC_LIBS) - LDFLAGS += -static -.ENDIF - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -g -.ELSE -# NASM does not support debugging information yet - ASFLAGS += -.ENDIF - -# Optionally turn on optimisations -.IF $(OPT_MAX) - CFLAGS += -O6 -.ELIF $(OPT) - CFLAGS += -O2 -.ELIF $(OPT_SIZE) - CFLAGS += -O1 -.ENDIF - -# Optionally turn on direct i387 FPU instructions -.IF $(FPU) - CFLAGS += -DFPU387 - ASFLAGS += -dFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -dBETA -.ENDIF - -# Disable standard C runtime library - -.IF $(NO_RUNTIME) -CFLAGS += -fno-builtin -nostdinc -.ENDIF - -# Compile flag for whether to build X11 or non-X11 lib -.IF $(USE_X11) - CFLAGS += -D__X11__ -.ENDIF - -# Target environment dependant flags - CFLAGS += -D__FREEBSD__ - ASFLAGS += -d__FREEBSD__ -d__UNIX__ - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)/lib/debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)/lib/release -.ENDIF - -# Define where to install library files - LIB_DEST := $(LIB_BASE_DIR)/freebsd/gcc - LDFLAGS += -L$(LIB_DEST) - -# Place to look for PMODE library files - -PMLIB := -lpm - -# Define which file contains our rules - - RULES_MAK := gcc_freebsd.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/gcc_linux.mk b/board/MAI/bios_emulator/scitech/makedefs/gcc_linux.mk deleted file mode 100644 index 72c4cedfd4..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/gcc_linux.mk +++ /dev/null @@ -1,180 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Linux version for GNU C/C++. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)/makedefs/startup.mk" - -# Import enivornment variables that we use -.IMPORT .IGNORE : GCC2_LIBBASE - -# Override some file suffix definitions - L := .a # Libraries - O := .o # Objects - -# Override the file prefix/suffix definitions for library naming. - LP := lib # LP - Library file prefix (name of file on disk) - LL := -l # Library link prefix (name of library on link command line) - LE := # Library link suffix (extension of library on link command line) - -# We are compiling for a 32 bit envionment - _32BIT_ := 1 - -# Define that we are compiling for Linux - USE_LINUX := 1 - -# Default commands for compiling, assembling linking and archiving. - CC := gcc - CFLAGS := -Wall -I. -Iinclude -I$(SCITECH:s,\,/)/include -I$(PRIVATE:s,\,/)/include - SHOW_CFLAGS := -c - CXX := g++ - AS := nasm - ASFLAGS := -t -f elf -d__FLAT__ -d__GNUC__ -iinclude -i$(SCITECH)/include -d__NOU__ - SHOW_ASFLAGS := -f elf - LD := gcc - LDXX := g++ - LDFLAGS := -L. - LIB := ar - LIBFLAGS := rcs - YACC := bison -y - LEX := flex - SED := sed - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -g - SHOW_CFLAGS += -g -.ELSE -# NASM does not support debugging information yet - ASFLAGS += -.ENDIF - -# Optionally turn on optimisations -.IF $(OPT_MAX) - CFLAGS += -O6 - SHOW_CFLAGS += -O6 -.ELIF $(OPT) - CFLAGS += -O2 - SHOW_CFLAGS += -O2 -.ELIF $(OPT_SIZE) - CFLAGS += -O1 - SHOW_CFLAGS += -O1 -.ENDIF - -# Optionally turn on direct i387 FPU instructions -.IF $(FPU) - CFLAGS += -DFPU387 - ASFLAGS += -dFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - SHOW_CFLAGS += -DBETA - ASFLAGS += -dBETA - SHOW_ASFLAGS += -dBETA -.ENDIF - -# Disable standard C runtime library - -.IF $(NO_RUNTIME) -CFLAGS += -fno-builtin -nostdinc -.ENDIF - -# Compile flag for whether to build X11 or non-X11 lib -.IF $(USE_X11) - CFLAGS += -D__X11__ -.ENDIF - -# Target environment dependant flags - CFLAGS += -D__LINUX__ - ASFLAGS += -d__LINUX__ -d__UNIX__ - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)/lib/debug -CFLAGS += -DCHECKED=1 -SHOW_CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)/lib/release -.ENDIF - -# Define where to install library files -.IF $(LIBC) - LIB_DEST_SHARED := $(LIB_BASE_DIR)/linux/gcc/libc.so - LIB_DEST_STATIC := $(LIB_BASE_DIR)/linux/gcc/libc -.ELSE - LIB_DEST_SHARED := $(LIB_BASE_DIR)/linux/gcc/glibc.so - LIB_DEST_STATIC := $(LIB_BASE_DIR)/linux/gcc/glibc -.ENDIF - -# Link to static libraries if requested -.IF $(STATIC_LIBS_ALL) - LDFLAGS += -static - STATIC_LIBS := 1 -.ENDIF - -# Link to static libraries if requested -.IF $(STATIC_LIBS) - LDFLAGS += -L$(LIB_DEST_STATIC) -.ELSE - LDFLAGS += -L$(LIB_DEST_SHARED) -L$(LIB_DEST_STATIC) -.ENDIF - -# Optionally enable some dynamic libraries to be built -.IF $(BUILD_DLL) -.IF $(VERSIONMAJ) -.ELSE - VERSIONMAJ := 5 - VERSIONMIN := 0 -.ENDIF - VERSION := $(VERSIONMAJ).$(VERSIONMIN) - LIB := gcc -shared - LIBFLAGS := - L := .so - CFLAGS += -fPIC - SHOW_CFLAGS += -fPIC - ASFLAGS += -D__PIC__ - SHOW_ASFLAGS += -D__PIC__ - LIB_DEST := $(LIB_DEST_SHARED) -.ELSE - LIB_DEST := $(LIB_DEST_STATIC) -.ENDIF - -# Place to look for PMODE library files - -PMLIB := -lpm - -# Define which file contains our rules - - RULES_MAK := gcc_linux.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/gcc_win32.mk b/board/MAI/bios_emulator/scitech/makedefs/gcc_win32.mk deleted file mode 100644 index 21ccf97849..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/gcc_win32.mk +++ /dev/null @@ -1,135 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Cygwin port of GNU C/C++ to Win32. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Import enivornment variables that we use -.IMPORT .IGNORE : GCC2_LIBBASE - -# Override some file suffix definitions - L := .a # Libraries - O := .o # Objects - -# Override the file prefix/suffix definitions for library naming. - LP := lib # LP - Library file prefix (name of file on disk) - LL := -l # Library link prefix (name of library on link command line) - LE := # Library link suffix (extension of library on link command line) - -# We are compiling for a 32 bit envionment - _32BIT_ := 1 - -# Default commands for compiling, assembling linking and archiving - CC := gcc # C-compiler and flags - CFLAGS := -Wall -I. -Iinclude -I$(SCITECH:s,\,/)/include -I$(PRIVATE:s,\,/)/include - SHOW_CFLAGS := -c - CXX := g++ - AS := nasm - ASFLAGS := -t -f coff -F null -d__FLAT__ -d__GNUC__ -dSTDCALL_USCORE -iINCLUDE -i$(SCITECH)\INCLUDE - SHOW_ASFLAGS := -f coff - LD := gcc # Loader and flags - LDXX := g++ -.IF $(WIN32_GUI) - LDFLAGS := -L. -mwindows -e _mainCRTStartup -.ELSE - LDFLAGS := -L. -.ENDIF - RC := windres - RCFLAGS := -O coff - LIB := ar # Librarian - LIBFLAGS := rcs - YACC := bison -y - LEX := flex - SED := sed - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -g - SHOW_CFLAGS += -g -.ELSE -# NASM does not support debugging information yet - ASFLAGS += -.ENDIF - -# Optionally turn on optimisations -.IF $(OPT_MAX) - CFLAGS += -O6 - SHOW_CFLAGS += -O6 -.ELIF $(OPT) - CFLAGS += -O2 - SHOW_CFLAGS += -O2 -.ELIF $(OPT_SIZE) - CFLAGS += -O1 - SHOW_CFLAGS += -O1 -.ENDIF - -# Optionally turn on direct i387 FPU instructions - -.IF $(FPU) - CFLAGS += -DFPU387 - ASFLAGS += -dFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - SHOW_CFLAGS += -DBETA - ASFLAGS += -dBETA - SHOW_ASFLAGS += -dBETA -.ENDIF - -# DOS extender dependant flags - DX_CFLAGS += - DX_ASFLAGS += -dGCC_WIN32 - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += -DCHECKED=1 -SHOW_CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_DEST := $(LIB_BASE_DIR)\WIN32\$(GCC2_LIBBASE) - LDFLAGS += -L$(LIB_DEST) - -# Place to look for PMODE library files - -PMLIB := -lpm - -# Define which file contains our rules - - RULES_MAK := gcc_win32.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/hc32.mk b/board/MAI/bios_emulator/scitech/makedefs/hc32.mk deleted file mode 100644 index f0b065a47c..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/hc32.mk +++ /dev/null @@ -1,113 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Metaware High C/C++ 3.21 32 bit version. Supports Phar Lap's -# TNT DOS Extender. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# We are compiling for a 32 bit envionment - _32BIT_ := 1 - -# Default commands for compiling, assembling linking and archiving - CC := hc386 # C-compiler and flags - CFLAGS := -.IF $(USE_TASM32) - AS := tasm32 -.ELIF $(USE_TASMX) - AS := tasmx # Assembler and flags -.ELSE - AS := tasm # Assembler and flags -.ENDIF - ASFLAGS := /t /mx /m /D__FLAT__ /iINCLUDE /i$(SCITECH)\INCLUDE - LD := hc386 - LDFLAGS = $(CFLAGS) - LIB := 386lib # TNT 386|lib Librarian - LIBFLAGS := -TC - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -g # Turn on debugging for C compiler - ASFLAGS += /zi # Turn on debugging for assembler -.ELSE - ASFLAGS += /q # Suppress object records not needed for linking -.END - -# Optionally turn on optimisations -.IF $(OPT) - CFLAGS += -586 -O -.ELIF $(OPT_SIZE) - CFLAGS += -586 -O1 -.ELSE - CFLAGS += -O0 -.END - -# Optionally turn on direct i387 FPU instructions - -.IF $(FPU) - CFLAGS += -DFPU387 - ASFLAGS += -DFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -DBETA -.END - -# DOS extender dependant flags - USE_TNT := 1 - USE_REALDOS := 1 - DX_CFLAGS += -DTNT - DX_ASFLAGS += -DTNT - LDFLAGS += -LH:\TNT\LIB - -# Place to look for PMODE library files - -PMLIB := tnt\pm.lib - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_BASE := $(LIB_BASE_DIR)\DOS32\HC - LIB_DEST := $(LIB_BASE) - -# Define which file contains our rules - - RULES_MAK := hc32.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/qnx4.mk b/board/MAI/bios_emulator/scitech/makedefs/qnx4.mk deleted file mode 100644 index f583af36f6..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/qnx4.mk +++ /dev/null @@ -1,164 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# QNX version for Watcom C. -# -############################################################################# - -# Disable warnings for macros redefined here that were given -# on the command line. -__.SILENT := $(.SILENT) -.SILENT := yes - -# Import enivornment variables that we use common to all compilers -.IMPORT .IGNORE : TEMP SHELL INCLUDE LIB SCITECH PRIVATE SCITECH_LIB -.IMPORT .IGNORE : DBG OPT OPT_SIZE SHW BETA CHECKED USE_QNX USE_QNX4 -.IMPORT .IGNORE : USE_PHOTON USE_X11 USE_BIOS SHOW_ARGS MAX_WARN WC_LIBBASE - TMPDIR := $(TEMP) - -# Standard file suffix definitions -# -# NOTE: Qnx does not require any extension for executeable files, but you -# can use an extension if you wish. We use the .x extension for building -# executeable files so that we can use implicit rules to make the -# makefiles simpler and more portable between systems. When you install -# the files to a local bin directory, you will probably want to remove -# the .x extension. - L := .a # Libraries - E := .exe # Executables - O := .o # Objects - A := .asm # Assembler sources - S := .s # GNU assembler sources - P := .cpp # C++ sources - -# File prefix/suffix definitions. The following prefixes are defined, and are -# used primarily to abstract between the Unix style libXX.a naming convention -# and the DOS/Windows/OS2 naming convention of XX.lib. - LP := lib # LP - Library file prefix (name of file on disk) - LL := -l # Library link prefix (name of library on link command line) - LE := # Library link suffix (extension of library on link command line) - -# We use the Unix shell at all times - SHELL := /bin/sh - SHELLFLAGS := -c - -# Definition of $(MAKE) macro for recursive makes. - MAKE = $(MAKECMD) $(MFLAGS) - -# Macro to install a library file - INSTALL := cp - -# DMAKE uses this recipe to remove intermediate targets -.REMOVE :; $(RM) -f $< - -# Turn warnings back to previous setting. -.SILENT := $(__.SILENT) - -# We dont use TABS in our makefiles -.NOTABS := yes - -# Define that we are compiling for QNX - USE_QNX := 1 - -# Default commands for compiling, assembling linking and archiving. - CC := wcc386 - CFLAGS := -I. -Iinclude $(INCLUDE) - CXX := wpp386 - AS := nasm - ASFLAGS := -t -f obj -d__FLAT__ -dSTDCALL_MANGLE -iinclude -i$(SCITECH)/include - LD := cc - LDFLAGS := -L. - LIB := ar - LIBFLAGS := rc - -# Set the compiler warning level -.IF $(MAX_WARN) - CFLAGS += -w4 -.ELSE - CFLAGS += -w1 -.ENDIF - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -d2 - LDFLAGS += -g2 -.ELSE -# NASM does not support debugging information yet - ASFLAGS += -.ENDIF - -# Optionally turn on optimisations -.IF $(OPT) - CFLAGS += -onatx-5r-fp5 -.ELIF $(OPT_SIZE) - CFLAGS += -onaslmr-5r-fp5 -.ELIF $(NOOPT) - CFLAGS += -od-5r -.END - -# Compile flag for whether to build photon or non-photon lib -.IF $(USE_PHOTON) - CFLAGS += -D__PHOTON__ -.ENDIF - -# Compile flag for whether to build X11 or non-X11 lib -.IF $(USE_X11) - CFLAGS += -D__X11__ -.ENDIF - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -dBETA -.ENDIF - -# Target environment dependant flags - CFLAGS += -D__QNX__ -D__UNIX__ - ASFLAGS += -d__QNX__ -d__UNIX__ - -# Define the base directory for library files - -.IF $(CHECKED) - LIB_BASE_DIR := $(SCITECH_LIB)/lib/debug - CFLAGS += -DCHECKED=1 -.ELSE - LIB_BASE_DIR := $(SCITECH_LIB)/lib/release -.ENDIF - -# Define where to install library files - LIB_BASE := $(LIB_BASE_DIR)/qnx4/$(WC_LIBBASE) - LIB_DEST := $(LIB_BASE) - LDFLAGS += -L$(LIB_DEST) - -# Place to look for PMODE library files - -PMLIB := -lpm - -# Define which file contains our rules - - RULES_MAK := qnx4.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/qnxnto.mk b/board/MAI/bios_emulator/scitech/makedefs/qnxnto.mk deleted file mode 100644 index 5168ed269b..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/qnxnto.mk +++ /dev/null @@ -1,157 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# QNX Neutrino version for GNU C/C++ -# -############################################################################# - -# Disable warnings for macros redefined here that were given -# on the command line. -__.SILENT := $(.SILENT) -.SILENT := yes - -# Import enivornment variables that we use common to all compilers -.IMPORT .IGNORE : TEMP SHELL INCLUDE LIB SCITECH PRIVATE SCITECH_LIB -.IMPORT .IGNORE : DBG OPT OPT_SIZE SHW BETA CHECKED USE_QNX USE_QNXNTO -.IMPORT .IGNORE : USE_EGCS USE_PHOTON USE_X11 USE_BIOS - TMPDIR := $(TEMP) - -# Standard file suffix definitions -# -# NOTE: Qnx does not require any extension for executeable files, but you -# can use an extension if you wish. We use the .x extension for building -# executeable files so that we can use implicit rules to make the -# makefiles simpler and more portable between systems. When you install -# the files to a local bin directory, you will probably want to remove -# the .x extension. - L := .a # Libraries - E := .x # Executables - O := .o # Objects - A := .asm # Assembler sources - S := .s # GNU assembler sources - P := .cpp # C++ sources - -# File prefix/suffix definitions. The following prefixes are defined, and are -# used primarily to abstract between the Unix style libXX.a naming convention -# and the DOS/Windows/OS2 naming convention of XX.lib. - LP := lib # LP - Library file prefix (name of file on disk) - LL := -l # Library link prefix (name of library on link command line) - LE := # Library link suffix (extension of library on link command line) - -# We use the Unix shell at all times - SHELL := /bin/sh - SHELLFLAGS := -c - -# Definition of $(MAKE) macro for recursive makes. - MAKE = $(MAKECMD) $(MFLAGS) - -# Macro to install a library file - INSTALL := cp - -# DMAKE uses this recipe to remove intermediate targets -.REMOVE :; $(RM) -f $< - -# Turn warnings back to previous setting. -.SILENT := $(__.SILENT) - -# We dont use TABS in our makefiles -.NOTABS := yes - -# Define that we are compiling for QNX - USE_QNX := 1 - -# Default commands for compiling, assembling linking and archiving. - CC := qcc - CFLAGS := -Vgcc_ntox86 -I. -Iinclude $(INCLUDE) - CPPFLAGS := -Vgcc_ntox86 -I. -Iinclude $(INCLUDE) - CXX := QCC - AS := nasm - ASFLAGS := -t -f elf -d__FLAT__ -d__GNUC__ -dSTDCALL_MANGLE -iinclude -i$(SCITECH)/include -d__NOU__ - LD := qcc - LDFLAGS := -Vgcc_ntox86 -L. -lm - LIB := ar - LIBFLAGS := rc - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -g2 - LDFLAGS += -g2 -.ELSE -# NASM does not support debugging information yet - ASFLAGS += -.ENDIF - -# Optionally turn on optimisations -.IF $(OPT_MAX) - CFLAGS += -Ot -.ELIF $(OPT) - CFLAGS += -O -.ELIF $(OPT_SIZE) - CFLAGS += -Os -.ENDIF - -# Compile flag for whether to build photon or non-photon lib -.IF $(USE_PHOTON) - CFLAGS += -D__PHOTON__ -.ENDIF - -# Compile flag for whether to build X11 or non-X11 lib -.IF $(USE_X11) - CFLAGS += -D__X11__ -.ENDIF - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -dBETA -.ENDIF - -# Target environment dependant flags - CFLAGS += -D__QNX__ -D__UNIX__ - ASFLAGS += -d__QNX__ -d__UNIX__ - -# Define the base directory for library files - -.IF $(CHECKED) - LIB_BASE_DIR := $(SCITECH_LIB)/lib/debug - CFLAGS += -DCHECKED=1 -.ELSE - LIB_BASE_DIR := $(SCITECH_LIB)/lib/release -.ENDIF - -# Define where to install library files - LIB_DEST := $(LIB_BASE_DIR)/qnxnto - LDFLAGS += -L$(LIB_DEST) - -# Place to look for PMODE library files - -PMLIB := -lpm - -# Define which file contains our rules - - RULES_MAK := qnxnto.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/bc16.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/bc16.mk deleted file mode 100644 index 67ae9101b1..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/bc16.mk +++ /dev/null @@ -1,69 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Implicit generation rules for making object files -%$O: %.c ; $(CC) @$(mktmp $(CFLAGS:s/\/\\)) -c $< -%$O: %$P ; $(CC) @$(mktmp $(CFLAGS:s/\/\\)) -c $< -%$O: %$A ; $(AS) @$(mktmp $(ASFLAGS:s/\/\\)) $(<:s,/,\) - -# Implicit rule for building resource files -%$R: %.rc ; $(RC) $(RCFLAGS) -r $< - -# Implicit rule for building a DLL using a response file -%$D: ; $(LD) $(mktmp $(LDFLAGS) -C -Twd c0dl.obj+\n$(&:s/\/\\)\n$@\n$*.map\n$(DEF_LIBS) $(EXELIBS)\n$*.def) - -# Implicit rule for building a library file using response file -.IF $(BUILD_DLL) -%$L: ; - @$(RM) $@ - $(ILIB) $(ILIBFLAGS) $@ $? -.ELIF $(IMPORT_DLL) -%$L: ; - @$(RM) $@ - $(ILIB) $(ILIBFLAGS) $@ $? -.ELSE -%$L: ; - @$(RM) $@ - $(LIBR) $(LIBFLAGS) $@ @$(mktmp +$(&:t" &\n+")\n) -.ENDIF - -# Implicit rule for building an executable file using response file -.IF $(USE_WIN16) -%$E: ; $(LD) $(mktmp $(LDFLAGS) -C -Twe $(WIN_VERSION) c0wl.obj+\n$(&:s/\/\\)\n$@\n$*.map\n$(DEF_LIBS) $(EXELIBS)\n$*.def) -.ELSE -%$E: ; $(LD) $(mktmp $(LDFLAGS) -Tde c0l.obj+\n$(&:s/\/\\)\n$@\n$*.map\n$(PMLIB) $(DEF_LIBS) $(EXELIBS)) -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/bc3.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/bc3.mk deleted file mode 100644 index d4d071c0d8..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/bc3.mk +++ /dev/null @@ -1,43 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Implicit generation rules for making object files -%$O: %.c ; $(CC) @$(mktmp $(CFLAGS)) -c $< -%$O: %$P ; $(CC) @$(mktmp $(CFLAGS)) -c $< -%$O: %$A ; $(AS) @$(mktmp $(ASFLAGS)) $(<:s,/,\) - -# Implicit rule for building a library file using response file -%$L: ; - @$(RM) $@ - $(LIBR) $(LIBFLAGS) $@ @$(mktmp +$(&:t" &\n+")\n) - -# Implicit rule for building an executable file using response file -%$E: ; $(LD) $(mktmp $(LDFLAGS) -Tde c0l.obj+\n$(&:s/\/\\)\n$@\n$*.map\n$(DEF_LIBS) $(EXELIBS)) diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/bc32.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/bc32.mk deleted file mode 100644 index e3ce25bded..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/bc32.mk +++ /dev/null @@ -1,151 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -.IF $(USE_VXD) - -# Implicit rule generation to build VxD's - -%$O: %.c ; - $(CC) @$(mktmp $(CFLAGS:s/\/\\)) -c $(<:s,/,\) - @$(VTOOLSD)\bin\segalias.exe -p $(VTOOLSD)\include\default.seg $@ - -%$O: %$P ; - $(CC) @$(mktmp $(CFLAGS:s/\/\\)) -c $(<:s,/,\) - @$(VTOOLSD)\bin\segalias.exe -p $(VTOOLSD)\include\default.seg $@ - -%$O: %$A ; $(AS) @$(mktmp $(ASFLAGS:s/\/\\)) $(<:s,/,\) - -%$L: ; $(LIB) $(LIBFLAGS) $@ @$(mktmp -+$(?:t" &\n-+")\n) - -%.dll: ; - @$(CP) $(mktmp EXPORTS\n_The_DDB @1) $*.def - tlink32.exe @$(mktmp $(LDFLAGS) -Tpd $(VTOOLSD:s/\/\\)\lib\icrtbc4.obj+\n$(&:s/\/\\)\n$*.dll\n$*.map\n$(DEF_LIBS:s/\/\\) $(PMLIB:s/\/\\) $(EXELIBS:s/\/\\)\n$*.def) - @$(RM) -S $(mktmp $*.def) - -%.vxd: %.dll ; - @$(CP) $(mktmp DYNAMIC\nATTRIB ICODE INIT\nATTRIB LCODE LOCKED\nATTRIB PCODE PAGEABLE\nATTRIB SCODE STATIC\nATTRIB DBOCODE DEBUG\nMERGE ICODE INITDAT0 INITDATA) $*.pel - @$(VTOOLSD)\bin\vxdver.exe $*.vrc $*.res - @$(VTOOLSD)\bin\pele.exe -d -s $*.smf -c $*.pel -o $@ -k 400 $*.dll - @$(VTOOLSD)\bin\sethdr.exe -n $* -x $@ -r $*.res -.IF $(DBG) - $(NMSYM) /TRANS:source,package /SOURCE:$(VXDSOURCE) $*.smf -.ENDIF - @$(RM) -S $(mktmp $*.pel) - -.ELSE - -# Implicit generation rules for making object files, libraries and exe's - -%$O: %.c ; $(CC) @$(mktmp $(CFLAGS:s/\/\\)) -c $(<:s,/,\) -%$O: %$P ; $(CC) @$(mktmp $(CFLAGS:s/\/\\)) -c $(<:s,/,\) -.IF $(USE_NASM) -%$O: %$A ; $(AS) @$(mktmp -o $@ $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ELSE -%$O: %$A ; $(AS) @$(mktmp $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ENDIF - -# Implicit rule for building resource files -%$R: %.rc ; $(RC) $(RCFLAGS) -r $< - -# Implicit rule for building a DLL using a response file -.IF $(IMPORT_DLL) -.ELSE -.IF $(NO_RUNTIME) -%$D: ; $(LD) $(mktmp $(LDFLAGS) -Tpd -aa $(&:s/\/\\)\n$@\n$*.map\n$(EXELIBS)\n$*.def) -.ELSE -%$D: ; - makedef $(@:b) - $(LD) $(mktmp $(LDFLAGS) -Tpd -aa c0d32.obj+\n$(&:s/\/\\)\n$@\n$*.map\n$(DEF_LIBS:s/\/\\) $(PMLIB:s/\/\\) $(EXELIBS)\n$*.def) -.IF $(DBG) -.IF $(USE_SOFTICE) - $(NMSYM) $(NMSYMFLAGS);$(SI_SOURCE) $@ - tdstrp32 $@ -.ENDIF -.ENDIF -.ENDIF -.ENDIF - -# Implicit rule for building a library file using response file -.IF $(BUILD_DLL) -%$L: ; - @$(RM) $@ - $(ILIB) $(ILIBFLAGS) $@ $? -.ELIF $(IMPORT_DLL) -%$L: ; - @$(RM) $@ - $(ILIB) $(ILIBFLAGS) $@ $? -.ELSE -%$L: ; - @$(RM) $@ - $(LIB) $(LIBFLAGS) $@ @$(mktmp +$(&:t" &\n+")\n) -.ENDIF - -# Implicit rule for building an executable file using response file - -.IF $(USE_WIN32) -.IF $(WIN32_GUI) -%$E: ; - $(LD) $(mktmp $(LDFLAGS) -Tpe -aa $(WIN_VERSION) c0w32.obj+\n$(&:s/\/\\)\n$@\n$*.map\n$(DEF_LIBS:s/\/\\) $(PMLIB:s/\/\\) $(EXELIBS)\n$*.def) -.IF $(DBG) -.IF $(USE_SOFTICE) - $(NMSYM) $(NMSYMFLAGS);$(SI_SOURCE) $@ - tdstrp32 $@ -.ENDIF -.ENDIF -.ELSE -%$E: ; - $(LD) $(mktmp $(LDFLAGS) -Tpe -ap c0x32.obj+\n$(&:s/\/\\)\n$@\n$*.map\n$(DEF_LIBS:s/\/\\) $(PMLIB:s/\/\\) $(EXELIBS)\n$*.def) -.IF $(USE_SOFTICE) - $(NMSYM) $(NMSYMFLAGS);$(SI_SOURCE) $@ - tdstrp32 $@ -.ENDIF -.ENDIF -.ELIF $(USE_TNT) -%$E: ; - @$(CP) $(mktmp stub 'gotnt.exe') $*.def - @$(LD) $(mktmp $(LDFLAGS) -Tpe -ap c0x32.obj+\n$(&:s/\/\\)\n$@\n$*.map\n$(DEF_LIBS) $(PMLIB:s/\/\\) $(EXELIBS)\n$*.def) -.IF $(DOSSTYLE) - @markphar $@ -.ENDIF - @$(RM) -S $(mktmp $*.def) -.ELIF $(USE_SMX32) -%$E: ; $(LD) $(mktmp $(LDFLAGS) -Tpe -ap c0x32.obj+\n$(&:s/\/\\)\n$@\n$*.map\n$(DEF_LIBS) $(PMLIB:s/\/\\) $(EXELIBS)\n$*.def) -.ELSE -%$E: ; $(LD) $(mktmp $(LDFLAGS) -Tpe -ap c0x32.obj+\n$(&:s/\/\\)\n$@\n$*.map\n$(DEF_LIBS) $(PMLIB:s/\/\\) $(EXELIBS)\n$*.def) -.END - -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/bcos2.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/bcos2.mk deleted file mode 100644 index f473fecf49..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/bcos2.mk +++ /dev/null @@ -1,70 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Implicit generation rules for making object files -%$O: %.c ; $(CC) @$(mktmp $(CFLAGS:s/\/\\)) -c $(<:s,/,\) -%$O: %$P ; $(CC) @$(mktmp $(CFLAGS:s/\/\\)) -c $(<:s,/,\) -.IF $(USE_NASM) -%$O: %$A ; $(AS) @$(mktmp -o $@ $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ELSE -%$O: %$A ; $(AS) @$(mktmp $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ENDIF - -# Implicit rule for building resource files -%$R: %.rc ; $(RC) $(RCFLAGS) -r $< - -# Implicit rule for building a DLL using a response file -%$D: ; - makedef $(@:b) - $(LD) $(mktmp $(LDFLAGS) -Tod -aa c02d.obj+\n$(&:s/\/\\)\n$@\n$*.map\n$(DEF_LIBS:s/\/\\) $(EXELIBS)\n$*.def) - -# Implicit rule for building a library file using response file -.IF $(BUILD_DLL) -%$L: ; - @$(RM) $@ - $(ILIB) $(ILIBFLAGS) $@ $? -.ELIF $(IMPORT_DLL) -%$L: ; - @$(RM) $@ - $(ILIB) $(ILIBFLAGS) $@ $? -.ELSE -%$L: ; - @$(RM) $@ - $(LIB) $(LIBFLAGS) $@ @$(mktmp +$(&:t" &\n+")\n) -.ENDIF - -# Implicit rule for building an executable file using response file - -.IF $(USE_OS2GUI) -%$E: ; $(LD) $(mktmp $(LDFLAGS) -Toe -aa c02.obj+\n$(&:s/\/\\)\n$@\n$*.map\n$(DEF_LIBS:s/\/\\) $(EXELIBS)\n$*.def) -.ELSE -%$E: ; $(LD) $(mktmp $(LDFLAGS) -Toe -ap c02.obj+\n$(&:s/\/\\)\n$@\n$*.map\n$(DEF_LIBS:s/\/\\) $(EXELIBS)\n$*.def) -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/cl16.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/cl16.mk deleted file mode 100644 index 6489a3ee43..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/cl16.mk +++ /dev/null @@ -1,67 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Implicit generation rules for making object files -%$O: %.c ; $(CC) /nologo $(CFLAGS) /c $< -%$O: %$P ; $(CC) /nologo $(CFLAGS) /c $< -%$O: %$A ; $(AS) $(ASFLAGS) $< $* NUL NUL - -# Implicit rule for building resource files -%$R: %.rc ; $(RC) $(RCFLAGS) -r $< - -# Implicit rule for building a DLL using a response file -#%$D: ; rclink $(LD) $(RC) $@ $(mktmp $(LDFLAGS:s/\/\\) -e$@\n$(&:t"\n":s/\/\\)\n$(EXELIBS)) -#%$D: ; $(LD) $(LDFLAGS) /Fe$@ $& $(EXELIBS) -%$D: ; link @default.rsp - - -# Implicit rule for building a library file using response file -.IF $(BUILD_DLL) -%$L: ; $(ILIB) $(ILIBFLAGS) $@ $? -.ELIF $(IMPORT_DLL) -%$L: ; $(ILIB) $(ILIBFLAGS) $@ $? -.ELSE -%$L: ; $(LIB) /nologo $(LIBFLAGS) $@ @$(mktmp -+$(?:t" &\n-+") &\n,,\n) -.ENDIF - -# Implicit rule for building an executable file using response file -.IF $(USE_WIN16) -#%$E: ; rclink $(LD) $(RC) $@ $(mktmp $(LDFLAGS) /Fe$@ $(&:s/\/\\) $(EXELIBS)) -%$E: ; $(LD) @$(mktmp $(LDFLAGS) /Fe$@ $(&:s/\/\\) $(EXELIBS)) -.ELSE -%$E: ; $(LD) @$(mktmp $(LDFLAGS) /Fe$@ $(&:s/\/\\) $(PMLIB) $(EXELIBS)) -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/cl386.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/cl386.mk deleted file mode 100644 index f50b2749e4..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/cl386.mk +++ /dev/null @@ -1,69 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Implicit generation rules for making object files -%$O: %.c ; $(CC) -nologo $(CFLAGS) -c $< -%$O: %$P ; $(CC) -nologo $(CFLAGS) -c $< -%$O: %$A ; $(AS) $(ASFLAGS) $< $* NUL NUL - -# Implicit rule for building resource files -%$R: %.rc ; $(RC) $(RCFLAGS) -r $< - -# Implicit rule for building a DLL using a response file -#%$D: ; rclink $(LD) $(RC) $@ $(mktmp $(LDFLAGS:s/\/\\) -e$@\n$(&:t"\n":s/\/\\)\n$(EXELIBS)) -#%$D: ; $(LD) $(LDFLAGS) /Fe$@ $& $(EXELIBS) -%$D: ; link386 @default.rsp - -# Implicit rule for building a device driver using a response file -%.SYS: ; link386 @default.rsp - -# Implicit rule for building a library file using response file -.IF $(BUILD_DLL) -%$L: ; $(ILIB) $(ILIBFLAGS) $@ $? -.ELIF $(IMPORT_DLL) -%$L: ; $(ILIB) $(ILIBFLAGS) $@ $? -.ELSE -%$L: ; $(LIB) /nologo $(LIBFLAGS) $@ @$(mktmp -+$(?:t" &\n-+") &\n,,\n) -.ENDIF - -# Implicit rule for building an executable file using response file -.IF $(USE_WIN16) -#%$E: ; rclink $(LD) $(RC) $@ $(mktmp $(LDFLAGS) /Fe$@ $(&:s/\/\\) $(EXELIBS)) -%$E: ; $(LD) @$(mktmp $(LDFLAGS) /Fe$@ $(&:s/\/\\) $(EXELIBS)) -.ELSE -%$E: ; $(LD) @$(mktmp $(LDFLAGS) /Fe$@ $(&:s/\/\\) $(PMLIB) $(EXELIBS)) -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/dj32.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/dj32.mk deleted file mode 100644 index 9f917bbdd9..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/dj32.mk +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Implicit generation rules for making object files -%$O: %.c ; $(CC) @$(mktmp $(CFLAGS:s/\/\\) -c) $(<:s,/,\) -%$O: %$P ; $(CC) @$(mktmp $(CFLAGS:s/\/\\) -c) $(<:s,/,\) -%$O: %$A ; $(AS) @$(mktmp -o $@ $(ASFLAGS:s/\/\\)) $(<:s,/,\) - -# Implicit rule for building a library file using response file -%$L: ; $(LIB) $(LIBFLAGS) $@ @$(mktmp $(&:s/\/\\)\n) - -# Implicit rule for building an executable file using response file -%$E: ; $(LD) $(LDFLAGS) $@ @$(mktmp $(&:s/\/\\) $(EXELIBS) $(PMLIB) -lstdcxx -lm) diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/emx.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/emx.mk deleted file mode 100644 index 26d223ad41..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/emx.mk +++ /dev/null @@ -1,91 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -# OS/2 version for EMX/GNU C/C++. -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Implicit generation rules for making object files -%$O: %.c ; -.IF $(SHOW_ARGS) - $(CC) -c $(CFLAGS) $(<:s,\,/) -.ELSE - @echo $(CC) -c $(<:s,\,/) - @$(CC) -c $(CFLAGS) $(<:s,\,/) -.ENDIF - -%$O: %$P ; -.IF $(SHOW_ARGS) - $(CXX) -c $(CFLAGS) $(<:s,\,/) -.ELSE - @echo $(CXX) -c $(<:s,\,/) - @$(CXX) -c $(CFLAGS) $(<:s,\,/) -.ENDIF - -%$O: %$A ; -.IF $(USE_NASM) -.IF $(SHOW_ARGS) - $(AS) -o $@ $(ASFLAGS) $(<:s,\,/) -.ELSE - @echo $(AS) $(<:s,\,/) - @$(AS) @$(mktmp -o $@ $(ASFLAGS)) $(<:s,\,/) -.ENDIF -.ELSE -.IF $(SHOW_ARGS) - - $(AS) @$(mktmp $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ELSE - @echo $(AS) $(<:s,/,\) - $(AS) @$(mktmp $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ENDIF -.ENDIF - -# Implicit rule for building a library file using response file -%$L: ; -.IF $(SHOW_ARGS) - $(LIB) $(LIBFLAGS) $@ $(&:s,\,/) -.ELSE - @echo $(LIB) $@ - @$(LIB) $(LIBFLAGS) $@ @$(mktmp $(?:t"\n")) -.ENDIF - -# Implicit rule for building an executable file using response file -%$E: ; -.IF $(SHOW_ARGS) - $(LD) $(LDFLAGS) -o $@ $(&:s,\,/) $(EXELIBS) $(PMLIB) -lgpp -lstdcpp -.ELSE - @echo $(LD) $@ - @$(LD) $(LDFLAGS) -o $@ $(&:s,\,/) $(EXELIBS) $(PMLIB) -lgpp -lstdcpp -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_beos.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_beos.mk deleted file mode 100644 index 681b698fc2..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_beos.mk +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Implicit generation rules for making object files from source files -%$O: %.c ; $(CC) $(CFLAGS) -c $< -%$O: %$P ; $(CXX) $(CFLAGS) -c $< -%$O: %$A ; $(AS) $(ASFLAGS) $< - -# Implicit rule for building a library file -%$L: ; $(LIB) $(LIBFLAGS) $@ $& - -# Implicit rule for building an executable file -%$E: ; $(LD) $(LDFLAGS) -o $@ $& $(EXELIBS) $(PMLIB) diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_freebsd.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_freebsd.mk deleted file mode 100644 index 9b4d236216..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_freebsd.mk +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Implicit generation rules for making object files from source files -%$O: %.c ; $(CC) $(CFLAGS) -c $< -%$O: %$P ; $(CXX) $(CFLAGS) -c $< -%$O: %$A ; $(AS) -o $@ $(ASFLAGS) $< - -# Implicit rule for building a library file -%$L: ; $(LIB) $(LIBFLAGS) $@ $& - -# Implicit rule for building an executable file -%$E: ; $(LD) $(LDFLAGS) -o $@ $& $(EXELIBS) $(PMLIB) -lm diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_linux.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_linux.mk deleted file mode 100644 index 5f91fe53f4..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_linux.mk +++ /dev/null @@ -1,93 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -.IF $(USE_CXX_LINKER) -LD := $(LDXX) -.ENDIF - -# Implicit generation rules for making object files from source files -%$O: %.c ; -.IF $(SHOW_ARGS) - $(CC) -c $(CFLAGS) $< -.ELSE - @$(ECHO) $(CC) $(SHOW_CFLAGS) $< - @$(CC) -c $(CFLAGS) $< -.ENDIF - -%$O: %$P ; -.IF $(SHOW_ARGS) - $(CXX) -c $(CFLAGS) $< -.ELSE - @$(ECHO) $(CXX) $(SHOW_CFLAGS) $< - @$(CXX) -c $(CFLAGS) $< -.ENDIF - -%$O: %$A ; -.IF $(SHOW_ARGS) - $(AS) -o $@ $(ASFLAGS) $< -.ELSE - @$(ECHO) $(AS) $(SHOW_ASFLAGS) $< - @$(AS) @$(mktmp -o $@ $(ASFLAGS)) $< -.ENDIF - -# Implicit rule for building a library file -.IF $(BUILD_DLL) -%$L: ; -.IF $(SHOW_ARGS) - $(LIB) $(LIBFLAGS) -Wl,-soname,$@.$(VERSIONMAJ) -o $@ $& $(LIBS) -.ELSE - @$(ECHO) $(LIB) $@ - @$(LIB) $(LIBFLAGS) -Wl,-soname,$@.$(VERSIONMAJ) -o $@ $& $(LIBS) -.ENDIF -.ELSE -%$L: ; -.IF $(SHOW_ARGS) - $(LIB) $(LIBFLAGS) $@ $& -.ELSE - @$(ECHO) $(LIB) $@ - @$(LIB) $(LIBFLAGS) $@ $& -.ENDIF -.ENDIF - -# Implicit rule for building an executable file -%$E: ; -.IF $(SHOW_ARGS) - $(LD) $(LDFLAGS) -o $@ $& $(EXELIBS) $(PMLIB) -lm -.ELSE - @$(ECHO) ld $@ - @$(LD) $(LDFLAGS) -o $@ $& $(EXELIBS) $(PMLIB) -lm -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_win32.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_win32.mk deleted file mode 100644 index 485d166ac4..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_win32.mk +++ /dev/null @@ -1,90 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -.IF $(USE_CXX_LINKER) -LD := $(LDXX) -.ENDIF - -# Implicit generation rules for making object files from source files -%$O: %.c ; -.IF $(SHOW_ARGS) - $(CC) -c $(CFLAGS:s/\/\\) $(<:s,/,\) -.ELSE - @$(ECHO) $(CC) $(SHOW_CFLAGS:s/\/\\) $(<:s,/,\) - @$(CC) -c $(CFLAGS:s/\/\\) $(<:s,/,\) -.ENDIF - -%$O: %$P ; -.IF $(SHOW_ARGS) - $(CXX) -c $(CFLAGS:s/\/\\) $(<:s,/,\) -.ELSE - @$(ECHO) $(CXX) $(SHOW_CFLAGS:s/\/\\) $(<:s,/,\) - @$(CXX) -c $(CFLAGS:s/\/\\) $(<:s,/,\) -.ENDIF - -%$O: %$A ; -.IF $(SHOW_ARGS) - $(AS) -o $(ASFLAGS:s/\/\\) $(<:s,/,\) -.ELSE - @$(ECHO) $(AS) $(SHOW_ASFLAGS:s/\/\\) $(<:s,/,\) - @$(AS) @$(mktmp -o $@ $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ENDIF - -# Implicit rule for building resource files -%$R: %.rc ; $(RC) $< $(RCFLAGS) -o $@ - -# Implicit rule for building a DLL -# TODO! -#%$D: ; +rclink $(LD) $(RC) $@ $(mktmp $(LDFLAGS) /Fe$@ $(&:t"\n"s/\/\\) $(PMLIB) $(EXELIBS) $(DEF_LIBS) $(LDENDFLAGS)) - -# Implicit rule for building a library file -%$L: ; -.IF $(SHOW_ARGS) - $(LIB) $(LIBFLAGS) $@ $& -.ELSE - @$(ECHO) $(LIB) $@ - @$(LIB) $(LIBFLAGS) $@ @$(mktmp $(&:s/\/\\)\n) -.ENDIF - -# Implicit rule for building an executable file -%$E: ; -.IF $(SHOW_ARGS) - $(LD) $(LDFLAGS) -o $@ $& $(EXELIBS) $(PMLIB) -lm -.ELSE - @$(ECHO) ld $@ - @$(LD) $(LDFLAGS) -o $@ @$(mktmp $(&:s/\/\\) $(EXELIBS) $(PMLIB) -lm) -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/hc32.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/hc32.mk deleted file mode 100644 index 011e9ab3a4..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/hc32.mk +++ /dev/null @@ -1,51 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Implicit generation rules for making object files -%$O: %.c ; $(CC) $(CFLAGS) -c $< -%$O: %$P ; $(CC) $(CFLAGS) -c $< -.IF $(USE_NASM) -%$O: %$A ; $(AS) @$(mktmp -o $@ $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ELSE -%$O: %$A ; $(AS) @$(mktmp $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ENDIF - -# Implicit rule for building a library file using response file -%$L: ; $(LIB) $(LIBFLAGS) $@ @$(mktmp,$*.rsp -R $?) - -# Implicit rule for building an executable file using response file -%$E: ; $(LD) $(LDFLAGS) -o $@ @$(mktmp $(&:s/\/\\) $(PMLIB) $(EXELIBS) -ldosx32.lib) diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/qnx4.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/qnx4.mk deleted file mode 100644 index 55dc035500..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/qnx4.mk +++ /dev/null @@ -1,94 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Whether to link in real VBIOS library, or just the stub library - -.IF $(USE_BIOS) -VBIOSLIB := -lvbios.lib -.ELSE -VBIOSLIB := -lvbstubs.lib -.END - -# Require special privledges for Nucleus programs (requires root access) - -.IF $(USE_NUCLEUS) -LDFLAGS += -T1 -.ENDIF - -# Implicit generation rules for making object files from source files -%$O: %.c ; -.IF $(SHOW_ARGS) - $(CC) $(CFLAGS) $< -.ELSE - @echo $(CC) -c $< - +@$(CC) $(CFLAGS) $< > /dev/null -.ENDIF - -%$O: %$P ; -.IF $(SHOW_ARGS) - $(CXX) $(CFLAGS) $< -.ELSE - @echo $(CXX) -c $< - +@$(CXX) $(CFLAGS) $< > /dev/null -.ENDIF - -%$O: %$A ; -.IF $(SHOW_ARGS) - $(AS) -o $@ $(ASFLAGS) $< -.ELSE - @echo $(AS) $< - @$(AS) -o $@ $(ASFLAGS) $< -.ENDIF - -# Implicit rule for building a library file -%$L: ; -.IF $(SHOW_ARGS) - $(LIB) $(LIBFLAGS) -q $@ $& -.ELSE - @echo $(LIB) $@ - +@$(LIB) $(LIBFLAGS) -q $@ $& > /dev/null -.ENDIF - - -# Implicit rule for building an executable file -%$E: ; -.IF $(SHOW_ARGS) - $(LD) $(LDFLAGS) -o $@ $& $(EXELIBS) $(PMLIB) $(VBIOSLIB) -.ELSE - @echo wlink $@ - +@$(LD) $(LDFLAGS) -o $@ $& $(EXELIBS) $(PMLIB) $(VBIOSLIB) > /dev/null -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/qnxnto.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/qnxnto.mk deleted file mode 100644 index c43ad1f642..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/qnxnto.mk +++ /dev/null @@ -1,55 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Whether to link in real VBIOS library, or just the stub library - -.IF $(USE_BIOS) -VBIOSLIB := -lvbios -.ELSE -VBIOSLIB := -lvbstubs -.END - -# Implicit generation rules for making object files from source files -%$O: %.c ; $(CC) $(CFLAGS) -c $< -%$O: %$P ; $(CXX) $(CPPFLAGS) -c $< -%$O: %$A ; $(AS) -o $@ $(ASFLAGS) $< - -# Implicit rule for building a library file -%$L: ; $(LIB) $(LIBFLAGS) $@ $& - -# Implicit rule for building an executable file -%$E: ; $(LD) $(LDFLAGS) -o $@ $& $(EXELIBS) $(PMLIB) $(VBIOSLIB) diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/sc16.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/sc16.mk deleted file mode 100644 index b33bcd86a0..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/sc16.mk +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Implicit generation rules for making object files -%$O: %.c ; $(CC) $(CFLAGS) -c $< -%$O: %$P ; $(CC) $(CFLAGS) -c $< -%$O: %$A ; $(AS) @$(mktmp $(ASFLAGS)) $(<:s,/,\) - -# Implicit rule for building resource files -%$R: %.rc ; $(RC) $(RCFLAGS) -r $< - -# Implicit rule for building a DLL using a response file -%$D: ; $(LD) $(LDFLAGS) @$(mktmp $(&:s/\/\\) $(EXELIBS)) - -# Implicit rule for building a library file using response file -.IF $(BUILD_DLL) -%$L: ; $(ILIB) $(ILIBFLAGS) $@ $? -.ELIF $(IMPORT_DLL) -%$L: ; $(ILIB) $(ILIBFLAGS) $@ $? -.ELSE -%$L: ; $(LIB) $(LIBFLAGS) $@ @$(mktmp -+$(?:t" &\n-+")\n) -.ENDIF - -# Implicit rule for building an executable file using response file -.IF $(USE_WIN16) -%$E: ; $(LD) $(LDFLAGS) @$(mktmp $(&:s/\/\\) $(EXELIBS)) -.ELSE -%$E: ; $(LD) $(LDFLAGS) @$(mktmp $(&:s/\/\\) $(PMLIB) $(EXELIBS)) -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/sc32.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/sc32.mk deleted file mode 100644 index 2231906d66..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/sc32.mk +++ /dev/null @@ -1,69 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Implicit generation rules for making object files -%$O: %.c ; $(CC) $(CFLAGS) -c $< -%$O: %$P ; $(CC) $(CFLAGS) -c $< -.IF $(USE_NASM) -%$O: %$A ; $(AS) @$(mktmp -o $@ $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ELSE -%$O: %$A ; $(AS) @$(mktmp $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ENDIF - -# Implicit rule for building resource files -%$R: %.rc ; $(RC) $(RCFLAGS) -r $< - -# Implicit rule for building a DLL using a response file -%$D: ; $(LD) $(LDFLAGS) @$(mktmp,$*.lnk $(&:s/\/\\) $(EXELIBS) kernel32.lib user32.lib gdi32.lib winmm.lib comdlg32.lib advapi32.lib) - -# Implicit rule for building a library file using response file -.IF $(BUILD_DLL) -%$L: ; $(ILIB) $(ILIBFLAGS) $@ $? -.ELIF $(IMPORT_DLL) -%$L: ; $(ILIB) $(ILIBFLAGS) $@ $? -.ELSE -%$L: ; $(LIB) $(LIBFLAGS) $@ @$(mktmp -+$(?:t" &\n-+")\n) -.ENDIF - -# Implicit rule for building an executable file using response file -.IF $(USE_TNT) -%$E: ; $(LD) $(LDFLAGS) @$(mktmp,$*.lnk $(&:s/\/\\) $(PMLIB) $(EXELIBS)) -.ELIF $(USE_WIN32) -%$E: ; $(LD) $(LDFLAGS) @$(mktmp,$*.lnk $(&:s/\/\\) $(EXELIBS) kernel32.lib user32.lib gdi32.lib winmm.lib comdlg32.lib advapi32.lib) -.ELSE -%$E: ; $(LD) $(LDFLAGS) @$(mktmp,$*.lnk $(&:s/\/\\) $(PMLIB) $(EXELIBS)) -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/va32.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/va32.mk deleted file mode 100644 index 1a20319cba..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/va32.mk +++ /dev/null @@ -1,82 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Implicit generation rules for making object files -%$O: %.c ; $(CC) -c @$(mktmp $(CFLAGS:s/\/\\)) $(<:s,/,\) -%$O: %$P ; $(CPP) -c @$(mktmp $(CFLAGS:s/\/\\)) $(<:s,/,\) -.IF $(USE_NASM) -%$O: %$A ; $(AS) @$(mktmp -o $@ $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ELSE -%$O: %$A ; $(AS) @$(mktmp $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ENDIF - -# Implicit rule for building resource files -%$R: %.rc ; $(RC) $(RCFLAGS) -r $< - -# Implicit rule for building help files -%.hlp: %.ipf; $(IPFC) $(IPFCFLAGS) $< - -# Implicit rule for building a DLL using a response file -.IF $(USE_OS2GUI) -%$D: ; rclink $(LD) $(RC) $@ $(mktmp $(LDFLAGS) $(&:t"+\n":s/\/\\)\n$@\n$*.map\n$(EXELIBS) $(PMLIB)\n$*.def\n) -.ELSE -%$D: ; $(LD) /nofree /nol @$(mktmp $(LDFLAGS) $(&:t"+\n":s/\/\\)\n$@\n$*.map\n$(EXELIBS) $(PMLIB)\n$*.def\n) -.ENDIF - -# Implicit rule for building a library file using response file -.IF $(BUILD_DLL) -%$L: ; $(ILIB) $(ILIBFLAGS) $@ $? -.ELIF $(IMPORT_DLL) -%$L: ; $(ILIB) $(ILIBFLAGS) $@ $? -.ELSE -%$L: ; $(LIB) $(LIBFLAGS) @$(mktmp $@-+$(?:t"&\n-+":s/\/\\);) -.ENDIF - -# Implicit rule for building an executable file using response file -.IF $(USE_OS2GUI) -%$E: ; - rclink $(LD) $(RC) $@ $(mktmp $(LDFLAGS) $(&:t"+\n":s/\/\\)\n$@\n$*.map\n$(EXELIBS) $(PMLIB)\n$*.def\n) -.IF $(LXLITE) - lxlite $@ -.ENDIF -.ELSE -%$E: ; - rclink $(LD) $(RC) $@ $(mktmp $(LDFLAGS) $(&:t"+\n":s/\/\\)\n$@\n$*.map\n$(EXELIBS) $(PMLIB)\n\n) -.IF $(LXLITE) - lxlite $@ -.ENDIF -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/va365.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/va365.mk deleted file mode 100644 index 2b4180146a..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/va365.mk +++ /dev/null @@ -1,79 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Implicit generation rules for making object files -%$O: %.c ; $(CC) -c @$(mktmp $(CFLAGS:s/\/\\)) $(<:s,/,\) -%$O: %$P ; $(CPP) -c @$(mktmp $(CFLAGS:s/\/\\)) $(<:s,/,\) -.IF $(USE_NASM) -%$O: %$A ; $(AS) @$(mktmp -o $@ $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ELSE -%$O: %$A ; $(AS) @$(mktmp $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ENDIF - -# Implicit rule for building resource files -%$R: %.rc ; $(RC) $(RCFLAGS) -r $< - -# Implicit rule for building a DLL using a response file -.IF $(USE_OS2GUI) -%$D: ; rclink $(LD) $(RC) $@ $(mktmp $(LDFLAGS) $(&:t"+\n":s/\/\\)\n$@\n$*.map\n$(EXELIBS) $(PMLIB)\n$*.def\n) -.ELSE -%$D: ; $(LD) /nofree /nol @$(mktmp $(LDFLAGS) $(&:t"+\n":s/\/\\)\n$@\n$*.map\n$(EXELIBS) $(PMLIB)\n$*.def\n) -.ENDIF - -# Implicit rule for building a library file using response file -.IF $(BUILD_DLL) -%$L: ; $(ILIB) $(ILIBFLAGS) /out:$@ $? -.ELIF $(IMPORT_DLL) -%$L: ; $(ILIB) $(ILIBFLAGS) /out:$@ $? -.ELSE -%$L: ; $(LIB) $(LIBFLAGS) /nowarn:86 /out:$@ @$(mktmp $(?:t"\n":s/\/\\)) -.ENDIF - -# Implicit rule for building an executable file using response file -.IF $(USE_OS2GUI) -%$E: ; - rclink $(LD) $(RC) $@ $(mktmp $(LDFLAGS) $(&:t"+\n":s/\/\\)\n$@\n$*.map\n$(EXELIBS) $(PMLIB)\n$*.def\n) -.IF $(LXLITE) - lxlite $@ -.ENDIF -.ELSE -%$E: ; - rclink $(LD) $(RC) $@ $(mktmp $(LDFLAGS) $(&:t"+\n":s/\/\\)\n$@\n$*.map\n$(EXELIBS) $(PMLIB)\n\n) -.IF $(LXLITE) - lxlite $@ -.ENDIF -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/vc16.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/vc16.mk deleted file mode 100644 index 6ffc270c01..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/vc16.mk +++ /dev/null @@ -1,70 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Implicit generation rules for making object files -%$O: %.c ; $(CC) /nologo $(CFLAGS) /c $< -%$O: %$P ; $(CC) /nologo $(CFLAGS) /c $< -%$O: %$A ; $(AS) @$(mktmp $(ASFLAGS)) $(<:s,/,\) - -# Implicit rule for building resource files -%$R: %.rc ; $(RC) $(RCFLAGS) -r $< - -# Implicit rule for building a DLL using a response file -%$D: ; rclink $(LD) $(RC) $@ $(mktmp $(LDFLAGS) -e$@\n$(&:t"\n":s/\/\\)\n$(EXELIBS)) - -# Implicit rule for building a library file using response file -.IF $(BUILD_DLL) -%$L: ; - @$(RM) $@ - $(ILIB) $(ILIBFLAGS) $@ $? -.ELIF $(IMPORT_DLL) -%$L: ; - @$(RM) $@ - $(ILIB) $(ILIBFLAGS) $@ $? -.ELSE -%$L: ; - @$(RM) $@ - $(LIB) $@ /nologo $(LIBFLAGS) @$(mktmp +$(&:t" &\n+") &\n,\n) -.ENDIF - -# Implicit rule for building an executable file using response file -.IF $(USE_WIN16) -%$E: ; rclink $(LD) $(RC) $@ $(mktmp $(LDFLAGS) /Fe$@ $(&:s/\/\\) $(EXELIBS)) -#%$E: ; $(LD) @$(mktmp $(LDFLAGS) /Fe$@ $(&:s/\/\\) $(EXELIBS)) -.ELSE -%$E: ; $(LD) @$(mktmp $(LDFLAGS) /Fe$@ $(&:s/\/\\) $(PMLIB) $(EXELIBS)) -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/vc32.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/vc32.mk deleted file mode 100644 index 97f1a0c162..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/vc32.mk +++ /dev/null @@ -1,122 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Turn on pre-compiled headers as neccessary -.IF $(PRECOMP_HDR) - CFLAGS += -YX"$(PRECOMP_HDR)" -.ENDIF - -# Turn on runtime type information as necessary -.IF $(USE_RTTI) - CFLAGS += /GR -.ENDIF - -# Turn on C++ exception handling as necessary -.IF $(USE_CPPEXCEPT) - CFLAGS += /GX -.ENDIF - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Implicit generation rules for making object files -%$O: %.c ; $(CC) /nologo @$(mktmp $(CFLAGS:s/\/\\)) /c $(<:s,/,\) -%$O: %$P ; $(CC) /nologo @$(mktmp $(CFLAGS:s/\/\\)) /c $(<:s,/,\) -.IF $(USE_NASM) -%$O: %$A ; $(AS) @$(mktmp -o $@ $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ELSE -%$O: %$A ; $(AS) @$(mktmp $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ENDIF - -# Implicit rule for building resource files -%$R: %.rc ; $(RC) $(RCFLAGS) -r $< - -# Implicit rules for building NT device drivers - -%.sys: ; - $(LD) /nologo @$(mktmp $(LDFLAGS) /Fe$@ $(&:t"\n"s/\/\\) $(PMLIB) $(EXELIBS) $(DEF_LIBS) $(LDENDFLAGS)) -.IF $(DBG) -.IF $(USE_SOFTICE) - $(NMSYM) $(NMSYMFLAGS);$(SI_SOURCE) $@ -.ENDIF -.ENDIF - -# Implicit rule for building a DLL using a response file -.IF $(IMPORT_DLL) -.ELSE -.IF $(NO_RUNTIME) -%$D: ; $(LD) /nologo @$(mktmp $(LDFLAGS) /Fe$@ $(&:t"\n"s/\/\\) $(EXELIBS) $(DEF_LIBS) $(LDENDFLAGS)) -.ELSE -%$D: ; - makedef -v $* - $(LD) /nologo @$(mktmp $(LDFLAGS) /Fe$@ $(&:t"\n"s/\/\\) $(PMLIB) $(EXELIBS) $(DEF_LIBS) $(LDENDFLAGS)) -.IF $(DBG) -.IF $(USE_SOFTICE) - $(NMSYM) $(NMSYMFLAGS);$(SI_SOURCE) $@ -.ENDIF -.ENDIF -.ENDIF -.ENDIF - -# Implicit rule for building a library file using response file. Note that -# we use a special .VCD file that contains the EXPORT definitions for the -# Microsoft compiler, since the LIB utility automatically adds leading -# underscores to exported functions. -.IF $(IMPORT_DLL) -%$L: ; - makedef -v $(?:b) - @$(RM) $@ - $(ILIB) $(ILIBFLAGS) /DEF:$(?:b).def /OUT:$@ -.ELSE -%$L: ; - @$(RM) $@ - $(LIB) $(LIBFLAGS) /out:$@ @$(mktmp $(&:t"\n")\n) -.ENDIF - -# Implicit rule for building an executable file using response file -.IF $(USE_WIN32) -%$E: ; - $(LD) /nologo @$(mktmp $(LDFLAGS) /Fe$@ $(&:t"\n"s/\/\\) $(PMLIB) $(EXELIBS) $(DEF_LIBS) $(LDENDFLAGS)) -.IF $(DBG) -.IF $(USE_SOFTICE) - $(NMSYM) $(NMSYMFLAGS);$(SI_SOURCE) $@ -.ENDIF -.ENDIF -.ELSE -%$E: ; - @$(LD) /nologo @$(mktmp $(LDFLAGS) /Fe$@ $(&:t"\n"s/\/\\) $(PMLIB) $(EXELIBS) $(DEF_LIBS) $(LDENDFLAGS)) -.IF $(DOSSTYLE) - @markphar $@ -.ENDIF -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/wc16.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/wc16.mk deleted file mode 100644 index d1ca9176ef..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/wc16.mk +++ /dev/null @@ -1,79 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Implicit generation rules for making object files -%$O: %.c ; $(CC) @$(mktmp $(CFLAGS)) $< -%$O: %$P ; $(CPP) @$(mktmp $(CFLAGS)) $< -%$O: %$A ; $(AS) @$(mktmp $(ASFLAGS)) $(<:s,/,\) - -# Implicit rule for building resource files -%$R: %.rc ; $(RC) $(RCFLAGS) -r $< - -# Implicit rule for building a library file using response file -.IF $(BUILD_DLL) -%$L: ; - @$(RM) $@ - $(ILIB) $(ILIBFLAGS) $@ +$? -.ELIF $(IMPORT_DLL) -%$L: ; - @$(RM) $@ - $(ILIB) $(ILIBFLAGS) $@ +$? -.ELSE -%$L: ; - @$(RM) $@ - $(LIB) $(LIBFLAGS) $@ @$(mktmp,$*.rsp +$(&:t"\n+":s/\/\\)\n) -.ENDIF - -# Implicit rule for building an executable file using response file -.IF $(USE_WIN16) -.IF $(BUILD_DLL) -%$E: ; - @trimlib $(mktmp $(LDFLAGS) OP quiet SYS windows_dll\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(EXELIBS:t",")) $*.lnk - rclink $(LD) $(RC) $@ $*.lnk - @$(RM) -S $(mktmp $*.lnk) -.ELSE -%$E: ; - @trimlib $(mktmp $(LDFLAGS) OP quiet SYS windows\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(EXELIBS:t",")) $*.lnk - rclink $(LD) $(RC) $@ $*.lnk - @$(RM) -S $(mktmp $*.lnk) -.ENDIF -.ELSE -%$E: ; - @trimlib $(mktmp OP quiet\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB) $(EXELIBS:t",")) $*.lnk - $(LD) $(LDFLAGS) @$*.lnk - @$(RM) -S $(mktmp $*.lnk) -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/rules/wc32.mk b/board/MAI/bios_emulator/scitech/makedefs/rules/wc32.mk deleted file mode 100644 index 39b8819b2b..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/rules/wc32.mk +++ /dev/null @@ -1,264 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Rules makefile definitions, which define the rules used to -# build targets. We include them here at the end of the -# makefile so the generic project makefiles can override -# certain things with macros (such as linking C++ programs -# differently). -# -############################################################################# - -# Take out PMLIB if we don't need to link with it - -.IF $(NO_PMLIB) -PMLIB := -.ENDIF - -# Use a larger stack during linking if requested, or use a default stack -# of 200k. The usual default stack provided by Watcom C++ is *way* to small -# for real 32 bit code development. We also need a *huge* stack for OpenGL -# software rendering also! -.IF $(USE_QNX4) - # Not necessary for QNX code. -.ELSE -.IF $(STKSIZE) - LDFLAGS += OP STACK=$(STKSIZE) -.ELSE - LDFLAGS += OP STACK=204800 -.ENDIF -.ENDIF - -# Turn on runtime type information as necessary -.IF $(USE_RTTI) - CPFLAGS += -xr -.ENDIF - -# Optionally turn on pre-compiled headers -.IF $(PRECOMP_HDR) - CFLAGS += -fhq -.ENDIF - -.IF $(USE_QNX) -# Whether to link in real VBIOS library, or just the stub library -.IF $(USE_BIOS) -VBIOSLIB := vbios.lib, -.ELSE -VBIOSLIB := vbstubs.lib, -.END -# Require special privledges for Nucleus programs (requires root access) -.IF $(USE_NUCLEUS) -LDFLAGS += OP PRIV=1 -.ENDIF -.ENDIF - -# Implicit generation rules for making object files -.IF $(WC_LIBBASE) == WC10A -%$O: %.c ; $(CC) $(CFLAGS) $(<:s,/,\) -%$O: %$P ; $(CPP) $(CFLAGS) $(<:s,/,\) -.ELSE -%$O: %.c ; $(CC) @$(mktmp $(CFLAGS:s/\/\\)) $(<:s,/,\) -%$O: %$P ; $(CPP) @$(mktmp $(CPFLAGS:s/\/\\) $(CFLAGS:s/\/\\)) $(<:s,/,\) -.ENDIF -.IF $(USE_NASM) -%$O: %$A ; $(AS) @$(mktmp -o $@ $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ELSE -%$O: %$A ; $(AS) @$(mktmp $(ASFLAGS:s/\/\\)) $(<:s,/,\) -.ENDIF - -# Implit rule to compile .S assembler files. The first version -# uses GAS directly and the second uses a pre-processor to -# produce NASM code. - -.IF $(USE_GAS) -.IF $(WC_LIBBASE) == WC11 -%$O: %$S ; $(GAS) -c @$(mktmp $(GAS_FLAGS:s/\/\\)) $(<:s,/,\) -.ELSE -# Black magic to build asm sources with Watcom 10.6 (requires sed) -%$O: %$S ; - $(GAS) -c @$(mktmp $(GAS_FLAGS:s/\/\\)) $(<:s,/,\) - wdisasm \\ -a $(*:s,/,\).o > $(*:s,/,\).lst - sed -e "s/\.text/_TEXT/; s/\.data/_DATA/; s/\.bss/_BSS/; s/\.386/\.586/; s/lar *ecx,cx/lar ecx,ecx/" $(*:s,/,\).lst > $(*:s,/,\).asm - wasm \\ $(WFLAGS) -zq -fr=nul -fp3 -fo=$@ $(*:s,/,\).asm - $(RM) -S $(mktmp $(*:s,/,\).o) - $(RM) -S $(mktmp $(*:s,/,\).lst) - $(RM) -S $(mktmp $(*:s,/,\).asm) -.ENDIF -.ELSE -%$O: %$S ; - @gcpp -DNASM_ASSEMBLER -D__WATCOMC__ -EP $(<:s,/,\) > $(*:s,/,\).asm - nasm @$(mktmp -f obj -o $@) $(*:s,/,\).asm - @$(RM) -S $(mktmp $(*:s,/,\).asm) -.ENDIF - -# Special target to build dllstart.asm using Borland TASM -dllstart.obj: dllstart.asm - $(DLL_TASM) @$(mktmp /t /mx /m /D__FLAT__ /i$(SCITECH)\INCLUDE /q) $(PRIVATE)\src\common\dllstart.asm - -# Implicit rule for building resource files -%$R: %.rc ; $(RC) $(RCFLAGS) -r $< - -# Implicit rule for building a DLL using a response file -.IF $(IMPORT_DLL) -.ELSE -.IF $(USE_OS232) -%$D: ; - @trimlib $(mktmp $(LDFLAGS) OP quiet SYS os2v2 dll\nN $@\nF $(&:t",\n":s/\/\\)\nLIBR $(EXELIBS:t",")) $*.lnk - rclink $(LD) $(RC) $@ $*.lnk -.IF $(LEAVE_LINKFILE) -.ELSE - @$(RM) -S $(mktmp *.lnk) -.ENDIF -.ELIF $(USE_WIN32) -%$D: ; - @trimlib $(mktmp $(LDFLAGS) OP quiet SYS nt_dll\nN $@\nF $(&:t",\n":s/\/\\)\nLIBR $(PMLIB)$(DEFLIBS)$(EXELIBS:t",")) $*.lnk - rclink $(LD) $(RC) $@ $*.lnk -.IF $(LEAVE_LINKFILE) -.ELSE - @$(RM) -S $(mktmp *.lnk) -.ENDIF -.ELSE -%$D: ; - @trimlib $(mktmp $(LDFLAGS) OP quiet SYS win386\nN $*.rex\nF $(&:t",\n":s/\/\\)\nLIBR $(EXELIBS:t",")) $*.lnk - rclink $(LD) $(RC) $@ $*.lnk - wbind $* -d -q -n -.IF $(LEAVE_LINKFILE) -.ELSE - @$(RM) -S $(mktmp *.lnk) -.ENDIF -.ENDIF -.ENDIF - -# Implicit rule for building a library file using response file -.IF $(BUILD_DLL) -%$L: ; - @$(RM) $@ - $(ILIB) $(ILIBFLAGS) $@ +$? -.ELIF $(IMPORT_DLL) -%$L: ; - @$(RM) $@ - $(ILIB) $(ILIBFLAGS) $@ +$? -.ELSE -%$L: ; - @$(RM) $@ - $(LIB) $(LIBFLAGS) $@ @$(mktmp,$*.rsp +$(&:t"\n+":s/\/\\)\n) -.ENDIF - -# Implicit rule for building an executable file using response file -.IF $(USE_X32) -%$E: ; - @trimlib $(mktmp OP quiet\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(EXELIBS:t",")) $*.lnk - $(LD) $(LDFLAGS) @$*.lnk - x32fix $@ -.IF $(LEAVE_LINKFILE) -.ELSE - @$(RM) -S $(mktmp *.lnk) -.ENDIF -.ELIF $(USE_OS232) -.IF $(USE_OS2GUI) -%$E: ; - @trimlib $(mktmp $(LDFLAGS) OP quiet SYS os2v2_pm\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(EXELIBS:t",")) $*.lnk - rclink $(LD) $(RC) $@ $*.lnk -.IF $(LEAVE_LINKFILE) -.ELSE - @$(RM) -S $(mktmp *.lnk) -.ENDIF -.IF $(LXLITE) - lxlite $@ -.ENDIF -.ELSE -%$E: ; - @trimlib $(mktmp $(LDFLAGS) OP quiet SYS os2v2\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(EXELIBS:t",")) $*.lnk - rclink $(LD) $(RC) $@ $*.lnk -.IF $(LEAVE_LINKFILE) -.ELSE - @$(RM) -S $(mktmp *.lnk) -.ENDIF -.IF $(LXLITE) - lxlite $@ -.ENDIF -.ENDIF -.ELIF $(USE_SNAP) -%$E: ; - @trimlib $(mktmp $(LDFLAGS) OP quiet SYS nt\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(DEFLIBS)$(EXELIBS:t",")) $*.lnk - rclink $(LD) $(RC) $@ $*.lnk -.IF $(LEAVE_LINKFILE) -.ELSE - @$(RM) -S $(mktmp *.lnk) -.ENDIF -.ELIF $(USE_WIN32) -.IF $(WIN32_GUI) -%$E: ; - @trimlib $(mktmp $(LDFLAGS) OP quiet SYS win95\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(DEFLIBS)$(EXELIBS:t",")) $*.lnk - rclink $(LD) $(RC) $@ $*.lnk -.IF $(LEAVE_LINKFILE) -.ELSE - @$(RM) -S $(mktmp *.lnk) -.ENDIF -.ELSE -%$E: ; - @trimlib $(mktmp $(LDFLAGS) OP quiet SYS nt\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(DEFLIBS)$(EXELIBS:t",")) $*.lnk - rclink $(LD) $(RC) $@ $*.lnk -.IF $(LEAVE_LINKFILE) -.ELSE - @$(RM) -S $(mktmp *.lnk) -.ENDIF -.ENDIF -.ELIF $(USE_WIN386) -%$E: ; - @trimlib $(mktmp $(LDFLAGS) OP quiet SYS win386\nN $*.rex\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(EXELIBS:t",")) $*.lnk - rclink $(LD) wbind $*.rex $*.lnk -.IF $(LEAVE_LINKFILE) -.ELSE - @$(RM) -S $(mktmp *.lnk) -.ENDIF -.ELIF $(USE_TNT) -%$E: ; - @trimlib $(mktmp $(LDFLAGS) OP quiet\nN $@\nF $(&:t",":s/\/\\)\nLIBR dosx32.lib,tntapi.lib,$(PMLIB)$(EXELIBS:t",")) $*.lnk - $(LD) @$*.lnk -.IF $(LEAVE_LINKFILE) -.ELSE - @$(RM) -S $(mktmp *.lnk) -.ENDIF -.IF $(DOSSTYLE) - @markphar $@ -.ENDIF -.ELIF $(USE_QNX4) -%$E: ; - @trimlib $(mktmp $(LDFLAGS) OP quiet\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(VBIOSLIB)$(EXELIBS:t",")) $*.lnk - @+if exist $*.exe attrib -s $*.exe > NUL - $(LD) @$*.lnk - @attrib +s $*.exe -.IF $(LEAVE_LINKFILE) -.ELSE - @$(RM) -S $(mktmp *.lnk) -.ENDIF -.ELSE -%$E: ; - @trimlib $(mktmp $(LDFLAGS) OP quiet\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(EXELIBS:t",")) $*.lnk - $(LD) @$*.lnk -.IF $(LEAVE_LINKFILE) -.ELSE - @$(RM) -S $(mktmp *.lnk) -.ENDIF -.ENDIF diff --git a/board/MAI/bios_emulator/scitech/makedefs/sc16.mk b/board/MAI/bios_emulator/scitech/makedefs/sc16.mk deleted file mode 100644 index 099ad45527..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/sc16.mk +++ /dev/null @@ -1,128 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Symantec C++ 6.x/7.x 16 bit version. Supports 16 bit DOS -# and 16 bit Windows development. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Import enivornment variables that we use -.IMPORT .IGNORE : SC_LIBBASE - -# Default commands for compiling, assembling linking and archiving - CC := sc # C-compiler and flags - CFLAGS := -ml -Jm -.IF $(USE_TASM32) - AS := tasm32 -.ELIF $(USE_TASMX) - AS := tasmx # Assembler and flags -.ELSE - AS := tasm # Assembler and flags -.ENDIF - ASFLAGS := /t /mx /m /D__COMM__ /iINCLUDE /i$(SCITECH)\INCLUDE - LD := sc # Loader and flags - LDFLAGS = $(CFLAGS) - RC := rcc # WIndows resource compiler - RCFLAGS := # Mark as Win32 compatible resources - LIB := lib # Librarian - LIBFLAGS := /N /B - ILIB := implib # Import librarian - ILIBFLAGS := - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -g # Turn on debugging for C compiler -.ELSE - ASFLAGS += /q # Suppress object records not needed for linking -.END - -# Optionally turn on optimisations -.IF $(OPT) - CFLAGS += -5 -o+all -.ELIF $(OPT_SIZE) - CFLAGS += -5 -o+space -.END - -# Optionally turn on direct i387 FPU instructions - -.IF $(FPU) - CFLAGS += -ff -DFPU387 - ASFLAGS += -DFPU387 -DFPU_REG_RTN -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -DBETA -.END - -# User a larger stack if requested - -.IF $(STKSIZE) - LDFLAGS += =$(STKSIZE) -.ENDIF - -# Optionally compile for 16 bit Windows -.IF $(USE_WIN16) -.IF $(BUILD_DLL) - CFLAGS += -WD -DBUILD_DLL - ASFLAGS += -DBUILD_DLL -.ELSE - CFLAGS += -WA -.ENDIF - DX_ASFLAGS += -D__WINDOWS16__ - LIB_OS = WIN16 -.ELSE - USE_REALDOS := 1 - LIB_OS = DOS16 -.END - -# Place to look for PMODE library files - -PMLIB := pm.lib - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_BASE := $(LIB_BASE_DIR)\$(LIB_OS)\$(SC_LIBBASE) - LIB_DEST := $(LIB_BASE) - -# Define which file contains our rules - - RULES_MAK := sc16.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/sc32.mk b/board/MAI/bios_emulator/scitech/makedefs/sc32.mk deleted file mode 100644 index 9ca757088a..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/sc32.mk +++ /dev/null @@ -1,178 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Symantec C++ 6.x/7.x 32 bit version. Supports the DOSX -# extender, FlashTek X32 and Phar Lap's TNT DOS Extender -# and 32 bit Windows development. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Import enivornment variables that we use -.IMPORT .IGNORE : USE_TNT USE_X32 USE_X32VM SC_LIBBASE - -# We are compiling for a 32 bit envionment - _32BIT_ := 1 - -# Default commands for compiling, assembling linking and archiving - CC := sc # C-compiler and flags - CFLAGS := -Jm -.IF $(USE_TASM32) - AS := tasm32 -.ELIF $(USE_TASMX) - AS := tasmx # Assembler and flags -.ELSE - AS := tasm # Assembler and flags -.ENDIF -.IF $(USE_WIN32) - ASFLAGS := /t /mx /m /D__FLAT__ /iINCLUDE /i$(SCITECH)\INCLUDE -.ELSE - ASFLAGS := /t /mx /m /DES_NOT_DS /D__COMM__ /i$(SCITECH)\INCLUDE -.ENDIF - LD := sc # Loader and flags - LD_FLAGS = - RC := rcc # WIndows resource compiler - RCFLAGS := -32 # Mark as Win32 compatible resources - LIB := lib # Librarian - LIBFLAGS := /N /B - ILIB := implib # Import librarian - ILIBFLAGS := - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -g # Turn on debugging for C compiler (FlashView) -.IF $(USE_TNT) - LDFLAGS += -fullsym # Turn on debugging for TNT 386link linker -.END -.IF $(USE_X32) or $(USE_X32VM) - LDFLAGS += -L/map # Turn on debugging for FlashView debugger -.END -.ELSE - ASFLAGS += /q # Suppress object records not needed for linking -.END - -# Optionally turn on optimisations -.IF $(OPT) - CFLAGS += -5 -o+all -.ELIF $(OPT_SIZE) - CFLAGS += -5 -o+space -.END - -# Optionally turn on direct i387 FPU instructions - -.IF $(FPU) - CFLAGS += -ff -DFPU387 - ASFLAGS += -DFPU387 -DFPU_REG_RTN -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -DBETA -.END - -# User a larger stack if requested - -.IF $(STKSIZE) - LDFLAGS += =$(STKSIZE) -.ENDIF - -.IF $(USE_TNT) # Use Phar Lap's TNT DOS Extender - CFLAGS += -mp - DX_CFLAGS += -DTNT - ASFLAGS += /D__FLAT__ - DX_ASFLAGS += -DTNT - LD := 386link - LDFLAGS += @sc32.dos -exe $@ - LIB_OS = DOS32 -.ELIF $(USE_X32VM) # Use FlashTek X-32VM DOS extender - CFLAGS += -mx - DX_CFLAGS += -DX32VM - ASFLAGS += /D__X386__ - DX_ASFLAGS += -DX32VM - LD := sc - LDFLAGS += $(CFLAGS) x32v.lib - LIB_OS = DOS32 -.ELIF $(USE_X32) # Use FlashTek X-32 DOS extender - CFLAGS += -mx - DX_CFLAGS += -DX32VM - ASFLAGS += /D__X386__ - DX_ASFLAGS += -DX32VM - LD := sc - LDFLAGS += $(CFLAGS) x32.lib - LIB_OS = DOS32 -.ELIF $(USE_WIN32) # Build 32 bit Windows NT app -.IF $(BUILD_DLL) - CFLAGS += -WD -mn - ASFLAGS += -DBUILD_DLL -.ELSE - CFLAGS += -WA -mn -.ENDIF - DX_ASFLAGS += -D__WINDOWS32__ - LIB_OS = WIN32 -.ELSE # Use default Symantec DOSX extender - USE_DOSX := 1 - USE_REALDOS := 1 - CFLAGS += -mx - DX_CFLAGS += -DDOSX - ASFLAGS += /D__X386__ - DX_ASFLAGS += -DDOSX - LD := sc - LDFLAGS += $(CFLAGS) - LIB_OS = DOS32 -.END - -# Place to look for PMODE library files - -.IF $(USE_TNT) -PMLIB := tnt\pm.lib -.ELIF $(USE_X32) -PMLIB := x32\pm.lib -.ELSE -PMLIB := dosx\pm.lib -.END - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_BASE := $(LIB_BASE_DIR)\$(LIB_OS)\$(SC_LIBBASE) - LIB_DEST := $(LIB_BASE) - -# Define which file contains our rules - - RULES_MAK := sc32.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/startup.mk b/board/MAI/bios_emulator/scitech/makedefs/startup.mk deleted file mode 100644 index d8b2ba2b9b..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/startup.mk +++ /dev/null @@ -1,161 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Common startup script that defines all variables common to -# all startup scripts. These define the DMAKE runtime -# environment and the values are dependant on the version of -# DMAKE in use. -# -############################################################################# - -# Disable warnings for macros redefined here that were given -# on the command line. -__.SILENT := $(.SILENT) -.SILENT := yes - -# Import enivornment variables that we use common to all compilers -.IMPORT .IGNORE : TEMP SHELL COMSPEC INCLUDE LIB SCITECH PRIVATE SCITECH_LIB -.IMPORT .IGNORE : DBG OPT OPT_SIZE SHW BETA USE_WIN32 FPU BUILD_DLL BUILD_FOR_DLL -.IMPORT .IGNORE : IMPORT_DLL USE_TASMX WIN32_GUI USE_WIN16 USE_NASM CHECKED -.IMPORT .IGNORE : OS2_SHELL SOFTICE_PATH MAX_WARN USE_SOFTICE USE_TASM32 -.IMPORT .IGNORE : DLL_START_TASM USE_SNAP USE_X11 USE_LINUX STATIC_LIBS LIBC -.IMPORT .IGNORE : SHOW_ARGS BOOT_STRAP_DMAKE - TMPDIR := $(TEMP) - -# Determine if the host machine is a Windows/DOS or Unix box -.IF $(COMSPEC) - WIN32_HOST := 1 -.ELSE - USE_NASM := 1 - UNIX_HOST := 1 -.ENDIF - -# Setup to either user NASM or TASM as the assembler -.IF $(USE_NASM) -.ELSE - USE_TASM := 1 -.ENDIF - -.IF $(UNIX_HOST) -# Standard file suffix definitions -# -# NOTE: Linux/Unix does not require any extenion for executeable files, but you -# can use an extension if you wish. We use the .exe extension for building -# executeable files so that we can use implicit rules to make the -# makefiles simpler and more portable between systems (exe also makes it -# easier for cross-compile/debugging situations). When you install -# the files to a local bin directory, you will probably want to remove -# the .exe extension. - L := .a # Libraries - E := .exe # Executables for glibc - O := .o # Objects - A := .asm # Assembler sources - S := .s # GNU assembler sources - P := .cpp # C++ sources - -# File prefix/suffix definitions. The following prefixes are defined, and are -# used primarily to abstract between the Unix style libXX.a naming convention -# and the DOS/Windows/OS2 naming convention of XX.lib. - LP := lib # LP - Library file prefix (name of file on disk) - LL := -l # Library link prefix (name of library on link command line) - LE := # Library link suffix (extension of library on link command line) - -# We use the Unix shell at all times - SHELL := /bin/sh - SHELLFLAGS := -c - -.ELSE -# Standard file DOS/Win/OS2 suffix definitions - L := .lib # Libraries -.IF $(USE_SNAP) - E := .sxe # Snap Executables - D := .sll # Snap Dynamic Link Library file -.ELSE - E := .exe # Executables - D := .dll # Dynamic Link Library file -.ENDIF - O := .obj # Objects - A := .asm # Assembler sources - P := .cpp # C++ sources - R := .res # Compiled resource file - S := .s # Assyntax.h style assembler - -# File prefix/suffix definitions. The following prefixes are defined, and are -# used primarily to abstract between the Unix style libXX.a naming convention -# and the DOS/Windows/OS2 naming convention of XX.lib. - LP := # LP - Library file prefix (name of file on disk) - LL := # Library link prefix (name of library on link command line) - LE := .lib # Library link suffix (extension of library on link command line) - -# We use the DOS/Win/OS2 style shell at all times - SHELL := $(COMSPEC) - GROUPSHELL := $(SHELL) - SHELLFLAGS := $(SWITCHAR)c - GROUPFLAGS := $(SHELLFLAGS) - SHELLMETAS := *"?<> -.IF $(OS2_SHELL) - GROUPSUFFIX := .cmd -.ELSE - GROUPSUFFIX := .bat -.ENDIF - DIRSEPSTR := \\ - DIVFILE = $(TMPFILE:s,/,\) - -.ENDIF - -# Standard Unix style shell commands. Since these do not exist on -# regular DOS/Win/OS2 installations we use our own '' versions -# instead. To boostrtap a new OS you may wish to use the regular -# unix versions. - -.IF $(BOOT_STRAP_DMAKE) - CP := cp - MD := mkdir - RM := rm - ECHO := echo -.ELSE - CP := k_cp - MD := k_md - RM := k_rm - ECHO := k_echo -.ENDIF - -# Definition of $(MAKE) macro for recursive makes. - MAKE = $(MAKECMD) $(MFLAGS) - -# Macro to install a library file - INSTALL := $(CP) - -# DMAKE uses this recipe to remove intermediate targets -.REMOVE :; $(RM) -f $< - -# Turn warnings back to previous setting. -.SILENT := $(__.SILENT) - -# We dont use TABS in our makefiles -.NOTABS := yes diff --git a/board/MAI/bios_emulator/scitech/makedefs/va32.mk b/board/MAI/bios_emulator/scitech/makedefs/va32.mk deleted file mode 100644 index fbca523922..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/va32.mk +++ /dev/null @@ -1,163 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# IBM VisualAge C++ 3.0 OS/2 32-bit version. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Import enivornment variables that we use -.IMPORT .IGNORE : VA_LIBBASE USE_OS232 USE_OS2GUI FULLSCREEN NOOPT MAX_WARN - -# We are compiling for a 32 bit envionment - _32BIT_ := 1 - -# Default commands for compiling, assembling linking and archiving - CC := icc - CPP := icc - CFLAGS := /Q /G5 /Gl+ /Fi /Si /J- /Ss+ /Sp1 /Gm+ /I. -.IF $(USE_NASM) - AS := nasm - ASFLAGS := -t -f obj -F null -d__FLAT__ -dSTDCALL_MANGLE -d__NOU_VAR__ -iINCLUDE -i$(SCITECH)\INCLUDE -.ELSE -.IF $(USE_TASM32) - AS := tasm32 -.ELIF $(USE_TASMX) - AS := tasmx -.ELSE - AS := tasm -.ENDIF - ASFLAGS := /t /mx /m /D__FLAT__ /DSTDCALL_MANGLE /D__NOU_VAR__ /iINCLUDE /i$(SCITECH)\INCLUDE -.ENDIF - LD := ilink - LDFLAGS = /noi /exepack:2 /packcode /packdata /align:32 /map /noe - RC := rc - RCFLAGS := -n -x2 - LIB := ilib - LIBFLAGS := /nologo - ILIB := implib - ILIBFLAGS := /nologo - IPFC := ipfc - IPFCFLAGS := - IBMCOBJ := 1 - -# Set the compiler warning level -.IF $(MAX_WARN) - CFLAGS += /W3 -.ELSE - CFLAGS += /W1 -.ENDIF - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += /Ti - LDFLAGS += /DE -.ELSE -.IF $(USE_TASM) - ASFLAGS += /q -.ENDIF -.END - -# Optionally turn on optimisations -.IF $(OPT) - CFLAGS += /Gfi /O /Oi -.ELIF $(OPT_SIZE) - CFLAGS += /Gfi /O /Oc -.ELIF $(NOOPT) - CFLAGS += /O- -.END - -# Optionally turn on direct i387 FPU instructions optimised for Pentium -.IF $(FPU) - CFLAGS += -DFPU387 - ASFLAGS += -dFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -dBETA -.END - -# Build 32-bit OS/2 apps -.IF $(BUILD_DLL) - CFLAGS += /Ge- /DBUILD_DLL - LDFLAGS += /DLL /NOE - ASFLAGS += -dBUILD_DLL -.ELSE -.IF $(USE_OS2GUI) - CFLAGS += -D__OS2_PM__ - LDFLAGS += /PMTYPE:PM -.ELSE -.IF $(FULLSCREEN) - LDFLAGS += /PMTYPE:NOVIO -.ELSE - LDFLAGS += /PMTYPE:VIO -.ENDIF -.ENDIF -.ENDIF - DX_ASFLAGS += -d__OS2__ - LIB_OS = os232 - -# Place to look for PMODE library files - -.IF $(USE_OS2GUI) -.IF $(USE_SDDPMDLL) -#Note: This is OK for now but might need to be changed if the GUI PM library -# were really different -PMLIB := sddpmlib.lib -.ELSE -PMLIB := pm_pm.lib -.ENDIF -.ELSE -.IF $(USE_SDDPMDLL) -PMLIB := sddpmlib.lib -.ELSE -PMLIB := pm.lib -.ENDIF -.ENDIF - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += /DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_BASE := $(LIB_BASE_DIR)\$(LIB_OS)\$(VA_LIBBASE) - LIB_DEST := $(LIB_BASE) - -# Define which file contains our rules - - RULES_MAK := va32.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/va365.mk b/board/MAI/bios_emulator/scitech/makedefs/va365.mk deleted file mode 100644 index 3a2eccbbce..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/va365.mk +++ /dev/null @@ -1,151 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# IBM VisualAge C++ 3.65 OS/2 32-bit version. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Import enivornment variables that we use -.IMPORT .IGNORE : VA_LIBBASE USE_OS232 USE_OS2GUI FULLSCREEN NOOPT MAX_WARN - -# We are compiling for a 32 bit envionment - _32BIT_ := 1 - -# Default commands for compiling, assembling linking and archiving - CC := icc - CPP := icc - CFLAGS := /Q /G5l /Fi /Si /J- /Ss+ /Sp1 /Gm+ /I. -.IF $(USE_NASM) - AS := nasm - ASFLAGS := -t -f obj -F null -d__FLAT__ -dSTDCALL_MANGLE -d__NOU_VAR__ -iINCLUDE -i$(SCITECH)\INCLUDE -.ELSE -.IF $(USE_TASM32) - AS := tasm32 -.ELIF $(USE_TASMX) - AS := tasmx -.ELSE - AS := tasm -.ENDIF - ASFLAGS := /t /mx /m /D__FLAT__ /DSTDCALL_MANGLE /D__NOU_VAR__ /iINCLUDE /i$(SCITECH)\INCLUDE -.ENDIF - LD := ilink - LDFLAGS = /noi /exepack /packcode /packdata /align:32 /map /noe - RC := rc - RCFLAGS := /nologo - LIB := ilib - LIBFLAGS := /nologo - ILIB := implib - ILIBFLAGS := /nologo - IBMCOBJ := 1 - -# Set the compiler warning level -.IF $(MAX_WARN) - CFLAGS += /W3 -.ELSE - CFLAGS += /W1 -.ENDIF - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += /Ti - LDFLAGS += /DE -.ELSE -.IF $(USE_TASM) - ASFLAGS += /q -.ENDIF -.END - -# Optionally turn on optimisations -.IF $(OPT) - CFLAGS += /Gfi /O /Oi -.ELIF $(OPT_SIZE) - CFLAGS += /Gfi /O /Oc -.ELIF $(NOOPT) - CFLAGS += /O- -.END - -# Optionally turn on direct i387 FPU instructions optimised for Pentium -.IF $(FPU) - CFLAGS += -DFPU387 - ASFLAGS += -dFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -dBETA -.END - -# Build 32-bit OS/2 apps -.IF $(BUILD_DLL) - CFLAGS += /Gme- /DBUILD_DLL - LDFLAGS += /DLL /NOE - ASFLAGS += -dBUILD_DLL -.ELSE -.IF $(USE_OS2GUI) - CFLAGS += -D__OS2_PM__ - LDFLAGS += /PMTYPE:PM -.ELSE -.IF $(FULLSCREEN) - LDFLAGS += /PMTYPE:NOVIO -.ELSE - LDFLAGS += /PMTYPE:VIO -.ENDIF -.ENDIF -.ENDIF - DX_ASFLAGS += -d__OS2__ - LIB_OS = os232 - -# Place to look for PMODE library files - -.IF $(USE_OS2GUI) -PMLIB := pm_pm.lib -.ELSE -PMLIB := pm.lib -.ENDIF - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += /DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_BASE := $(LIB_BASE_DIR)\$(LIB_OS)\$(VA_LIBBASE) - LIB_DEST := $(LIB_BASE) - -# Define which file contains our rules - - RULES_MAK := va365.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/vc16.mk b/board/MAI/bios_emulator/scitech/makedefs/vc16.mk deleted file mode 100644 index 913bf9c3e4..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/vc16.mk +++ /dev/null @@ -1,128 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Microsoft Visual C++ 1.x 16 bit version. Supports 16 bit -# DOS and Windows development. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Import enivornment variables that we use -.IMPORT .IGNORE : VC_LIBBASE - -# Default commands for compiling, assembling linking and archiving - CC := cl # C-compiler and flags - CFLAGS := /YX /w /G3 /Gs -.IF $(USE_TASM32) - AS := tasm32 -.ELIF $(USE_TASMX) - AS := tasmx # Assembler and flags -.ELSE - AS := tasm # Assembler and flags -.ENDIF - ASFLAGS := /t /mx /m /D__COMM__ /iINCLUDE /i$(SCITECH)\INCLUDE - LD := cl # Loader and flags - LDFLAGS = $(CFLAGS) - RC := rc # WIndows resource compiler - RCFLAGS := - LIB := lib # Librarian - LIBFLAGS := /NOI /NOE - ILIB := implib # Import librarian - ILIBFLAGS := /noignorecase - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += /Yd /Zi # Turn on debugging for C compiler - ASFLAGS += /zi # Turn on debugging for assembler -.ELSE - ASFLAGS += /q # Suppress object records not needed for linking -.END - -# Optionally turn on optimisations -.IF $(OPT) - CFLAGS += /Ox -.END - -# Optionally turn on direct i387 FPU instructions - -.IF $(FPU) - CFLAGS += /FPi87 /DFPU387 - ASFLAGS += /DFPU387 /DFPU_REG_RTN -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += /DBETA - ASFLAGS += /DBETA -.END - -# Use a larger stack during linking if requested ???? How the fuck do you -# specify linker options on the CL command line????? - -.IF $(STKSIZE) -.ENDIF - -# Optionally compile for 16 bit Windows -.IF $(USE_WIN16) -.IF $(BUILD_DLL) - CFLAGS += /GD /Alfw /DBUILD_DLL - ASFLAGS += -DBUILD_DLL -.ELSE - CFLAGS += /GA /AL -.ENDIF - DX_ASFLAGS += -D__WINDOWS16__ - LIB_OS = WIN16 -.ELSE - USE_REALDOS := 1 - CFLAGS += /AL - LIB_OS = DOS16 -.END - -# Place to look for PMODE library files - -PMLIB := pm.lib - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_BASE := $(LIB_BASE_DIR)\$(LIB_OS)\$(VC_LIBBASE) - LIB_DEST := $(LIB_BASE) - -# Define which file contains our rules - - RULES_MAK := vc16.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/vc32.mk b/board/MAI/bios_emulator/scitech/makedefs/vc32.mk deleted file mode 100644 index 11c9071fb8..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/vc32.mk +++ /dev/null @@ -1,226 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Microsoft Visual C++ 2.x 32 bit version. Supports Phar Lap -# TNT DOS Extender and 32 bit Windows development. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Import enivornment variables that we use -.IMPORT .IGNORE : TNT_PATH VC_LIBBASE DOSSTYLE USE_TNT USE_RTTARGET MSVCDIR -.IMPORT .IGNORE : USE_VXD USE_NTDRV USE_W2KDRV NT_DDKROOT USE_RTTI USE_CPPEXCEPT - -# We are compiling for a 32 bit envionment - _32BIT_ := 1 - -# Default commands for compiling, assembling linking and archiving - CC := cl # C-compiler and flags - CFLAGS := -.IF $(USE_NASM) - AS := nasm - ASFLAGS := -t -f win32 -F null -d__FLAT__ -dSTDCALL_MANGLE -iINCLUDE -i$(SCITECH)\INCLUDE -.ELSE -.IF $(USE_TASM32) - AS := tasm32 -.ELIF $(USE_TASMX) - AS := tasmx # Assembler and flags -.ELSE - AS := tasm # Assembler and flags -.ENDIF - ASFLAGS := /t /mx /m /D__FLAT__ /DSTDCALL_MANGLE /iINCLUDE /i$(SCITECH)\INCLUDE -.ENDIF - LD := cl -.IF $(USE_WIN32) - LDFLAGS = $(CFLAGS) -.IF $(USE_NTDRV) - LDENDFLAGS = -link /INCREMENTAL:NO /DRIVER /SUBSYSTEM:NATIVE,4.00 /VERSION:4.00 /MACHINE:I386 /NODEFAULTLIB /DEBUGTYPE:CV /PDB:NONE /ALIGN:0x20 /BASE:0x10000 /ENTRY:DriverEntry@8 - #/MERGE:_page=page /MERGE:_text=.text /MERGE:.rdata=.text -.ELIF $(WIN32_GUI) - LDENDFLAGS = -link /INCREMENTAL:NO /DEF:$(@:b).def /SUBSYSTEM:WINDOWS /MACHINE:I386 /DEBUGTYPE:CV /PDB:NONE -.ELSE - LDENDFLAGS = -link /INCREMENTAL:NO /SUBSYSTEM:CONSOLE /MACHINE:I386 /DEBUGTYPE:CV /PDB:NONE -.ENDIF -.ELSE - LDFLAGS = $(CFLAGS) - LDENDFLAGS := -link -stub:$(TNT_PATH:s/\/\\)\\bin\\gotnt.exe /PDB:NONE -.ENDIF - RC := rc # Watcom resource compiler - RCFLAGS := # Mark as Win32 compatible resources - LIB := lib # Librarian - LIBFLAGS := - ILIB := lib # Import librarian - ILIBFLAGS := /MACHINE:IX86 - INTEL_X86 := 1 - NMSYM := $(SOFTICE_PATH)\nmsym.exe -.IF $(USE_NTDRV) - NMSYMFLAGS := /TRANSLATE:source,package,always /PROMPT /SOURCE:$(MSVCDIR)\crt\src\intel;$(SCITECH)\src\pm;$(SCITECH)\src\pm\common;$(SCITECH)\src\pm\ntdrv -.ELSE - NMSYMFLAGS := /TRANSLATE:source,package,always /PROMPT /SOURCE:$(SCITECH)\src\pm;$(SCITECH)\src\pm\common;$(SCITECH)\src\pm\win32 -.ENDIF - -# Set the compiler warning level -.IF $(MAX_WARN) - CFLAGS += -W3 -.ELSE - CFLAGS += -W1 -.ENDIF - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += /Yd /Zi # Turn on debugging for C compiler -.IF $(USE_TASM) - ASFLAGS += /zi # Turn on debugging for assembler -.ENDIF -.ELSE -.IF $(USE_TASM) - ASFLAGS += /q # Suppress object records not needed for linking -.ENDIF -.END - -# Optionally turn on optimisations -.IF $(VC_LIBBASE) == vc5 -.IF $(OPT) - CFLAGS += /G6 /O2 /Ox /Oi- -.ELIF $(OPT_SIZE) - CFLAGS += /G6 /O1 -.END -.ELSE -.IF $(OPT) - CFLAGS += /G5 /O2 /Ox -.ELIF $(OPT_SIZE) - CFLAGS += /G5 /O1 -.END -.ENDIF - -# Optionally turn on direct i387 FPU instructions - -.IF $(FPU) - CFLAGS += /DFPU387 - ASFLAGS += -dFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += /DBETA - ASFLAGS += -dBETA -.END - -# Use a larger stack during linking if requested, or use a default stack -# of 50k. The usual default stack provided by Visual C++ is *way* to small -# for real 32 bit code development. - -.IF $(USE_WIN32) - # Not necessary for Win32 code. -.ELSE -.IF $(STKSIZE) - LDENDFLAGS += /STACK:$(STKSIZE) -.ELSE - LDENDFLAGS += /STACK:51200 -.ENDIF -.ENDIF - -# DOS extender dependant flags -.IF $(USE_NTDRV) # Build 32 bit Windows NT driver - CFLAGS += /LD /Zl /Gy /Gz /GF /D__NT_DRIVER__ /D_X86_=1 /Di386=1 -.IF $(DBG) - CFLAGS += /QIf -.ENDIF - ASFLAGS += - DEF_LIBS := int64.lib ntoskrnl.lib hal.lib - DX_ASFLAGS += -d__NT_DRIVER__ -.IF $(USE_W2KDRV) # Build 32 bit Windows 2000 driver - LIB_OS = W2KDRV -.ELSE - LIB_OS = NTDRV -.ENDIF -.ELIF $(USE_WIN32) # Build 32 bit Windows NT app -.IF $(WIN32_GUI) -.ELSE - CFLAGS += -D__CONSOLE__ -.ENDIF -.IF $(BUILD_DLL) - CFLAGS += /MT /LD /DBUILD_DLL - ASFLAGS += -dBUILD_DLL -.IF $(NO_RUNTIME) - LDENDFLAGS += /NODEFAULTLIB - CFLAGS += /Zl - DEF_LIBS := -.ELSE - DEF_LIBS := kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib winmm.lib comdlg32.lib comctl32.lib ole32.lib oleaut32.lib version.lib winspool.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib rpcrt4.lib -.ENDIF -.ELSE - CFLAGS += /MT - DEF_LIBS := kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib winmm.lib comdlg32.lib comctl32.lib ole32.lib oleaut32.lib version.lib winspool.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib rpcrt4.lib -.ENDIF - DX_ASFLAGS += -d__WINDOWS32__ - LIB_OS = WIN32 -.ELIF $(USE_RTTARGET) - CFLAGS += -D__RTTARGET__ - DX_CFLAGS += - DX_ASFLAGS += -d__RTTARGET__ - USE_REALDOS := - LIB_OS = RTT32 - DEF_LIBS := cw32mt.lib -.ELSE - USE_TNT := 1 - USE_REALDOS := 1 - CFLAGS += /MT /D__MSDOS32__ - DX_CFLAGS += -DTNT - DX_ASFLAGS += -dTNT - LIB_OS = DOS32 - DEF_LIBS := dosx32.lib tntapi.lib -.ENDIF - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += /DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_BASE := $(LIB_BASE_DIR)\$(LIB_OS)\$(VC_LIBBASE) - LIB_DEST := $(LIB_BASE) - -# Place to look for PMODE library files - -.IF $(USE_TNT) -PMLIB := $(LIB_BASE:s/\/\\)\\tnt\\pm.lib -.ELSE -PMLIB := $(LIB_BASE:s/\/\\)\\pm.lib -.ENDIF - -# Define which file contains our rules - - RULES_MAK := vc32.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/wc16.mk b/board/MAI/bios_emulator/scitech/makedefs/wc16.mk deleted file mode 100644 index e316f4c760..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/wc16.mk +++ /dev/null @@ -1,141 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Watcom C++ 10.x 16 bit version. Supports 16-bit DOS, -# 16-bit Windows development and 16-bit OS/2 development. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Import enivornment variables that we use -.IMPORT .IGNORE : WC_LIBBASE USE_WIN16 USE_OS216 USE_OS2GUI - -# Default commands for compiling, assembling linking and archiving - CC := wcc # C-compiler and flags - CPP := wpp # C++-compiler and flags - CFLAGS := -ml-zq-j-w2-s-fh -fhq -.IF $(USE_TASM32) - AS := tasm32 -.ELIF $(USE_TASMX) - AS := tasmx # Assembler and flags -.ELSE - AS := tasm # Assembler and flags -.ENDIF - AS := tasm # Assembler and flags - ASFLAGS := /t /mx /m /D__LARGE__ /iINCLUDE /i$(SCITECH)\INCLUDE - LD := wlink # Loader and flags - LDFLAGS = - RC := wrc # Watcom resource compiler - RCFLAGS := /bt=windows - LIB := wlib # Librarian - LIBFLAGS := -q - ILIB := wlib # Import librarian - ILIBFLAGS := -c - -# Optionally turn on debugging information -.IF $(DBG) - CFLAGS += -d2 # Turn on debugging for C compiler - LIBFLAGS += -p=128 # Larger page size for libraries with debug info! - ASFLAGS += /zi # Turn on debugging for assembler - LDFLAGS += D A # Turn on debugging for linker -.ELSE - ASFLAGS += /q # Suppress object records not needed for linking -.END - -# Optionally turn on optimisations -.IF $(OPT) - CFLAGS += -onatx-5 -.ELIF $(OPT_SIZE) - CFLAGS += -onaslmr-5 -.END - -# Optionally turn on direct i387 FPU instructions optimised for Pentium - -.IF $(FPU) - CFLAGS += -fpi87-fp5-DFPU387 - ASFLAGS += -DFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -DBETA -.END - -# Use a larger stack during linking if requested - -.IF $(STKSIZE) - LDFLAGS += OP STACK=$(STKSIZE) -.ENDIF - -.IF $(USE_OS216) -.IF $(BUILD_DLL) - CFLAGS += -bd-bt=os2-DBUILD_DLL - ASFLAGS += -DBUILD_DLL -.ELSE - CFLAGS += -bt=os2 -.ENDIF - DX_ASFLAGS += -D__OS216__ - LIB_OS = os216 -.ELIF $(USE_WIN16) -.IF $(BUILD_DLL) - CFLAGS += -bd-bt=windows-D_WINDOWS-DBUILD_DLL - ASFLAGS += -DBUILD_DLL -.ELSE - CFLAGS += -bt=windows-D_WINDOWS -.ENDIF - DX_ASFLAGS += -D__WINDOWS16__ - LIB_OS = WIN16 -.ELSE - USE_REALDOS := 1 - LIB_OS = DOS16 -.END - -# Place to look for PMODE library files - -PMLIB := pm.lib, - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_BASE := $(LIB_BASE_DIR)\$(LIB_OS)\$(WC_LIBBASE) - LIB_DEST := $(LIB_BASE) - -# Define which file contains our rules - - RULES_MAK := wc16.mk diff --git a/board/MAI/bios_emulator/scitech/makedefs/wc32.mk b/board/MAI/bios_emulator/scitech/makedefs/wc32.mk deleted file mode 100644 index e5175ca9ea..0000000000 --- a/board/MAI/bios_emulator/scitech/makedefs/wc32.mk +++ /dev/null @@ -1,353 +0,0 @@ -############################################################################# -# -# SciTech Multi-platform Graphics Library -# -# ======================================================================== -# -# The contents of this file are subject to the SciTech MGL Public -# License Version 1.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.scitechsoft.com/mgl-license.txt -# -# Software distributed under the License is distributed on an -# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -# -# The Initial Developer of the Original Code is SciTech Software, Inc. -# All Rights Reserved. -# -# ======================================================================== -# -# Descripton: Generic DMAKE startup makefile definitions file. Assumes -# that the SCITECH environment variable has been set to point -# to where all our stuff is installed. You should not need -# to change anything in this file. -# -# Watcom C++ 10.x 32 bit version. Supports Rational's DOS4GW -# DOS Extender, PMODE/W, Causeway, FlashTek's X32-VM, -# Phar Lap's TNT DOS Extender, 32-bit Windows development and -# 32-bit OS/2 development. -# -############################################################################# - -# Include standard startup script definitions -.IMPORT: SCITECH -.INCLUDE: "$(SCITECH)\makedefs\startup.mk" - -# Import enivornment variables that we use -.IMPORT .IGNORE : USE_TNT USE_X32 USE_X32VM USE_PMODEW STKCALL USE_CAUSEWAY -.IMPORT .IGNORE : USE_WIN386 USE_OS232 USE_OS2GUI WC_LIBBASE NOOPT DOSSTYLE -.IMPORT .IGNORE : OS2_SHELL USE_CODEVIEW USE_DOS32A USE_QNX4 LEAVE_LINKFILE - -# We are compiling for a 32 bit envionment - _32BIT_ := 1 - -# Setup special environment for QNX 4 (Unix'ish) -.IF $(USE_QNX4) - USE_QNX := 1 - L := .a # Libraries - LP := lib # LP - Library file prefix (name of file on disk) - LL := lib # Library link prefix (name of library on link command line) - LE := .a # Library link suffix (extension of library on link command line) -.ENDIF - -# Default commands for compiling, assembling linking and archiving - CC := wcc386 - CPP := wpp386 - CFLAGS := -zq-j-s-fpi87 -.IF $(USE_NASM) - AS := nasm - ASFLAGS := -t -f obj -d__FLAT__ -dSTDCALL_MANGLE -iINCLUDE -i$(SCITECH)\INCLUDE -.ELSE -.IF $(USE_TASM32) - AS := tasm32 - DLL_TASM := tasm32 -.ELIF $(USE_TASMX) - AS := tasmx - DLL_TASM := tasmx -.ELSE - AS := tasm - DLL_TASM := tasm -.ENDIF - ASFLAGS := /t /mx /m /w-res /w-mcp /D__FLAT__ /DSTDCALL_MANGLE /iINCLUDE /i$(SCITECH)\INCLUDE - GAS := gcc - GAS_FLAGS := -D__WATCOMC__ -D__SW_3S -D__SW_S -U__GNUC__ -UDJGPP -U__unix__ -Wall -I. -I$(SCITECH)\include -x assembler-with-cpp -.ENDIF - LD := wlink - LDFLAGS = -.IF $(USE_OS232) - RC := rc -.ELSE - RC := wrc -.ENDIF -.IF $(USE_WIN32) - RCFLAGS := -q /bt=nt -.ELIF $(USE_OS232) -.IF $(USE_OS2GUI) - CFLAGS += -D__OS2_PM__ -.ENDIF -.ELSE - RCFLAGS := -q -.ENDIF - LIB := wlib - LIBFLAGS := -q - ILIB := wlib - ILIBFLAGS := -c - INTEL_X86 := 1 - -# Set the compiler warning level -.IF $(MAX_WARN) - CFLAGS += -w4 -.ELSE - CFLAGS += -w1 -.ENDIF - -# Optionally turn on debugging information (Codeview format) -.IF $(DBG) -.IF $(USE_WIN32) -.IF $(USE_CODEVIEW) - CFLAGS += -d2 -hc - LDFLAGS += D CODEVIEW OPT CVPACK -.ELSE - CFLAGS += -d2 - LDFLAGS += D A -.ENDIF -.ELSE - CFLAGS += -d2 - LDFLAGS += D A -.ENDIF - LIBFLAGS += -p=768 -.IF $(USE_NASM) - ASFLAGS += -F borland -g -.ELSE -.IF $(USE_TASM32) - ASFLAGS += /q # TASM32 fucks up Watcom C++ debug info -.ELIF $(OS2_SHELL) - ASFLAGS += /q # TASM for OS/2 fucks up Watcom C++ debug info -.ELSE - ASFLAGS += /zi -.ENDIF -.ENDIF -.ELSE -.IF $(USE_NASM) - ASFLAGS += -F null -.ELSE - ASFLAGS += /q -.ENDIF -.END - -# Optionally turn on optimisations (with or without stack conventions) -.IF $(STKCALL) -.IF $(OPT) - CFLAGS += -onatx-5s-fp5 -.ELIF $(OPT_SIZE) - CFLAGS += -onaslmr-5s-fp5 -.ELIF $(NOOPT) - CFLAGS += -od-5s -.ELSE - CFLAGS += -3s -.END -.ELSE -.IF $(OPT) - CFLAGS += -onatx-5r-fp5 -.ELIF $(OPT_SIZE) - CFLAGS += -onaslmr-5r-fp5 -.ELIF $(NOOPT) - CFLAGS += -od-5r -.END -.END - -# Optionally turn on direct i387 FPU instructions optimised for Pentium -.IF $(FPU) - CFLAGS += -DFPU387 - ASFLAGS += -dFPU387 -.END - -# Optionally compile a beta release version of a product -.IF $(BETA) - CFLAGS += -DBETA - ASFLAGS += -dBETA -.END - -.IF $(USE_TNT) # Use Phar Lap's TNT DOS Extender - CFLAGS += -bt=nt -DTNT - ASFLAGS += -dTNT - LDFLAGS += SYS NT OP STUB=GOTNT.EXE - LIB_OS = DOS32 -.ELIF $(USE_X32VM) # Use FlashTek X-32VM DOS extender - CFLAGS += -bt=dos - LDFLAGS += SYS X32RV - DX_CFLAGS += -DX32VM - DX_ASFLAGS += -dX32VM - LIB_OS = DOS32 -.ELIF $(USE_X32) # Use FlashTek X-32 DOS extender - CFLAGS += -bt=dos - LDFLAGS += SYS X32R - DX_CFLAGS += -DX32VM - DX_ASFLAGS += -dX32VM - LIB_OS = DOS32 -.ELIF $(USE_QNX4) # Build QNX 4 app - CFLAGS += -bt=qnx386 - LDFLAGS += SYS QNX386FLAT OP CASEEXACT OP OFFSET=40k OP STACK=32k - CFLAGS += -D__QNX__ -D__UNIX__ - ASFLAGS += -d__QNX__ -d__UNIX__ - LIB_OS = QNX4 -.ELIF $(USE_OS232) -.IF $(BUILD_DLL) - CFLAGS += -bm-bd-bt=os2-sg-DBUILD_DLL - ASFLAGS += -dBUILD_DLL -.ELSE - CFLAGS += -bm-bt=os2-sg -.ENDIF - DX_ASFLAGS += -d__OS2__ - LIB_OS = os232 -.ELIF $(USE_SNAP) # Build 32 bit Snap app -.IF $(BUILD_DLL) - CFLAGS += -bm-bd-bt=nt-DBUILD_DLL - ASFLAGS += -dBUILD_DLL -.ELSE - CFLAGS += -bm-bt=nt-D_WIN32 -.ENDIF - LDFLAGS += OP nodefaultlibs -.IF $(STKCALL) - DEFLIBS := clib3s.lib,math3s.lib,noemu387.lib, -.ELSE - DEFLIBS := clib3r.lib,math3r.lib,noemu387.lib, -.ENDIF - LIB_OS = SNAP -.ELIF $(USE_WIN32) # Build 32 bit Windows NT app -.IF $(WIN32_GUI) -.ELSE - CFLAGS += -D__CONSOLE__ -.ENDIF -.IF $(BUILD_DLL) - CFLAGS += -bm-bd-bt=nt-sg-DBUILD_DLL -D_WIN32 - ASFLAGS += -dBUILD_DLL -.ELSE - CFLAGS += -bm-bt=nt-sg-D_WIN32 -.ENDIF - DX_ASFLAGS += -d__WINDOWS32__ - LIB_OS = WIN32 - DEFLIBS := kernel32.lib,user32.lib,gdi32.lib,advapi32.lib,shell32.lib,winmm.lib,comdlg32.lib,comctl32.lib,ole32.lib,oleaut32.lib,version.lib,winspool.lib,uuid.lib,wsock32.lib,rpcrt4.lib, -.ELIF $(USE_WIN386) # Build 32 bit Win386 extended app -.IF $(BUILD_DLL) - CFLAGS += -bd-bt=windows-DBUILD_DLL - ASFLAGS += -dBUILD_DLL -.ELSE - CFLAGS += -bt=windows -.ENDIF - DX_ASFLAGS += -d__WIN386__ - LIB_OS = WIN386 -.ELIF $(USE_PMODEW) # PMODE/W - CFLAGS += -bt=dos - USE_DOS4GW := 1 - USE_REALDOS := 1 - LDFLAGS += SYS PMODEW - DX_CFLAGS += -DDOS4GW - DX_ASFLAGS += -dDOS4GW - LIB_OS = DOS32 -.ELIF $(USE_CAUSEWAY) # Causeway - CFLAGS += -bt=dos - USE_DOS4GW := 1 - USE_REALDOS := 1 - LDFLAGS += SYS CAUSEWAY - DX_CFLAGS += -DDOS4GW - DX_ASFLAGS += -dDOS4GW - LIB_OS = DOS32 -.ELIF $(USE_DOS32A) # DOS32/A - CFLAGS += -bt=dos - USE_DOS4GW := 1 - USE_REALDOS := 1 - LDFLAGS += SYS DOS32A - DX_CFLAGS += -DDOS4GW - DX_ASFLAGS += -dDOS4GW - LIB_OS = DOS32 -.ELSE # Use DOS4GW - CFLAGS += -bt=dos - USE_DOS4GW := 1 - USE_REALDOS := 1 - LDFLAGS += SYS DOS4G - DX_CFLAGS += -DDOS4GW - DX_ASFLAGS += -dDOS4GW - LIB_OS = DOS32 -.END - -# Disable linking to default C runtime library and PM library - -.IF $(NO_RUNTIME) -LDFLAGS += OP nodefaultlibs -DEFLIBS := -.ELSE - -# Place to look for PM library files - -.IF $(USE_SNAP) # Build 32 bit Snap app or dll -PMLIB := -.ELIF $(USE_WIN32) -.IF $(STKCALL) -PMLIB := spm.lib, -.ELSE -PMLIB := pm.lib, -.ENDIF -.ELIF $(USE_OS232) -.IF $(STKCALL) -.IF $(USE_OS2GUI) -PMLIB := spm_pm.lib, -.ELSE -PMLIB := spm.lib, -.ENDIF -.ELSE -.IF $(USE_OS2GUI) -PMLIB := pm_pm.lib, -.ELSE -PMLIB := pm.lib, -.ENDIF -.ENDIF -.ELIF $(USE_QNX4) -.IF $(STKCALL) -PMLIB := libspm.a, -.ELSE -PMLIB := libpm.a, -.ENDIF -.ELIF $(USE_TNT) -.IF $(STKCALL) -PMLIB := tnt\spm.lib, -.ELSE -PMLIB := tnt\pm.lib, -.ENDIF -.ELIF $(USE_X32) -.IF $(STKCALL) -PMLIB := x32\spm.lib, -.ELSE -PMLIB := x32\pm.lib, -.ENDIF -.ELSE -.IF $(STKCALL) -PMLIB := dos4gw\spm.lib, -.ELSE -PMLIB := dos4gw\pm.lib, -.ENDIF -.ENDIF -.ENDIF - -# Define the base directory for library files - -.IF $(CHECKED) -LIB_BASE_DIR := $(SCITECH_LIB)\lib\debug -CFLAGS += -DCHECKED=1 -.ELSE -LIB_BASE_DIR := $(SCITECH_LIB)\lib\release -.ENDIF - -# Define where to install library files - LIB_BASE := $(LIB_BASE_DIR)\$(LIB_OS)\$(WC_LIBBASE) - LIB_DEST := $(LIB_BASE) - - LDFLAGS += op map - -# Define which file contains our rules - - RULES_MAK := wc32.mk diff --git a/board/MAI/bios_emulator/scitech/src/biosemu/besys.c b/board/MAI/bios_emulator/scitech/src/biosemu/besys.c deleted file mode 100644 index 1512ce9bf9..0000000000 --- a/board/MAI/bios_emulator/scitech/src/biosemu/besys.c +++ /dev/null @@ -1,408 +0,0 @@ -/**************************************************************************** -* -* BIOS emulator and interface -* to Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: This file includes BIOS emulator I/O and memory access -* functions. -* -****************************************************************************/ - -#include "biosemui.h" - -/*------------------------------- Macros ----------------------------------*/ - -/* Macros to read and write values to x86 bus memory. Replace these as - * necessary if you need to do something special to access memory over - * the bus on a particular processor family. - */ - -#define readb(base,off) *((u8*)((u32)(base) + (off))) -#define readw(base,off) *((u16*)((u32)(base) + (off))) -#define readl(base,off) *((u32*)((u32)(base) + (off))) -#define writeb(v,base,off) *((u8*)((u32)(base) + (off))) = (v) -#define writew(v,base,off) *((u16*)((u32)(base) + (off))) = (v) -#define writel(v,base,off) *((u32*)((u32)(base) + (off))) = (v) - -/*----------------------------- Implementation ----------------------------*/ - -#ifdef DEBUG -# define DEBUG_MEM() (M.x86.debug & DEBUG_MEM_TRACE_F) -#else -# define DEBUG_MEM() -#endif - -/**************************************************************************** -PARAMETERS: -addr - Emulator memory address to read - -RETURNS: -Byte value read from emulator memory. - -REMARKS: -Reads a byte value from the emulator memory. We have three distinct memory -regions that are handled differently, which this function handles. -****************************************************************************/ -u8 X86API BE_rdb( - u32 addr) -{ - u8 val = 0; - - if (addr >= 0xC0000 && addr <= _BE_env.biosmem_limit) { - val = *(u8*)(_BE_env.biosmem_base + addr - 0xC0000); - } - else if (addr >= 0xA0000 && addr <= 0xFFFFF) { - val = readb(_BE_env.busmem_base, addr - 0xA0000); - } - else if (addr > M.mem_size - 1) { -DB( printk("mem_read: address %#lx out of range!\n", addr);) - HALT_SYS(); - } - else { - val = *(u8*)(M.mem_base + addr); - } -DB( if (DEBUG_MEM()) - printk("%#08x 1 -> %#x\n", addr, val);) - return val; -} - -/**************************************************************************** -PARAMETERS: -addr - Emulator memory address to read - -RETURNS: -Word value read from emulator memory. - -REMARKS: -Reads a word value from the emulator memory. We have three distinct memory -regions that are handled differently, which this function handles. -****************************************************************************/ -u16 X86API BE_rdw( - u32 addr) -{ - u16 val = 0; - - if (addr >= 0xC0000 && addr <= _BE_env.biosmem_limit) { -#ifdef __BIG_ENDIAN__ - if (addr & 0x1) { - addr -= 0xC0000; - val = ( *(u8*)(_BE_env.biosmem_base + addr) | - (*(u8*)(_BE_env.biosmem_base + addr + 1) << 8)); - } - else -#endif - val = *(u16*)(_BE_env.biosmem_base + addr - 0xC0000); - } - else if (addr >= 0xA0000 && addr <= 0xFFFFF) { -#ifdef __BIG_ENDIAN__ - if (addr & 0x1) { - addr -= 0xA0000; - val = ( readb(_BE_env.busmem_base, addr) | - (readb(_BE_env.busmem_base, addr + 1) << 8)); - } - else -#endif - val = readw(_BE_env.busmem_base, addr - 0xA0000); - } - else if (addr > M.mem_size - 2) { -DB( printk("mem_read: address %#lx out of range!\n", addr);) - HALT_SYS(); - } - else { -#ifdef __BIG_ENDIAN__ - if (addr & 0x1) { - val = ( *(u8*)(M.mem_base + addr) | - (*(u8*)(M.mem_base + addr + 1) << 8)); - } - else -#endif - val = *(u16*)(M.mem_base + addr); - } -DB( if (DEBUG_MEM()) - printk("%#08x 2 -> %#x\n", addr, val);) - return val; -} - -/**************************************************************************** -PARAMETERS: -addr - Emulator memory address to read - -RETURNS: -Long value read from emulator memory. - -REMARKS: -Reads a long value from the emulator memory. We have three distinct memory -regions that are handled differently, which this function handles. -****************************************************************************/ -u32 X86API BE_rdl( - u32 addr) -{ - u32 val = 0; - - if (addr >= 0xC0000 && addr <= _BE_env.biosmem_limit) { -#ifdef __BIG_ENDIAN__ - if (addr & 0x3) { - addr -= 0xC0000; - val = ( *(u8*)(_BE_env.biosmem_base + addr + 0) | - (*(u8*)(_BE_env.biosmem_base + addr + 1) << 8) | - (*(u8*)(_BE_env.biosmem_base + addr + 2) << 16) | - (*(u8*)(_BE_env.biosmem_base + addr + 3) << 24)); - } - else -#endif - val = *(u32*)(_BE_env.biosmem_base + addr - 0xC0000); - } - else if (addr >= 0xA0000 && addr <= 0xFFFFF) { -#ifdef __BIG_ENDIAN__ - if (addr & 0x3) { - addr -= 0xA0000; - val = ( readb(_BE_env.busmem_base, addr) | - (readb(_BE_env.busmem_base, addr + 1) << 8) | - (readb(_BE_env.busmem_base, addr + 2) << 16) | - (readb(_BE_env.busmem_base, addr + 3) << 24)); - } - else -#endif - val = readl(_BE_env.busmem_base, addr - 0xA0000); - } - else if (addr > M.mem_size - 4) { -DB( printk("mem_read: address %#lx out of range!\n", addr);) - HALT_SYS(); - } - else { -#ifdef __BIG_ENDIAN__ - if (addr & 0x3) { - val = ( *(u8*)(M.mem_base + addr + 0) | - (*(u8*)(M.mem_base + addr + 1) << 8) | - (*(u8*)(M.mem_base + addr + 2) << 16) | - (*(u8*)(M.mem_base + addr + 3) << 24)); - } - else -#endif - val = *(u32*)(M.mem_base + addr); - } -DB( if (DEBUG_MEM()) - printk("%#08x 4 -> %#x\n", addr, val);) - return val; -} - -/**************************************************************************** -PARAMETERS: -addr - Emulator memory address to read -val - Value to store - -REMARKS: -Writes a byte value to emulator memory. We have three distinct memory -regions that are handled differently, which this function handles. -****************************************************************************/ -void X86API BE_wrb( - u32 addr, - u8 val) -{ -DB( if (DEBUG_MEM()) - printk("%#08x 1 <- %#x\n", addr, val);) - if (addr >= 0xC0000 && addr <= _BE_env.biosmem_limit) { - *(u8*)(_BE_env.biosmem_base + addr - 0xC0000) = val; - } - else if (addr >= 0xA0000 && addr <= 0xFFFFF) { - writeb(val, _BE_env.busmem_base, addr - 0xA0000); - } - else if (addr > M.mem_size-1) { -DB( printk("mem_write: address %#lx out of range!\n", addr);) - HALT_SYS(); - } - else { - *(u8*)(M.mem_base + addr) = val; - } -} - -/**************************************************************************** -PARAMETERS: -addr - Emulator memory address to read -val - Value to store - -REMARKS: -Writes a word value to emulator memory. We have three distinct memory -regions that are handled differently, which this function handles. -****************************************************************************/ -void X86API BE_wrw( - u32 addr, - u16 val) -{ -DB( if (DEBUG_MEM()) - printk("%#08x 2 <- %#x\n", addr, val);) - if (addr >= 0xC0000 && addr <= _BE_env.biosmem_limit) { -#ifdef __BIG_ENDIAN__ - if (addr & 0x1) { - addr -= 0xC0000; - *(u8*)(_BE_env.biosmem_base + addr + 0) = (val >> 0) & 0xff; - *(u8*)(_BE_env.biosmem_base + addr + 1) = (val >> 8) & 0xff; - } - else -#endif - *(u16*)(_BE_env.biosmem_base + addr - 0xC0000) = val; - } - else if (addr >= 0xA0000 && addr <= 0xFFFFF) { -#ifdef __BIG_ENDIAN__ - if (addr & 0x1) { - addr -= 0xA0000; - writeb(val >> 0, _BE_env.busmem_base, addr); - writeb(val >> 8, _BE_env.busmem_base, addr + 1); - } - else -#endif - writew(val, _BE_env.busmem_base, addr - 0xA0000); - } - else if (addr > M.mem_size-2) { -DB( printk("mem_write: address %#lx out of range!\n", addr);) - HALT_SYS(); - } - else { -#ifdef __BIG_ENDIAN__ - if (addr & 0x1) { - *(u8*)(M.mem_base + addr + 0) = (val >> 0) & 0xff; - *(u8*)(M.mem_base + addr + 1) = (val >> 8) & 0xff; - } - else -#endif - *(u16*)(M.mem_base + addr) = val; - } -} - -/**************************************************************************** -PARAMETERS: -addr - Emulator memory address to read -val - Value to store - -REMARKS: -Writes a long value to emulator memory. We have three distinct memory -regions that are handled differently, which this function handles. -****************************************************************************/ -void X86API BE_wrl( - u32 addr, - u32 val) -{ -DB( if (DEBUG_MEM()) - printk("%#08x 4 <- %#x\n", addr, val);) - if (addr >= 0xC0000 && addr <= _BE_env.biosmem_limit) { -#ifdef __BIG_ENDIAN__ - if (addr & 0x1) { - addr -= 0xC0000; - *(u8*)(M.mem_base + addr + 0) = (val >> 0) & 0xff; - *(u8*)(M.mem_base + addr + 1) = (val >> 8) & 0xff; - *(u8*)(M.mem_base + addr + 2) = (val >> 16) & 0xff; - *(u8*)(M.mem_base + addr + 3) = (val >> 24) & 0xff; - } - else -#endif - *(u32*)(M.mem_base + addr - 0xC0000) = val; - } - else if (addr >= 0xA0000 && addr <= 0xFFFFF) { -#ifdef __BIG_ENDIAN__ - if (addr & 0x3) { - addr -= 0xA0000; - writeb(val >> 0, _BE_env.busmem_base, addr); - writeb(val >> 8, _BE_env.busmem_base, addr + 1); - writeb(val >> 16, _BE_env.busmem_base, addr + 1); - writeb(val >> 24, _BE_env.busmem_base, addr + 1); - } - else -#endif - writel(val, _BE_env.busmem_base, addr - 0xA0000); - } - else if (addr > M.mem_size-4) { -DB( printk("mem_write: address %#lx out of range!\n", addr);) - HALT_SYS(); - } - else { -#ifdef __BIG_ENDIAN__ - if (addr & 0x1) { - *(u8*)(M.mem_base + addr + 0) = (val >> 0) & 0xff; - *(u8*)(M.mem_base + addr + 1) = (val >> 8) & 0xff; - *(u8*)(M.mem_base + addr + 2) = (val >> 16) & 0xff; - *(u8*)(M.mem_base + addr + 3) = (val >> 24) & 0xff; - } - else -#endif - *(u32*)(M.mem_base + addr) = val; - } -} - -/* Debug functions to do ISA/PCI bus port I/O */ - -#ifdef DEBUG -#define DEBUG_IO() (M.x86.debug & DEBUG_IO_TRACE_F) - -u8 X86API BE_inb(int port) -{ - u8 val = PM_inpb(port); - if (DEBUG_IO()) - printk("%04X:%04X: inb.%04X -> %02X\n",M.x86.saved_cs, M.x86.saved_ip, (ushort)port, val); - return val; -} - -u16 X86API BE_inw(int port) -{ - u16 val = PM_inpw(port); - if (DEBUG_IO()) - printk("%04X:%04X: inw.%04X -> %04X\n",M.x86.saved_cs, M.x86.saved_ip, (ushort)port, val); - return val; -} - -u32 X86API BE_inl(int port) -{ - u32 val = PM_inpd(port); - if (DEBUG_IO()) - printk("%04X:%04X: inl.%04X -> %08X\n",M.x86.saved_cs, M.x86.saved_ip, (ushort)port, val); - return val; -} - -void X86API BE_outb(int port, u8 val) -{ - if (DEBUG_IO()) - printk("%04X:%04X: outb.%04X <- %02X\n",M.x86.saved_cs, M.x86.saved_ip, (ushort)port, val); - PM_outpb(port,val); -} - -void X86API BE_outw(int port, u16 val) -{ - if (DEBUG_IO()) - printk("%04X:%04X: outw.%04X <- %04X\n",M.x86.saved_cs, M.x86.saved_ip, (ushort)port, val); - PM_outpw(port,val); -} - -void X86API BE_outl(int port, u32 val) -{ - if (DEBUG_IO()) - printk("%04X:%04X: outl.%04X <- %08X\n",M.x86.saved_cs, M.x86.saved_ip, (ushort)port, val); - PM_outpd(port,val); -} -#endif diff --git a/board/MAI/bios_emulator/scitech/src/biosemu/bios.c b/board/MAI/bios_emulator/scitech/src/biosemu/bios.c deleted file mode 100644 index c0f4a4b18e..0000000000 --- a/board/MAI/bios_emulator/scitech/src/biosemu/bios.c +++ /dev/null @@ -1,250 +0,0 @@ -/**************************************************************************** -* -* BIOS emulator and interface -* to Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Module implementing the BIOS specific functions. -* -****************************************************************************/ - -#include "biosemui.h" - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -PARAMETERS: -intno - Interrupt number being serviced - -REMARKS: -Handler for undefined interrupts. -****************************************************************************/ -static void X86API undefined_intr( - int intno) -{ - if (BE_rdw(intno * 4 + 2) == BIOS_SEG) - printk("biosEmu: undefined interrupt %xh called!\n",intno); - else - X86EMU_prepareForInt(intno); -} - -/**************************************************************************** -PARAMETERS: -intno - Interrupt number being serviced - -REMARKS: -This function handles the default system BIOS Int 10h (the default is stored -in the Int 42h vector by the system BIOS at bootup). We only need to handle -a small number of special functions used by the BIOS during POST time. -****************************************************************************/ -static void X86API int42( - int intno) -{ - if (M.x86.R_AH == 0x12 && M.x86.R_BL == 0x32) { - if (M.x86.R_AL == 0) { - /* Enable CPU accesses to video memory */ - PM_outpb(0x3c2, PM_inpb(0x3cc) | (u8)0x02); - return; - } - else if (M.x86.R_AL == 1) { - /* Disable CPU accesses to video memory */ - PM_outpb(0x3c2, PM_inpb(0x3cc) & (u8)~0x02); - return; - } -#ifdef DEBUG - else { - printk("biosEmu/bios.int42: unknown function AH=0x12, BL=0x32, AL=%#02x\n",M.x86.R_AL); - } -#endif - } -#ifdef DEBUG - else { - printk("biosEmu/bios.int42: unknown function AH=%#02x, AL=%#02x, BL=%#02x\n",M.x86.R_AH, M.x86.R_AL, M.x86.R_BL); - } -#endif -} - -/**************************************************************************** -PARAMETERS: -intno - Interrupt number being serviced - -REMARKS: -This function handles the default system BIOS Int 10h. If the POST code -has not yet re-vectored the Int 10h BIOS interrupt vector, we handle this -by simply calling the int42 interrupt handler above. Very early in the -BIOS POST process, the vector gets replaced and we simply let the real -mode interrupt handler process the interrupt. -****************************************************************************/ -static void X86API int10( - int intno) -{ - if (BE_rdw(intno * 4 + 2) == BIOS_SEG) - int42(intno); - else - X86EMU_prepareForInt(intno); -} - -/* Result codes returned by the PCI BIOS */ - -#define SUCCESSFUL 0x00 -#define FUNC_NOT_SUPPORT 0x81 -#define BAD_VENDOR_ID 0x83 -#define DEVICE_NOT_FOUND 0x86 -#define BAD_REGISTER_NUMBER 0x87 -#define SET_FAILED 0x88 -#define BUFFER_TOO_SMALL 0x89 - -/**************************************************************************** -PARAMETERS: -intno - Interrupt number being serviced - -REMARKS: -This function handles the default Int 1Ah interrupt handler for the real -mode code, which provides support for the PCI BIOS functions. Since we only -want to allow the real mode BIOS code *only* see the PCI config space for -its own device, we only return information for the specific PCI config -space that we have passed in to the init function. This solves problems -when using the BIOS to warm boot a secondary adapter when there is an -identical adapter before it on the bus (some BIOS'es get confused in this -case). -****************************************************************************/ -static void X86API int1A( - unused) -{ - u16 pciSlot; - - /* Fail if no PCI device information has been registered */ - if (!_BE_env.vgaInfo.pciInfo) - return; - pciSlot = (u16)(_BE_env.vgaInfo.pciInfo->slot.i >> 8); - switch (M.x86.R_AX) { - case 0xB101: /* PCI bios present? */ - M.x86.R_AL = 0x00; /* no config space/special cycle generation support */ - M.x86.R_EDX = 0x20494350; /* " ICP" */ - M.x86.R_BX = 0x0210; /* Version 2.10 */ - M.x86.R_CL = 0; /* Max bus number in system */ - CLEAR_FLAG(F_CF); - break; - case 0xB102: /* Find PCI device */ - M.x86.R_AH = DEVICE_NOT_FOUND; - if (M.x86.R_DX == _BE_env.vgaInfo.pciInfo->VendorID && - M.x86.R_CX == _BE_env.vgaInfo.pciInfo->DeviceID && - M.x86.R_SI == 0) { - M.x86.R_AH = SUCCESSFUL; - M.x86.R_BX = pciSlot; - } - CONDITIONAL_SET_FLAG((M.x86.R_AH != SUCCESSFUL), F_CF); - break; - case 0xB103: /* Find PCI class code */ - M.x86.R_AH = DEVICE_NOT_FOUND; - if (M.x86.R_CL == _BE_env.vgaInfo.pciInfo->Interface && - M.x86.R_CH == _BE_env.vgaInfo.pciInfo->SubClass && - (u8)(M.x86.R_ECX >> 16) == _BE_env.vgaInfo.pciInfo->BaseClass) { - M.x86.R_AH = SUCCESSFUL; - M.x86.R_BX = pciSlot; - } - CONDITIONAL_SET_FLAG((M.x86.R_AH != SUCCESSFUL), F_CF); - break; - case 0xB108: /* Read configuration byte */ - M.x86.R_AH = BAD_REGISTER_NUMBER; - if (M.x86.R_BX == pciSlot) { - M.x86.R_AH = SUCCESSFUL; - M.x86.R_CL = (u8)PCI_accessReg(M.x86.R_DI,0,PCI_READ_BYTE,_BE_env.vgaInfo.pciInfo); - } - CONDITIONAL_SET_FLAG((M.x86.R_AH != SUCCESSFUL), F_CF); - break; - case 0xB109: /* Read configuration word */ - M.x86.R_AH = BAD_REGISTER_NUMBER; - if (M.x86.R_BX == pciSlot) { - M.x86.R_AH = SUCCESSFUL; - M.x86.R_CX = (u16)PCI_accessReg(M.x86.R_DI,0,PCI_READ_WORD,_BE_env.vgaInfo.pciInfo); - } - CONDITIONAL_SET_FLAG((M.x86.R_AH != SUCCESSFUL), F_CF); - break; - case 0xB10A: /* Read configuration dword */ - M.x86.R_AH = BAD_REGISTER_NUMBER; - if (M.x86.R_BX == pciSlot) { - M.x86.R_AH = SUCCESSFUL; - M.x86.R_ECX = (u32)PCI_accessReg(M.x86.R_DI,0,PCI_READ_DWORD,_BE_env.vgaInfo.pciInfo); - } - CONDITIONAL_SET_FLAG((M.x86.R_AH != SUCCESSFUL), F_CF); - break; - case 0xB10B: /* Write configuration byte */ - M.x86.R_AH = BAD_REGISTER_NUMBER; - if (M.x86.R_BX == pciSlot) { - M.x86.R_AH = SUCCESSFUL; - PCI_accessReg(M.x86.R_DI,M.x86.R_CL,PCI_WRITE_BYTE,_BE_env.vgaInfo.pciInfo); - } - CONDITIONAL_SET_FLAG((M.x86.R_AH != SUCCESSFUL), F_CF); - break; - case 0xB10C: /* Write configuration word */ - M.x86.R_AH = BAD_REGISTER_NUMBER; - if (M.x86.R_BX == pciSlot) { - M.x86.R_AH = SUCCESSFUL; - PCI_accessReg(M.x86.R_DI,M.x86.R_CX,PCI_WRITE_WORD,_BE_env.vgaInfo.pciInfo); - } - CONDITIONAL_SET_FLAG((M.x86.R_AH != SUCCESSFUL), F_CF); - break; - case 0xB10D: /* Write configuration dword */ - M.x86.R_AH = BAD_REGISTER_NUMBER; - if (M.x86.R_BX == pciSlot) { - M.x86.R_AH = SUCCESSFUL; - PCI_accessReg(M.x86.R_DI,M.x86.R_ECX,PCI_WRITE_DWORD,_BE_env.vgaInfo.pciInfo); - } - CONDITIONAL_SET_FLAG((M.x86.R_AH != SUCCESSFUL), F_CF); - break; - default: - printk("biosEmu/bios.int1a: unknown function AX=%#04x\n", M.x86.R_AX); - } -} - -/**************************************************************************** -REMARKS: -This function initialises the BIOS emulation functions for the specific -PCI display device. We insulate the real mode BIOS from any other devices -on the bus, so that it will work correctly thinking that it is the only -device present on the bus (ie: avoiding any adapters present in from of -the device we are trying to control). -****************************************************************************/ -void _BE_bios_init( - u32 *intrTab) -{ - int i; - X86EMU_intrFuncs bios_intr_tab[256]; - - for (i = 0; i < 256; ++i) { - intrTab[i] = BIOS_SEG << 16; - bios_intr_tab[i] = undefined_intr; - } - bios_intr_tab[0x10] = int10; - bios_intr_tab[0x1A] = int1A; - bios_intr_tab[0x42] = int42; - X86EMU_setupIntrFuncs(bios_intr_tab); -} diff --git a/board/MAI/bios_emulator/scitech/src/biosemu/biosemu.c b/board/MAI/bios_emulator/scitech/src/biosemu/biosemu.c deleted file mode 100644 index 0052709cc6..0000000000 --- a/board/MAI/bios_emulator/scitech/src/biosemu/biosemu.c +++ /dev/null @@ -1,445 +0,0 @@ -/**************************************************************************** -* -* BIOS emulator and interface -* to Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Module implementing the system specific functions. This -* module is always compiled and linked in the OS depedent -* libraries, and never in a binary portable driver. -* -****************************************************************************/ - -#include "biosemui.h" -#include -#include - -/*------------------------- Global Variables ------------------------------*/ - -BE_sysEnv _BE_env; -#ifdef __DRIVER__ -PM_imports _VARAPI _PM_imports; -#endif -static X86EMU_memFuncs _BE_mem = { - BE_rdb, - BE_rdw, - BE_rdl, - BE_wrb, - BE_wrw, - BE_wrl, - }; -#ifdef DEBUG -static X86EMU_pioFuncs _BE_pio = { - BE_inb, - BE_inw, - BE_inl, - BE_outb, - BE_outw, - BE_outl, - }; -#else -static X86EMU_pioFuncs _BE_pio = { - (void*)PM_inpb, - (void*)PM_inpw, - (void*)PM_inpd, - (void*)PM_outpb, - (void*)PM_outpw, - (void*)PM_outpd, - }; -#endif - -/*-------------------------- Implementation -------------------------------*/ - -#define OFF(addr) (u16)(((addr) >> 0) & 0xffff) -#define SEG(addr) (u16)(((addr) >> 4) & 0xf000) - -/**************************************************************************** -PARAMETERS: -debugFlags - Flags to enable debugging options (debug builds only) -memSize - Amount of memory to allocate for real mode machine -info - Pointer to default VGA device information - -REMARKS: -This functions initialises the BElib, and uses the passed in -BIOS image as the BIOS that is used and emulated at 0xC0000. -****************************************************************************/ -ibool PMAPI BE_init( - u32 debugFlags, - int memSize, - BE_VGAInfo *info) -{ -#ifndef __DRIVER__ - PM_init(); -#endif - memset(&M,0,sizeof(M)); - if (memSize < 20480) - PM_fatalError("Emulator requires at least 20Kb of memory!\n"); - if ((M.mem_base = (unsigned long)malloc(memSize)) == NULL) - PM_fatalError("Out of memory!"); - M.mem_size = memSize; - _BE_env.busmem_base = (ulong)PM_mapPhysicalAddr(0xA0000,0x5FFFF,true); - M.x86.debug = debugFlags; - _BE_bios_init((u32*)info->LowMem); - X86EMU_setupMemFuncs(&_BE_mem); - X86EMU_setupPioFuncs(&_BE_pio); - BE_setVGA(info); - return true; -} - -/**************************************************************************** -PARAMETERS: -debugFlags - Flags to enable debugging options (debug builds only) - -REMARKS: -This function allows the application to enable logging and debug flags -on a function call basis, so we can specifically enable logging only -for specific functions that are causing problems in debug mode. -****************************************************************************/ -void PMAPI BE_setDebugFlags( - u32 debugFlags) -{ - M.x86.debug = debugFlags; -} - -/**************************************************************************** -PARAMETERS: -info - Pointer to VGA device information to make current - -REMARKS: -This function sets the VGA BIOS functions in the emulator to point to the -specific VGA BIOS in use. This includes swapping the BIOS interrupt -vectors, BIOS image and BIOS data area to the new BIOS. This allows the -real mode BIOS to be swapped without resetting the entire emulator. -****************************************************************************/ -void PMAPI BE_setVGA( - BE_VGAInfo *info) -{ - _BE_env.vgaInfo.pciInfo = info->pciInfo; - _BE_env.vgaInfo.BIOSImage = info->BIOSImage; - if (info->BIOSImage) { - _BE_env.biosmem_base = (ulong)info->BIOSImage; - _BE_env.biosmem_limit = 0xC0000 + info->BIOSImageLen-1; - } - else { - _BE_env.biosmem_base = _BE_env.busmem_base + 0x20000; - _BE_env.biosmem_limit = 0xC7FFF; - } - if (*((u32*)info->LowMem) == 0) - _BE_bios_init((u32*)info->LowMem); - memcpy((u8*)M.mem_base,info->LowMem,sizeof(info->LowMem)); -} - -/**************************************************************************** -PARAMETERS: -info - Pointer to VGA device information to retrieve current - -REMARKS: -This function returns the VGA BIOS functions currently active in the -emulator, so they can be restored at a later date. -****************************************************************************/ -void PMAPI BE_getVGA( - BE_VGAInfo *info) -{ - info->pciInfo = _BE_env.vgaInfo.pciInfo; - info->BIOSImage = _BE_env.vgaInfo.BIOSImage; - memcpy(info->LowMem,(u8*)M.mem_base,sizeof(info->LowMem)); -} - -/**************************************************************************** -PARAMETERS: -r_seg - Segment for pointer to convert -r_off - Offset for pointer to convert - -REMARKS: -This function maps a real mode pointer in the emulator memory to a protected -mode pointer that can be used to directly access the memory. - -NOTE: The memory is *always* in little endian format, son on non-x86 - systems you will need to do endian translations to access this - memory. -****************************************************************************/ -void * PMAPI BE_mapRealPointer( - uint r_seg, - uint r_off) -{ - u32 addr = ((u32)r_seg << 4) + r_off; - - if (addr >= 0xC0000 && addr <= _BE_env.biosmem_limit) { - return (void*)(_BE_env.biosmem_base + addr - 0xC0000); - } - else if (addr >= 0xA0000 && addr <= 0xFFFFF) { - return (void*)(_BE_env.busmem_base + addr - 0xA0000); - } - return (void*)(M.mem_base + addr); -} - -/**************************************************************************** -PARAMETERS: -len - Return the length of the VESA buffer -rseg - Place to store VESA buffer segment -roff - Place to store VESA buffer offset - -REMARKS: -This function returns the address of the VESA transfer buffer in real -mode emulator memory. The VESA transfer buffer is always 1024 bytes long, -and located at 15Kb into the start of the real mode memory (16Kb is where -we put the real mode code we execute for issuing interrupts). - -NOTE: The memory is *always* in little endian format, son on non-x86 - systems you will need to do endian translations to access this - memory. -****************************************************************************/ -void * PMAPI BE_getVESABuf( - uint *len, - uint *rseg, - uint *roff) -{ - *len = 1024; - *rseg = SEG(0x03C00); - *roff = OFF(0x03C00); - return (void*)(M.mem_base + ((u32)*rseg << 4) + *roff); -} - -/**************************************************************************** -REMARKS: -Cleans up and exits the emulator. -****************************************************************************/ -void PMAPI BE_exit(void) -{ - free((void*)M.mem_base); - PM_freePhysicalAddr((void*)_BE_env.busmem_base,0x5FFFF); -} - -/**************************************************************************** -PARAMETERS: -seg - Segment of code to call -off - Offset of code to call -regs - Real mode registers to load -sregs - Real mode segment registers to load - -REMARKS: -This functions calls a real mode far function at the specified address, -and loads all the x86 registers from the passed in registers structure. -On exit the registers returned from the call are returned in the same -structures. -****************************************************************************/ -void PMAPI BE_callRealMode( - uint seg, - uint off, - RMREGS *regs, - RMSREGS *sregs) -{ - M.x86.R_EAX = regs->e.eax; - M.x86.R_EBX = regs->e.ebx; - M.x86.R_ECX = regs->e.ecx; - M.x86.R_EDX = regs->e.edx; - M.x86.R_ESI = regs->e.esi; - M.x86.R_EDI = regs->e.edi; - M.x86.R_DS = sregs->ds; - M.x86.R_ES = sregs->es; - M.x86.R_FS = sregs->fs; - M.x86.R_GS = sregs->gs; - M.x86.R_CS = (u16)seg; - M.x86.R_IP = (u16)off; - M.x86.R_SS = SEG(M.mem_size - 1); - M.x86.R_SP = OFF(M.mem_size - 1); - X86EMU_exec(); - regs->e.cflag = M.x86.R_EFLG & F_CF; - regs->e.eax = M.x86.R_EAX; - regs->e.ebx = M.x86.R_EBX; - regs->e.ecx = M.x86.R_ECX; - regs->e.edx = M.x86.R_EDX; - regs->e.esi = M.x86.R_ESI; - regs->e.edi = M.x86.R_EDI; - sregs->ds = M.x86.R_DS; - sregs->es = M.x86.R_ES; - sregs->fs = M.x86.R_FS; - sregs->gs = M.x86.R_GS; -} - -/**************************************************************************** -PARAMETERS: -intno - Interrupt number to execute -in - Real mode registers to load -out - Place to store resulting real mode registers - -REMARKS: -This functions calls a real mode interrupt function at the specified address, -and loads all the x86 registers from the passed in registers structure. -On exit the registers returned from the call are returned in out stucture. -****************************************************************************/ -int PMAPI BE_int86( - int intno, - RMREGS *in, - RMREGS *out) -{ - M.x86.R_EAX = in->e.eax; - M.x86.R_EBX = in->e.ebx; - M.x86.R_ECX = in->e.ecx; - M.x86.R_EDX = in->e.edx; - M.x86.R_ESI = in->e.esi; - M.x86.R_EDI = in->e.edi; - ((u8*)M.mem_base)[0x4000] = 0xCD; - ((u8*)M.mem_base)[0x4001] = (u8)intno; - ((u8*)M.mem_base)[0x4002] = 0xC3; - M.x86.R_CS = SEG(0x04000); - M.x86.R_IP = OFF(0x04000); - M.x86.R_SS = SEG(M.mem_size - 1); - M.x86.R_SP = OFF(M.mem_size - 1); - X86EMU_exec(); - out->e.cflag = M.x86.R_EFLG & F_CF; - out->e.eax = M.x86.R_EAX; - out->e.ebx = M.x86.R_EBX; - out->e.ecx = M.x86.R_ECX; - out->e.edx = M.x86.R_EDX; - out->e.esi = M.x86.R_ESI; - out->e.edi = M.x86.R_EDI; - return out->x.ax; -} - -/**************************************************************************** -PARAMETERS: -intno - Interrupt number to execute -in - Real mode registers to load -out - Place to store resulting real mode registers -sregs - Real mode segment registers to load - -REMARKS: -This functions calls a real mode interrupt function at the specified address, -and loads all the x86 registers from the passed in registers structure. -On exit the registers returned from the call are returned in out stucture. -****************************************************************************/ -int PMAPI BE_int86x( - int intno, - RMREGS *in, - RMREGS *out, - RMSREGS *sregs) -{ - M.x86.R_EAX = in->e.eax; - M.x86.R_EBX = in->e.ebx; - M.x86.R_ECX = in->e.ecx; - M.x86.R_EDX = in->e.edx; - M.x86.R_ESI = in->e.esi; - M.x86.R_EDI = in->e.edi; - M.x86.R_DS = sregs->ds; - M.x86.R_ES = sregs->es; - M.x86.R_FS = sregs->fs; - M.x86.R_GS = sregs->gs; - ((u8*)M.mem_base)[0x4000] = 0xCD; - ((u8*)M.mem_base)[0x4001] = (u8)intno; - ((u8*)M.mem_base)[0x4002] = 0xC3; - M.x86.R_CS = SEG(0x04000); - M.x86.R_IP = OFF(0x04000); - M.x86.R_SS = SEG(M.mem_size - 1); - M.x86.R_SP = OFF(M.mem_size - 1); - X86EMU_exec(); - out->e.cflag = M.x86.R_EFLG & F_CF; - out->e.eax = M.x86.R_EAX; - out->e.ebx = M.x86.R_EBX; - out->e.ecx = M.x86.R_ECX; - out->e.edx = M.x86.R_EDX; - out->e.esi = M.x86.R_ESI; - out->e.edi = M.x86.R_EDI; - sregs->ds = M.x86.R_DS; - sregs->es = M.x86.R_ES; - sregs->fs = M.x86.R_FS; - sregs->gs = M.x86.R_GS; - return out->x.ax; -} - -#ifdef __DRIVER__ - -/**************************************************************************** -REMARKS: -Empty log function for binary portable DLL. The BPD is compiled without -debug information, so very little is logged anyway so it is simpler this -way. -****************************************************************************/ -void printk(const char *msg, ...) -{ -} - -/**************************************************************************** -REMARKS: -Fatal error handler called when a non-imported function is called by the -driver. We leave this to a runtime error so that older applications and -shell drivers will work with newer bpd drivers provided no newer functions -are required by the driver itself. If they are, the application or shell -driver needs to be recompiled. -****************************************************************************/ -static void _PM_fatalErrorHandler(void) -{ - PM_fatalError("Unsupported PM_imports import function called! Please re-compile!\n"); -} - -/**************************************************************************** -PARAMETERS: -beImp - BE library imports -beImp - Generic emulator imports - -RETURNS: -Pointer to exported function list - -REMARKS: -This function initialises the BIOS emulator library and returns the list of -loader library exported functions. -{secret} -****************************************************************************/ -BE_exports * _CEXPORT BE_initLibrary( - PM_imports *pmImp) -{ - static BE_exports _BE_exports = { - sizeof(BE_exports), - BE_init, - BE_setVGA, - BE_getVGA, - BE_mapRealPointer, - BE_getVESABuf, - BE_callRealMode, - BE_int86, - BE_int86x, - NULL, - BE_exit, - }; - int i,max; - ulong *p; - - /* Initialize all default imports to point to fatal error handler */ - /* for upwards compatibility. */ - max = sizeof(_PM_imports)/sizeof(BE_initLibrary_t); - for (i = 0,p = (ulong*)&_PM_imports; i < max; i++) - *p++ = (ulong)_PM_fatalErrorHandler; - - /* Now copy all our imported functions */ - memcpy(&_PM_imports,pmImp,MIN(sizeof(_PM_imports),pmImp->dwSize)); - return &_BE_exports; -} - -#endif /* __DRIVER__ */ diff --git a/board/MAI/bios_emulator/scitech/src/biosemu/biosemui.h b/board/MAI/bios_emulator/scitech/src/biosemu/biosemui.h deleted file mode 100644 index 23edebc95c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/biosemu/biosemui.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -* -* BIOS emulator and interface -* to Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Internal header file for the BIOS emulator library. -* -****************************************************************************/ - -#ifndef __BIOSEMUI_H -#define __BIOSEMUI_H - -#include - -/*---------------------- Macros and type definitions ----------------------*/ - -#ifdef DEBUG -#define DB(x) x -#else -#define DB(x) -#endif - -#define BIOS_SEG 0xfff0 - -#define M _X86EMU_env - -/*-------------------------- Function Prototypes --------------------------*/ - -/* bios.c */ - -void _BE_bios_init(u32 *intrTab); -void _BE_setup_funcs(void); - -/* besys.c */ - -u8 X86API BE_rdb(u32 addr); -u16 X86API BE_rdw(u32 addr); -u32 X86API BE_rdl(u32 addr); -void X86API BE_wrb(u32 addr,u8 val); -void X86API BE_wrw(u32 addr,u16 val); -void X86API BE_wrl(u32 addr,u32 val); -#ifdef DEBUG -u8 X86API BE_inb(int port); -u16 X86API BE_inw(int port); -u32 X86API BE_inl(int port); -void X86API BE_outb(int port, u8 val); -void X86API BE_outw(int port, u16 val); -void X86API BE_outl(int port, u32 val); -#endif - -#endif /* __BIOSEMUI_H */ diff --git a/board/MAI/bios_emulator/scitech/src/biosemu/makefile b/board/MAI/bios_emulator/scitech/src/biosemu/makefile deleted file mode 100644 index 80730b2997..0000000000 --- a/board/MAI/bios_emulator/scitech/src/biosemu/makefile +++ /dev/null @@ -1,99 +0,0 @@ -############################################################################# -# -# BIOS emulator and interface -# to Realmode X86 Emulator Library -# -# Copyright (C) 1996-1999 SciTech Software, Inc. -# -# ======================================================================== -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, -# provided that the above copyright notice appear in all copies and that -# both that copyright notice and this permission notice appear in -# supporting documentation, and that the name of the authors not be used -# in advertising or publicity pertaining to distribution of the software -# without specific, written prior permission. The authors makes no -# representations about the suitability of this software for any purpose. -# It is provided "as is" without express or implied warranty. -# -# THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -# EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. -# -# ======================================================================== -# -# Descripton: Generic makefile for the x86emu library. Requires -# the SciTech Software makefile definitions package to be -# installed, which uses the DMAKE make program. -# -############################################################################# - -.IMPORT .IGNORE: DEBUG - -#---------------------------------------------------------------------------- -# Define the lists of object files -#---------------------------------------------------------------------------- - -DLL_OBJS = dllstart$O _pm_imp$O -BIOS_OBJS = biosemu$O bios$O besys$O -X86_OBJS = sys$O decode$O ops$O ops2$O prim_ops$O fpu$O debug$O -CFLAGS += -DSCITECH -I$(SCITECH)\src\x86emu - -.IF $(BUILD_DLL) - -CFLAGS += -I$(PRIVATE)\include\drvlib -I$(SCITECH)\include\drvlib -D__DRIVER__ -ASFLAGS += -d__DRIVER__ -EXELIBS = drvlib$L - -.ELSE - -.IF $(DEBUG) -CFLAGS += -DDEBUG -.ENDIF -OBJECTS = $(BIOS_OBJS) $(X86_OBJS) -LIBCLEAN = *.dll *.lib *.a -LIBFILE = $(LP)biosemu$L - -.ENDIF - -#---------------------------------------------------------------------------- -# Sample test programs -#---------------------------------------------------------------------------- - -all: $(LIBFILE) warmboot$E - -warmboot$E: warmboot$O $(LIBFILE) - -#---------------------------------------------------------------------------- -# Target to build the Binary Portable DLL target -#---------------------------------------------------------------------------- - -biosemu.dll: $(DLL_OBJS) $(BIOS_OBJS) $(X86_OBJS) - -#---------------------------------------------------------------------------- -# Target to build all Intel binary drivers -#---------------------------------------------------------------------------- - -.PHONY mkdrv: - @build wc11-w32 biosemu.dll -u BUILD_DLL=1 NO_RUNTIME=1 OPT=1 - @$(CP) biosemu.dll $(PRIVATE)\nucleus\graphics\biosemu.bpd - @dmake cleanexe - -.PHONY db: - @build wc11-w32 biosemu.dll BUILD_DLL=1 NO_RUNTIME=1 OPT=1 - @$(CP) biosemu.dll $(PRIVATE)\nucleus\graphics\biosemu.bpd - -#---------------------------------------------------------------------------- -# Define the list of object files to create dependency information for -#---------------------------------------------------------------------------- - -DEPEND_OBJ = warmboot$O $(BIOS_OBJS) $(X86_OBJS) $(DLL_OBJS) -DEPEND_SRC = $(SCITECH)/src/x86emu;$(PRIVATE)/src/common -.SOURCE: $(SCITECH)/src/x86emu $(PRIVATE)/src/common - -.INCLUDE: "$(SCITECH)/makedefs/common.mk" diff --git a/board/MAI/bios_emulator/scitech/src/biosemu/makefile.cross b/board/MAI/bios_emulator/scitech/src/biosemu/makefile.cross deleted file mode 100644 index 9141003076..0000000000 --- a/board/MAI/bios_emulator/scitech/src/biosemu/makefile.cross +++ /dev/null @@ -1,10 +0,0 @@ -CC = ppc-elf32-gcc -AR = ppc-elf32-ar - -CFLAGS = -D__DRIVER__ -I../../include -DDEBUG -I. - -BIOS_OBJS = biosemu.o bios.o besys.o -X86_OBJS = sys.o decode.o ops.o prim_ops.o fpu.o debug.o - -libbios.a: $(BIOS_OBJS) - $(AR) rcs libbios.a $(BIOS_OBJS) \ No newline at end of file diff --git a/board/MAI/bios_emulator/scitech/src/biosemu/warmboot.c b/board/MAI/bios_emulator/scitech/src/biosemu/warmboot.c deleted file mode 100644 index 98d5fb8a62..0000000000 --- a/board/MAI/bios_emulator/scitech/src/biosemu/warmboot.c +++ /dev/null @@ -1,569 +0,0 @@ -/**************************************************************************** -* -* BIOS emulator and interface -* to Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Module to implement warm booting of all PCI/AGP controllers -* on the bus. We use the x86 real mode emulator to run the -* BIOS on the primary and secondary controllers to bring -* the cards up. -* -****************************************************************************/ - -#include -#include -#include -#include -#include "biosemu.h" -#ifndef _MAX_PATH -#define _MAX_PATH 256 -#endif - -/*------------------------- Global Variables ------------------------------*/ - -static PCIDeviceInfo PCI[MAX_PCI_DEVICES]; -static int NumPCI = -1; -static int BridgeIndex[MAX_PCI_DEVICES] = {0}; -static int NumBridges; -static PCIBridgeInfo *AGPBridge = NULL; -static int DeviceIndex[MAX_PCI_DEVICES] = {0}; -static int NumDevices; -static u32 debugFlags = 0; -static BE_VGAInfo VGAInfo[MAX_PCI_DEVICES] = {{0}}; -static ibool useV86 = false; -static ibool forcePost = false; - -/* Length of the BIOS image */ - -#define MAX_BIOSLEN (64 * 1024L) -#define FINAL_BIOSLEN (32 * 1024L) - -/* Macro to determine if the VGA is enabled and responding */ - -#define VGA_NOT_ACTIVE() (forcePost || (PM_inpb(0x3CC) == 0xFF) || ((PM_inpb(0x3CC) & 0x2) == 0)) - -#define ENABLE_DEVICE(device) \ - PCI_writePCIRegB(0x4,PCI[DeviceIndex[device]].Command | 0x7,device) - -#define DISABLE_DEVICE(device) \ - PCI_writePCIRegB(0x4,0,device) - -/* Macros to enable and disable AGP VGA resources */ - -#define ENABLE_AGP_VGA() \ - PCI_accessReg(0x3E,AGPBridge->BridgeControl | 0x8,PCI_WRITE_WORD,(PCIDeviceInfo*)AGPBridge) - -#define DISABLE_AGP_VGA() \ - PCI_accessReg(0x3E,AGPBridge->BridgeControl & ~0x8,PCI_WRITE_WORD,(PCIDeviceInfo*)AGPBridge) - -#define RESTORE_AGP_VGA() \ - PCI_accessReg(0x3E,AGPBridge->BridgeControl,PCI_WRITE_WORD,(PCIDeviceInfo*)AGPBridge) - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -RETURNS: -The address to use to map the secondary BIOS (PCI/AGP devices) - -REMARKS: -Searches all the PCI base address registers for the device looking for a -memory mapping that is large enough to hold our ROM BIOS. We usually end up -finding the framebuffer mapping (usually BAR 0x10), and we use this mapping -to map the BIOS for the device into. We use a mapping that is already -assigned to the device to ensure the memory range will be passed through -by any PCI->PCI or AGP->PCI bridge that may be present. - -NOTE: Usually this function is only used for AGP devices, but it may be - used for PCI devices that have already been POST'ed and the BIOS - ROM base address has been zero'ed out. -****************************************************************************/ -static ulong PCI_findBIOSAddr( - int device) -{ - ulong base,size; - int bar; - - for (bar = 0x10; bar <= 0x14; bar++) { - base = PCI_readPCIRegL(bar,device) & ~0xFF; - if (!(base & 0x1)) { - PCI_writePCIRegL(bar,0xFFFFFFFF,device); - size = PCI_readPCIRegL(bar,device) & ~0xFF; - size = ~size+1; - PCI_writePCIRegL(bar,0,device); - if (size >= MAX_BIOSLEN) - return base; - } - } - return 0; -} - -/**************************************************************************** -REMARKS: -Re-writes the PCI base address registers for the secondary PCI controller -with the values from our initial PCI bus enumeration. This fixes up the -values after we have POST'ed the secondary display controller BIOS, which -may have incorrectly re-programmed the base registers the same as the -primary display controller (the case for identical S3 cards). -****************************************************************************/ -static void _PCI_fixupSecondaryBARs(void) -{ - int i; - - for (i = 0; i < NumDevices; i++) { - PCI_writePCIRegL(0x10,PCI[DeviceIndex[i]].BaseAddress10,i); - PCI_writePCIRegL(0x14,PCI[DeviceIndex[i]].BaseAddress14,i); - PCI_writePCIRegL(0x18,PCI[DeviceIndex[i]].BaseAddress18,i); - PCI_writePCIRegL(0x1C,PCI[DeviceIndex[i]].BaseAddress1C,i); - PCI_writePCIRegL(0x20,PCI[DeviceIndex[i]].BaseAddress20,i); - PCI_writePCIRegL(0x24,PCI[DeviceIndex[i]].BaseAddress24,i); - } -} - -/**************************************************************************** -RETURNS: -True if successfully initialised, false if not. - -REMARKS: -This function executes the BIOS POST code on the controller. We assume that -at this stage the controller has its I/O and memory space enabled and -that all other controllers are in a disabled state. -****************************************************************************/ -static void PCI_doBIOSPOST( - int device, - ulong BIOSPhysAddr, - void *mappedBIOS, - ulong BIOSLen) -{ - RMREGS regs; - RMSREGS sregs; - - /* Determine the value to store in AX for BIOS POST */ - regs.x.ax = (u16)(PCI[DeviceIndex[device]].slot.i >> 8); - if (useV86) { - /* Post the BIOS using the PM functions (ie: v86 mode on Linux) */ - if (!PM_doBIOSPOST(regs.x.ax,BIOSPhysAddr,mappedBIOS,BIOSLen)) { - /* If the PM function fails, this probably means are we are on */ - /* DOS and can't re-map the real mode 0xC0000 region. In thise */ - /* case if the device is the primary, we can use the real */ - /* BIOS at 0xC0000 directly. */ - if (device == 0) - PM_doBIOSPOST(regs.x.ax,0xC0000,mappedBIOS,BIOSLen); - } - } - else { - /* Setup the X86 emulator for the VGA BIOS */ - BE_setVGA(&VGAInfo[device]); - - /* Execute the BIOS POST code */ - BE_callRealMode(0xC000,0x0003,®s,&sregs); - - /* Cleanup and exit */ - BE_getVGA(&VGAInfo[device]); - } -} - -/**************************************************************************** -RETURNS: -True if successfully initialised, false if not. - -REMARKS: -Loads and POST's the secondary controllers BIOS, directly from the BIOS -image we can extract over the PCI bus. -****************************************************************************/ -static ibool PCI_postControllers(void) -{ - int device; - ulong BIOSImageLen,mappedBIOSPhys; - uchar *mappedBIOS,*copyOfBIOS; - char filename[_MAX_PATH]; - FILE *f; - - /* Disable the primary display controller and AGP VGA pass-through */ - DISABLE_DEVICE(0); - if (AGPBridge) - DISABLE_AGP_VGA(); - - /* Now POST all the secondary controllers */ - for (device = 0; device < NumDevices; device++) { - /* Skip the device if it is not enabled (probably an ISA device) */ - if (DeviceIndex[device] == -1) - continue; - - /* Enable secondary display controller. If the secondary controller */ - /* is on the AGP bus, then enable VGA resources for the AGP device. */ - ENABLE_DEVICE(device); - if (AGPBridge && AGPBridge->SecondayBusNumber == PCI[DeviceIndex[device]].slot.p.Bus) - ENABLE_AGP_VGA(); - - /* Check if the controller has already been POST'ed */ - if (VGA_NOT_ACTIVE()) { - /* Find a viable place to map the secondary PCI BIOS image and map it */ - printk("Device %d not enabled, so attempting warm boot it\n", device); - - /* For AGP devices (and PCI devices that do have the ROM base */ - /* address zero'ed out) we have to map the BIOS to a location */ - /* that is passed by the AGP bridge to the bus. Some AGP devices */ - /* have the ROM base address already set up for us, and some */ - /* do not (we map to one of the existing BAR locations in */ - /* this case). */ - mappedBIOS = NULL; - if (PCI[DeviceIndex[device]].ROMBaseAddress != 0) - mappedBIOSPhys = PCI[DeviceIndex[device]].ROMBaseAddress & ~0xF; - else - mappedBIOSPhys = PCI_findBIOSAddr(device); - printk("Mapping BIOS image to 0x%08X\n", mappedBIOSPhys); - mappedBIOS = PM_mapPhysicalAddr(mappedBIOSPhys,MAX_BIOSLEN-1,false); - PCI_writePCIRegL(0x30,mappedBIOSPhys | 0x1,device); - BIOSImageLen = mappedBIOS[2] * 512; - if ((copyOfBIOS = malloc(BIOSImageLen)) == NULL) - return false; - memcpy(copyOfBIOS,mappedBIOS,BIOSImageLen); - PM_freePhysicalAddr(mappedBIOS,MAX_BIOSLEN-1); - - /* Allocate memory to store copy of BIOS from secondary controllers */ - VGAInfo[device].pciInfo = &PCI[DeviceIndex[device]]; - VGAInfo[device].BIOSImage = copyOfBIOS; - VGAInfo[device].BIOSImageLen = BIOSImageLen; - - /* Restore device mappings */ - PCI_writePCIRegL(0x30,PCI[DeviceIndex[device]].ROMBaseAddress,device); - PCI_writePCIRegL(0x10,PCI[DeviceIndex[device]].BaseAddress10,device); - PCI_writePCIRegL(0x14,PCI[DeviceIndex[device]].BaseAddress14,device); - - /* Now execute the BIOS POST for the device */ - if (copyOfBIOS[0] == 0x55 && copyOfBIOS[1] == 0xAA) { - printk("Executing BIOS POST for controller.\n"); - PCI_doBIOSPOST(device,mappedBIOSPhys,copyOfBIOS,BIOSImageLen); - } - - /* Reset the size of the BIOS image to the final size */ - VGAInfo[device].BIOSImageLen = FINAL_BIOSLEN; - - /* Save the BIOS and interrupt vector information to disk */ - sprintf(filename,"%s/bios.%02d",PM_getNucleusConfigPath(),device); - if ((f = fopen(filename,"wb")) != NULL) { - fwrite(copyOfBIOS,1,FINAL_BIOSLEN,f); - fwrite(VGAInfo[device].LowMem,1,sizeof(VGAInfo[device].LowMem),f); - fclose(f); - } - } - else { - /* Allocate memory to store copy of BIOS from secondary controllers */ - if ((copyOfBIOS = malloc(FINAL_BIOSLEN)) == NULL) - return false; - VGAInfo[device].pciInfo = &PCI[DeviceIndex[device]]; - VGAInfo[device].BIOSImage = copyOfBIOS; - VGAInfo[device].BIOSImageLen = FINAL_BIOSLEN; - - /* Load the BIOS and interrupt vector information from disk */ - sprintf(filename,"%s/bios.%02d",PM_getNucleusConfigPath(),device); - if ((f = fopen(filename,"rb")) != NULL) { - fread(copyOfBIOS,1,FINAL_BIOSLEN,f); - fread(VGAInfo[device].LowMem,1,sizeof(VGAInfo[device].LowMem),f); - fclose(f); - } - } - - /* Fix up all the secondary PCI base address registers */ - /* (restores them all from the values we read previously) */ - _PCI_fixupSecondaryBARs(); - - /* Disable the secondary controller and AGP VGA pass-through */ - DISABLE_DEVICE(device); - if (AGPBridge) - DISABLE_AGP_VGA(); - } - - /* Reenable primary display controller and reset AGP bridge control */ - if (AGPBridge) - RESTORE_AGP_VGA(); - ENABLE_DEVICE(0); - - /* Free physical BIOS image mapping */ - PM_freePhysicalAddr(mappedBIOS,MAX_BIOSLEN-1); - - /* Restore the X86 emulator BIOS info to primary controller */ - if (!useV86) - BE_setVGA(&VGAInfo[0]); - return true; -} - -/**************************************************************************** -REMARKS: -Enumerates the PCI bus and dumps the PCI configuration information to the -log file. -****************************************************************************/ -static void EnumeratePCI(void) -{ - int i,index; - PCIBridgeInfo *info; - - printk("Displaying enumeration of PCI bus (%d devices, %d display devices)\n", - NumPCI, NumDevices); - for (index = 0; index < NumDevices; index++) - printk(" Display device %d is PCI device %d\n",index,DeviceIndex[index]); - printk("\n"); - printk("Bus Slot Fnc DeviceID SubSystem Rev Class IRQ Int Cmd\n"); - for (i = 0; i < NumPCI; i++) { - printk("%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].SubSystemVendorID, - PCI[i].SubSystemID, - PCI[i].RevID, - PCI[i].BaseClass, - PCI[i].SubClass, - PCI[i].InterruptLine, - PCI[i].InterruptPin, - PCI[i].Command); - for (index = 0; index < NumDevices; index++) { - if (DeviceIndex[index] == i) - break; - } - if (index < NumDevices) - printk("<- %d\n", index); - else - printk("\n"); - } - printk("\n"); - printk("DeviceID Stat Ifc Cch Lat Hdr BIST\n"); - for (i = 0; i < NumPCI; i++) { - printk("%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) - printk("<- %d\n", index); - else - printk("\n"); - } - printk("\n"); - printk("DeviceID Base10h Base14h Base18h Base1Ch Base20h Base24h ROMBase\n"); - for (i = 0; i < NumPCI; i++) { - printk("%04X:%04X %08X %08X %08X %08X %08X %08X %08X ", - PCI[i].VendorID, - PCI[i].DeviceID, - PCI[i].BaseAddress10, - PCI[i].BaseAddress14, - PCI[i].BaseAddress18, - PCI[i].BaseAddress1C, - PCI[i].BaseAddress20, - PCI[i].BaseAddress24, - PCI[i].ROMBaseAddress); - for (index = 0; index < NumDevices; index++) { - if (DeviceIndex[index] == i) - break; - } - if (index < NumDevices) - printk("<- %d\n", index); - else - printk("\n"); - } - printk("\n"); - printk("DeviceID BAR10Len BAR14Len BAR18Len BAR1CLen BAR20Len BAR24Len ROMLen\n"); - for (i = 0; i < NumPCI; i++) { - printk("%04X:%04X %08X %08X %08X %08X %08X %08X %08X ", - PCI[i].VendorID, - PCI[i].DeviceID, - PCI[i].BaseAddress10Len, - PCI[i].BaseAddress14Len, - PCI[i].BaseAddress18Len, - PCI[i].BaseAddress1CLen, - PCI[i].BaseAddress20Len, - PCI[i].BaseAddress24Len, - PCI[i].ROMBaseAddressLen); - for (index = 0; index < NumDevices; index++) { - if (DeviceIndex[index] == i) - break; - } - if (index < NumDevices) - printk("<- %d\n", index); - else - printk("\n"); - } - printk("\n"); - printk("Displaying enumeration of %d bridge devices\n",NumBridges); - printk("\n"); - printk("DeviceID P# S# B# IOB IOL MemBase MemLimit PreBase PreLimit Ctrl\n"); - for (i = 0; i < NumBridges; i++) { - info = (PCIBridgeInfo*)&PCI[BridgeIndex[i]]; - printk("%04X:%04X %02X %02X %02X %04X %04X %08X %08X %08X %08X %04X\n", - info->VendorID, - info->DeviceID, - info->PrimaryBusNumber, - info->SecondayBusNumber, - info->SubordinateBusNumber, - ((u16)info->IOBase << 8) & 0xF000, - info->IOLimit ? - ((u16)info->IOLimit << 8) | 0xFFF : 0, - ((u32)info->MemoryBase << 16) & 0xFFF00000, - info->MemoryLimit ? - ((u32)info->MemoryLimit << 16) | 0xFFFFF : 0, - ((u32)info->PrefetchableMemoryBase << 16) & 0xFFF00000, - info->PrefetchableMemoryLimit ? - ((u32)info->PrefetchableMemoryLimit << 16) | 0xFFFFF : 0, - info->BridgeControl); - } - printk("\n"); -} - -/**************************************************************************** -RETURNS: -Number of display devices found. - -REMARKS: -This function enumerates the number of available display devices on the -PCI bus, and returns the number found. -****************************************************************************/ -static int PCI_enumerateDevices(void) -{ - int i,j; - PCIBridgeInfo *info; - - /* If this is the first time we have been called, enumerate all */ - /* devices on the PCI bus. */ - if (NumPCI == -1) { - for (i = 0; i < MAX_PCI_DEVICES; i++) - PCI[i].dwSize = sizeof(PCI[i]); - if ((NumPCI = PCI_enumerate(PCI,MAX_PCI_DEVICES)) == 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) { - if (NumBridges < MAX_PCI_DEVICES) - 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 { - if (NumDevices < MAX_PCI_DEVICES) - 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 = (PCIBridgeInfo*)&PCI[BridgeIndex[j]]; - if (info->SecondayBusNumber == PCI[i].slot.p.Bus) { - AGPBridge = info; - break; - } - } - } - } - } - - /* Enumerate all PCI and bridge devices to log file */ - EnumeratePCI(); - } - return NumDevices; -} - -FILE *logfile; - -void printk(const char *fmt, ...) -{ - va_list argptr; - va_start(argptr, fmt); - vfprintf(logfile, fmt, argptr); - fflush(logfile); - va_end(argptr); -} - -int main(int argc,char *argv[]) -{ - while (argc > 1) { - if (stricmp(argv[1],"-usev86") == 0) { - useV86 = true; - } - else if (stricmp(argv[1],"-force") == 0) { - forcePost = true; - } -#ifdef DEBUG - else if (stricmp(argv[1],"-decode") == 0) { - debugFlags |= DEBUG_DECODE_F; - } - else if (stricmp(argv[1],"-iotrace") == 0) { - debugFlags |= DEBUG_IO_TRACE_F; - } -#endif - else { - printf("Usage: warmboot [-usev86] [-force] [-decode] [-iotrace]\n"); - exit(-1); - } - argc--; - argv++; - } - if ((logfile = fopen("warmboot.log","w")) == NULL) - exit(1); - - PM_init(); - if (!useV86) { - /* Initialise the x86 BIOS emulator */ - BE_init(false,debugFlags,65536,&VGAInfo[0]); - } - - /* Enumerate all devices (which POST's them at the same time) */ - if (PCI_enumerateDevices() < 1) { - printk("No PCI display devices found!\n"); - return -1; - } - - /* Post all the display controller BIOS'es */ - PCI_postControllers(); - - /* Cleanup and exit the emulator */ - if (!useV86) - BE_exit(); - fclose(logfile); - return 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/common/_aa_imp.asm b/board/MAI/bios_emulator/scitech/src/common/_aa_imp.asm deleted file mode 100644 index 61a9024ab3..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/_aa_imp.asm +++ /dev/null @@ -1,51 +0,0 @@ -;**************************************************************************** -;* -;* SciTech Nucleus Audio Architecture -;* -;* Copyright (C) 1991-1998 SciTech Software, Inc. -;* All rights reserved. -;* -;* ====================================================================== -;* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -;* | | -;* |This copyrighted computer code contains proprietary technology | -;* |owned by SciTech Software, Inc., located at 505 Wall Street, | -;* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -;* | | -;* |The contents of this file are subject to the SciTech Nucleus | -;* |License; you may *not* use this file or related software except in | -;* |compliance with the License. You may obtain a copy of the License | -;* |at http://www.scitechsoft.com/nucleus-license.txt | -;* | | -;* |Software distributed under the License is distributed on an | -;* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -;* |implied. See the License for the specific language governing | -;* |rights and limitations under the License. | -;* | | -;* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -;* ====================================================================== -;* -;* Language: TASM 4.0 or NASM -;* Environment: IBM PC 32 bit Protected Mode. -;* -;* Description: Module to implement the import stubs for all the Nucleus -;* Audio API functions for Intel binary compatible drivers. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -BEGIN_IMPORTS_DEF _AA_exports -SKIP_IMP AA_status ; Implemented in C code -SKIP_IMP AA_errorMsg ; Implemented in C code -SKIP_IMP AA_getDaysLeft ; Implemented in C code -SKIP_IMP AA_registerLicense ; Implemented in C code -SKIP_IMP AA_enumerateDevices ; Implemented in C code -SKIP_IMP AA_loadDriver ; Implemented in C code -DECLARE_IMP AA_unloadDriver -DECLARE_IMP AA_saveOptions -END_IMPORTS_DEF - - END diff --git a/board/MAI/bios_emulator/scitech/src/common/_ga_imp.asm b/board/MAI/bios_emulator/scitech/src/common/_ga_imp.asm deleted file mode 100644 index 5317600438..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/_ga_imp.asm +++ /dev/null @@ -1,136 +0,0 @@ -;**************************************************************************** -;* -;* SciTech Nucleus Graphics Architecture -;* -;* Copyright (C) 1991-1998 SciTech Software, Inc. -;* All rights reserved. -;* -;* ====================================================================== -;* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -;* | | -;* |This copyrighted computer code contains proprietary technology | -;* |owned by SciTech Software, Inc., located at 505 Wall Street, | -;* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -;* | | -;* |The contents of this file are subject to the SciTech Nucleus | -;* |License; you may *not* use this file or related software except in | -;* |compliance with the License. You may obtain a copy of the License | -;* |at http://www.scitechsoft.com/nucleus-license.txt | -;* | | -;* |Software distributed under the License is distributed on an | -;* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -;* |implied. See the License for the specific language governing | -;* |rights and limitations under the License. | -;* | | -;* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -;* ====================================================================== -;* -;* Language: TASM 4.0 or NASM -;* Environment: IBM PC 32 bit Protected Mode. -;* -;* Description: Module to implement the import stubs for all the Nucleus -;* Graphics API functions for Intel binary compatible drivers. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -BEGIN_IMPORTS_DEF __GA_exports -SKIP_IMP GA_status,0 ; Implemented in C code -SKIP_IMP GA_errorMsg,1 ; Implemented in C code -SKIP_IMP GA_getDaysLeft,1 ; Implemented in C code -SKIP_IMP GA_registerLicense,2 ; Implemented in C code -SKIP_IMP GA_enumerateDevices,1 ; Implemented in C code -SKIP_IMP GA_loadDriver,2 ; Implemented in C code -DECLARE_IMP GA_setActiveDevice,1 -SKIP_IMP GA_reserved1,0 ; Implemented in C code -DECLARE_IMP GA_unloadDriver,1 -DECLARE_IMP REF2D_loadDriver,6 -DECLARE_IMP REF2D_unloadDriver,2 -DECLARE_IMP GA_loadRef2d,5 -DECLARE_IMP GA_unloadRef2d,1 -DECLARE_IMP GA_softStereoInit,1 -DECLARE_IMP GA_softStereoOn,0 -DECLARE_IMP GA_softStereoScheduleFlip,2 -DECLARE_IMP GA_softStereoGetFlipStatus,0 -DECLARE_IMP GA_softStereoWaitTillFlipped,0 -DECLARE_IMP GA_softStereoOff,0 -DECLARE_IMP GA_softStereoExit,0 -DECLARE_IMP GA_saveModeProfile,2 -DECLARE_IMP GA_saveOptions,2 -DECLARE_IMP GA_saveCRTCTimings,1 -DECLARE_IMP GA_restoreCRTCTimings,1 -DECLARE_IMP DDC_init,1 -DECLARE_IMP DDC_readEDID,5 -DECLARE_IMP EDID_parse,3 -DECLARE_IMP MCS_begin,1 -DECLARE_IMP MCS_getCapabilitiesString,2 -DECLARE_IMP MCS_isControlSupported,1 -DECLARE_IMP MCS_enableControl,2 -DECLARE_IMP MCS_getControlMax,2 -DECLARE_IMP MCS_getControlValue,2 -DECLARE_IMP MCS_getControlValues,3 -DECLARE_IMP MCS_setControlValue,2 -DECLARE_IMP MCS_setControlValues,3 -DECLARE_IMP MCS_resetControl,1 -DECLARE_IMP MCS_saveCurrentSettings,0 -DECLARE_IMP MCS_getTimingReport,3 -DECLARE_IMP MCS_getSelfTestReport,3 -DECLARE_IMP MCS_end,0 -SKIP_IMP GA_loadInGUI,1 ; Implemented in C code -DECLARE_IMP DDC_writeEDID,6 -DECLARE_IMP GA_useDoubleScan,1 -DECLARE_IMP GA_getMaxRefreshRate,4 -DECLARE_IMP GA_computeCRTCTimings,6 -DECLARE_IMP GA_addMode,5 -DECLARE_IMP GA_addRefresh,5 -DECLARE_IMP GA_delMode,5 -DECLARE_IMP N_getLogName,0 -SKIP_IMP2 N_log -DECLARE_IMP MDBX_getErrCode,0 -DECLARE_IMP MDBX_getErrorMsg,0 -DECLARE_IMP MDBX_open,1 -DECLARE_IMP MDBX_close,0 -DECLARE_IMP MDBX_first,1 -DECLARE_IMP MDBX_last,1 -DECLARE_IMP MDBX_next,1 -DECLARE_IMP MDBX_prev,1 -DECLARE_IMP MDBX_insert,1 -DECLARE_IMP MDBX_update,1 -DECLARE_IMP MDBX_flush,0 -DECLARE_IMP MDBX_importINF,2 -SKIP_IMP GA_getGlobalOptions,2 ; Implemented in C code -DECLARE_IMP GA_setGlobalOptions,1 -DECLARE_IMP GA_saveGlobalOptions,1 -DECLARE_IMP GA_getInternalName,1 -DECLARE_IMP GA_getNucleusConfigPath,0 -DECLARE_IMP GA_getFakePCIID,0 -SKIP_IMP GA_loadLibrary,3 ; Implemented in C code -SKIP_IMP GA_isOEMVersion,1 ; Implemented in C code -DECLARE_IMP GA_isLiteVersion,1 -DECLARE_IMP GA_getDisplaySerialNo,1 -DECLARE_IMP GA_getDisplayUserName,1 -SKIP_IMP GA_getCurrentDriver,1 ; Implemented in C code -SKIP_IMP GA_getCurrentRef2d,1 ; Implemented in C code -SKIP_IMP GA_getLicensedDevices,1 ; Implemented in C code -DECLARE_IMP DDC_initExt,2 -DECLARE_IMP MCS_beginExt,2 -DECLARE_IMP GA_loadRegionMgr,3 -DECLARE_IMP GA_unloadRegionMgr,1 -DECLARE_IMP GA_getProcAddress,2 -DECLARE_IMP GA_enableVBEMode,5 -DECLARE_IMP GA_disableVBEMode,5 -DECLARE_IMP GA_loadModeProfile,2 -DECLARE_IMP GA_getCRTCTimings,4 -DECLARE_IMP GA_setCRTCTimings,4 -DECLARE_IMP GA_setDefaultRefresh,6 -DECLARE_IMP GA_saveMonitorInfo,2 -DECLARE_IMP GA_detectPnPMonitor,3 -SKIP_IMP3 GA_queryFunctions -SKIP_IMP3 REF2D_queryFunctions -END_IMPORTS_DEF - - END - diff --git a/board/MAI/bios_emulator/scitech/src/common/_gatimer.asm b/board/MAI/bios_emulator/scitech/src/common/_gatimer.asm deleted file mode 100644 index 0194a62f98..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/_gatimer.asm +++ /dev/null @@ -1,248 +0,0 @@ -;**************************************************************************** -;* -;* SciTech Nucleus Graphics Architecture -;* -;* Copyright (C) 1991-1998 SciTech Software, Inc. -;* All rights reserved. -;* -;* ====================================================================== -;* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -;* | | -;* |This copyrighted computer code contains proprietary technology | -;* |owned by SciTech Software, Inc., located at 505 Wall Street, | -;* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -;* | | -;* |The contents of this file are subject to the SciTech Nucleus | -;* |License; you may *not* use this file or related software except in | -;* |compliance with the License. You may obtain a copy of the License | -;* |at http://www.scitechsoft.com/nucleus-license.txt | -;* | | -;* |Software distributed under the License is distributed on an | -;* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -;* |implied. See the License for the specific language governing | -;* |rights and limitations under the License. | -;* | | -;* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -;* ====================================================================== -;* -;* Language: 80386 Assembler, NASM or TASM -;* Environment: IBM PC 32 bit Protected Mode. -;* -;* Description: Assembly support functions for the Nucleus library for -;* the high resolution timing support functions provided by -;* the Intel Pentium and compatible processors. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -header _gatimer - -begcodeseg _gatimer - -ifdef USE_NASM -%macro mCPU_ID 0 -db 00Fh,0A2h -%endmacro -else -MACRO mCPU_ID -db 00Fh,0A2h -ENDM -endif - -ifdef USE_NASM -%macro mRDTSC 0 -db 00Fh,031h -%endmacro -else -MACRO mRDTSC -db 00Fh,031h -ENDM -endif - -;---------------------------------------------------------------------------- -; bool _GA_haveCPUID(void) -;---------------------------------------------------------------------------- -; Determines if we have support for the CPUID instruction. -;---------------------------------------------------------------------------- -cprocstart _GA_haveCPUID - - enter_c - pushfd ; Get original EFLAGS - pop eax - mov ecx, eax - xor eax, 200000h ; Flip ID bit in EFLAGS - push eax ; Save new EFLAGS value on stack - popfd ; Replace current EFLAGS value - pushfd ; Get new EFLAGS - pop eax ; Store new EFLAGS in EAX - xor eax, ecx ; Can not toggle ID bit, - jnz @@1 ; Processor=80486 - mov eax,0 ; We dont have CPUID support - jmp @@Done -@@1: mov eax,1 ; We have CPUID support -@@Done: leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; uint _GA_getCPUIDFeatures(void) -;---------------------------------------------------------------------------- -; Determines the CPU type using the CPUID instruction. -;---------------------------------------------------------------------------- -cprocstart _GA_getCPUIDFeatures - - enter_c - - xor eax, eax ; Set up for CPUID instruction - mCPU_ID ; Get and save vendor ID - cmp eax, 1 ; Make sure 1 is valid input for CPUID - jl @@Fail ; We dont have the CPUID instruction - xor eax, eax - inc eax - mCPU_ID ; Get family/model/stepping/features - mov eax, edx -@@Done: leave_c - ret - -@@Fail: xor eax,eax - jmp @@Done - -cprocend - -;---------------------------------------------------------------------------- -; void _GA_readTimeStamp(GA_largeInteger *time) -;---------------------------------------------------------------------------- -; Reads the time stamp counter and returns the 64-bit result. -;---------------------------------------------------------------------------- -cprocstart _GA_readTimeStamp - - mRDTSC - mov ecx,[esp+4] ; Access directly without stack frame - mov [ecx],eax - mov [ecx+4],edx - ret - -cprocend - -;---------------------------------------------------------------------------- -; N_uint32 GA_TimerDifference(GA_largeInteger *a,GA_largeInteger *b) -;---------------------------------------------------------------------------- -; Computes the difference between two 64-bit numbers (a-b) -;---------------------------------------------------------------------------- -cprocstart GA_TimerDifference - - ARG a:DPTR, b:DPTR, t:DPTR - - enter_c - - mov ecx,[a] - mov eax,[ecx] ; EAX := b.low - mov ecx,[b] - sub eax,[ecx] - mov edx,eax ; EDX := low difference - mov ecx,[a] - mov eax,[ecx+4] ; ECX := b.high - mov ecx,[b] - sbb eax,[ecx+4] ; EAX := high difference - mov eax,edx ; Return low part - - leave_c - ret - -cprocend - -; Macro to delay briefly to ensure that enough time has elapsed between -; successive I/O accesses so that the device being accessed can respond -; to both accesses even on a very fast PC. - -ifdef USE_NASM -%macro DELAY_TIMER 0 - jmp short $+2 - jmp short $+2 - jmp short $+2 -%endmacro -else -macro DELAY_TIMER - jmp short $+2 - jmp short $+2 - jmp short $+2 -endm -endif - -;---------------------------------------------------------------------------- -; void _OS_delay8253(N_uint32 microSeconds); -;---------------------------------------------------------------------------- -; Delays for the specified number of microseconds, by directly programming -; the 8253 timer chips. -;---------------------------------------------------------------------------- -cprocstart _OS_delay8253 - - ARG microSec:UINT - - enter_c - -; Start timer 2 counting - - mov _ax,[microSec] ; EAX := count in microseconds - mov ecx,1196 - mul ecx - mov ecx,1000 - div ecx - mov ecx,eax ; ECX := count in timer ticks - in al,61h - or al,1 - out 61h,al - -; Set the timer 2 count to 0 again to start the timing interval. - - mov al,10110100b ; set up to load initial (timer 2) - out 43h,al ; timer count - DELAY_TIMER - sub al,al - out 42h,al ; load count lsb - DELAY_TIMER - out 42h,al ; load count msb - xor di,di ; Allow max 64K loop iterations - -@@LoopStart: - dec di ; This is a guard against the possibility that - jz @@LoopEnd ; someone eg. stopped the timer behind our back. - ; After 64K iterations we bail out no matter what - ; (and hope it wasn't too soon) - mov al,00000000b ; latch timer 0 - out 43h,al - DELAY_TIMER - in al,42h ; least significant byte - DELAY_TIMER - mov ah,al - in al,42h ; most significant byte - xchg ah,al - neg ax ; Convert from countdown remaining - ; to elapsed count - cmp ax,cx ; Has delay expired? - jb @@LoopStart ; No, so loop till done - -; Stop timer 2 from counting -@@LoopEnd: - in al,61H - and al,0FEh - out 61H,al - -; Some programs have a problem if we change the control port; better change it -; to something they expect (mode 3 - square wave generator)... - mov al,0B6h - out 43h,al - - leave_c - ret - -cprocend - -endcodeseg _gatimer - - END - diff --git a/board/MAI/bios_emulator/scitech/src/common/_pm_imp.asm b/board/MAI/bios_emulator/scitech/src/common/_pm_imp.asm deleted file mode 100644 index d4b11790af..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/_pm_imp.asm +++ /dev/null @@ -1,195 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* Copyright (C) 1991-1998 SciTech Software, Inc. -;* All rights reserved. -;* -;* ====================================================================== -;* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -;* | | -;* |This copyrighted computer code contains proprietary technology | -;* |owned by SciTech Software, Inc., located at 505 Wall Street, | -;* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -;* | | -;* |The contents of this file are subject to the SciTech Nucleus | -;* |License; you may *not* use this file or related software except in | -;* |compliance with the License. You may obtain a copy of the License | -;* |at http://www.scitechsoft.com/nucleus-license.txt | -;* | | -;* |Software distributed under the License is distributed on an | -;* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -;* |implied. See the License for the specific language governing | -;* |rights and limitations under the License. | -;* | | -;* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -;* ====================================================================== -;* -;* Language: TASM 4.0 or NASM -;* Environment: IBM PC 32 bit Protected Mode. -;* -;* Description: Module to implement the import stubs for all the PM -;* API functions for Intel binary portable drivers. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -BEGIN_IMPORTS_DEF _PM_imports -DECLARE_IMP PM_getModeType,0 -DECLARE_IMP PM_getBIOSPointer,0 -DECLARE_IMP PM_getA0000Pointer,0 -DECLARE_IMP PM_mapPhysicalAddr,0 -DECLARE_IMP PM_mallocShared,0 -SKIP_IMP _PM_reserved1,0 -DECLARE_IMP PM_freeShared,0 -DECLARE_IMP PM_mapToProcess,0 -DECLARE_IMP PM_mapRealPointer,0 -DECLARE_IMP PM_allocRealSeg,0 -DECLARE_IMP PM_freeRealSeg,0 -DECLARE_IMP PM_allocLockedMem,0 -DECLARE_IMP PM_freeLockedMem,0 -DECLARE_IMP PM_callRealMode,0 -DECLARE_IMP PM_int86,0 -DECLARE_IMP PM_int86x,0 -DECLARE_IMP DPMI_int86,0 -DECLARE_IMP PM_availableMemory,0 -DECLARE_IMP PM_getVESABuf,0 -DECLARE_IMP PM_getOSType,0 -DECLARE_IMP PM_fatalError,0 -DECLARE_IMP PM_setBankA,0 -DECLARE_IMP PM_setBankAB,0 -DECLARE_IMP PM_setCRTStart,0 -DECLARE_IMP PM_getCurrentPat,0 -DECLARE_IMP PM_getVBEAFPath,0 -DECLARE_IMP PM_getNucleusPath,0 -DECLARE_IMP PM_getNucleusConfigPath,0 -DECLARE_IMP PM_getUniqueID,0 -DECLARE_IMP PM_getMachineName,0 -DECLARE_IMP VF_available,0 -DECLARE_IMP VF_init,0 -DECLARE_IMP VF_exit,0 -DECLARE_IMP PM_openConsole,0 -DECLARE_IMP PM_getConsoleStateSize,0 -DECLARE_IMP PM_saveConsoleState,0 -DECLARE_IMP PM_restoreConsoleState,0 -DECLARE_IMP PM_closeConsole,0 -DECLARE_IMP PM_setOSCursorLocation,0 -DECLARE_IMP PM_setOSScreenWidth,0 -DECLARE_IMP PM_enableWriteCombine,0 -DECLARE_IMP PM_backslash,0 -DECLARE_IMP PM_lockDataPages,0 -DECLARE_IMP PM_unlockDataPages,0 -DECLARE_IMP PM_lockCodePages,0 -DECLARE_IMP PM_unlockCodePages,0 -DECLARE_IMP PM_setRealTimeClockHandler,0 -DECLARE_IMP PM_setRealTimeClockFrequency,0 -DECLARE_IMP PM_restoreRealTimeClockHandler,0 -DECLARE_IMP PM_doBIOSPOST,0 -DECLARE_IMP PM_getBootDrive,0 -DECLARE_IMP PM_freePhysicalAddr,0 -DECLARE_IMP PM_inpb,0 -DECLARE_IMP PM_inpw,0 -DECLARE_IMP PM_inpd,0 -DECLARE_IMP PM_outpb,0 -DECLARE_IMP PM_outpw,0 -DECLARE_IMP PM_outpd,0 -SKIP_IMP _PM_reserved2,0 -DECLARE_IMP PM_setSuspendAppCallback,0 -DECLARE_IMP PM_haveBIOSAccess,0 -DECLARE_IMP PM_kbhit,0 -DECLARE_IMP PM_getch,0 -DECLARE_IMP PM_findBPD,0 -DECLARE_IMP PM_getPhysicalAddr,0 -DECLARE_IMP PM_sleep,0 -DECLARE_IMP PM_getCOMPort,0 -DECLARE_IMP PM_getLPTPort,0 -DECLARE_IMP PM_loadLibrary,0 -DECLARE_IMP PM_getProcAddress,0 -DECLARE_IMP PM_freeLibrary,0 -DECLARE_IMP PCI_enumerate,0 -DECLARE_IMP PCI_accessReg,0 -DECLARE_IMP PCI_setHardwareIRQ,0 -DECLARE_IMP PCI_generateSpecialCyle,0 -SKIP_IMP _PM_reserved3,0 -DECLARE_IMP PCIBIOS_getEntry,0 -DECLARE_IMP CPU_getProcessorType,0 -DECLARE_IMP CPU_haveMMX,0 -DECLARE_IMP CPU_have3DNow,0 -DECLARE_IMP CPU_haveSSE,0 -DECLARE_IMP CPU_haveRDTSC,0 -DECLARE_IMP CPU_getProcessorSpeed,0 -DECLARE_IMP ZTimerInit,0 -DECLARE_IMP LZTimerOn,0 -DECLARE_IMP LZTimerLap,0 -DECLARE_IMP LZTimerOff,0 -DECLARE_IMP LZTimerCount,0 -DECLARE_IMP LZTimerOnExt,0 -DECLARE_IMP LZTimerLapExt,0 -DECLARE_IMP LZTimerOffExt,0 -DECLARE_IMP LZTimerCountExt,0 -DECLARE_IMP ULZTimerOn,0 -DECLARE_IMP ULZTimerLap,0 -DECLARE_IMP ULZTimerOff,0 -DECLARE_IMP ULZTimerCount,0 -DECLARE_IMP ULZReadTime,0 -DECLARE_IMP ULZElapsedTime,0 -DECLARE_IMP ULZTimerResolution,0 -DECLARE_IMP PM_findFirstFile,0 -DECLARE_IMP PM_findNextFile,0 -DECLARE_IMP PM_findClose,0 -DECLARE_IMP PM_makepath,0 -DECLARE_IMP PM_splitpath,0 -DECLARE_IMP PM_driveValid,0 -DECLARE_IMP PM_getdcwd,0 -DECLARE_IMP PM_setFileAttr,0 -DECLARE_IMP PM_mkdir,0 -DECLARE_IMP PM_rmdir,0 -DECLARE_IMP PM_getFileAttr,0 -DECLARE_IMP PM_getFileTime,0 -DECLARE_IMP PM_setFileTime,0 -DECLARE_IMP CPU_getProcessorName,0 -DECLARE_IMP PM_getVGAStateSize,0 -DECLARE_IMP PM_saveVGAState,0 -DECLARE_IMP PM_restoreVGAState,0 -DECLARE_IMP PM_vgaBlankDisplay,0 -DECLARE_IMP PM_vgaUnblankDisplay,0 -DECLARE_IMP PM_blockUntilTimeout,0 -DECLARE_IMP _PM_add64,0 -DECLARE_IMP _PM_sub64,0 -DECLARE_IMP _PM_mul64,0 -DECLARE_IMP _PM_div64,0 -DECLARE_IMP _PM_shr64,0 -DECLARE_IMP _PM_sar64,0 -DECLARE_IMP _PM_shl64,0 -DECLARE_IMP _PM_neg64,0 -DECLARE_IMP PCI_findBARSize,0 -DECLARE_IMP PCI_readRegBlock,0 -DECLARE_IMP PCI_writeRegBlock,0 -DECLARE_IMP PM_flushTLB,0 -DECLARE_IMP PM_useLocalMalloc,0 -DECLARE_IMP PM_malloc,0 -DECLARE_IMP PM_calloc,0 -DECLARE_IMP PM_realloc,0 -DECLARE_IMP PM_free,0 -DECLARE_IMP PM_getPhysicalAddrRange,0 -DECLARE_IMP PM_allocPage,0 -DECLARE_IMP PM_freePage,0 -DECLARE_IMP PM_agpInit,0 -DECLARE_IMP PM_agpExit,0 -DECLARE_IMP PM_agpReservePhysical,0 -DECLARE_IMP PM_agpReleasePhysical,0 -DECLARE_IMP PM_agpCommitPhysical,0 -DECLARE_IMP PM_agpFreePhysical,0 -DECLARE_IMP PCI_getNumDevices,0 -DECLARE_IMP PM_setLocalBPDPath,0 -DECLARE_IMP PM_loadDirectDraw,0 -DECLARE_IMP PM_unloadDirectDraw,0 -DECLARE_IMP PM_getDirectDrawWindow,0 -DECLARE_IMP PM_doSuspendApp,0 -END_IMPORTS_DEF - - END - diff --git a/board/MAI/bios_emulator/scitech/src/common/aabeos.c b/board/MAI/bios_emulator/scitech/src/common/aabeos.c deleted file mode 100644 index ad5698a406..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/aabeos.c +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: Linux -* -* Description: OS specific Nucleus Graphics Architecture services for -* the Linux operating system. -* -****************************************************************************/ - -#include "nucleus/graphics.h" -#include - -static ibool haveRDTSC; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -GA_sharedInfo * NAPI GA_getSharedInfo( - int device) -{ - (void)device; - return NULL; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp) -{ - (void)gaExp; - return false; -} - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) - haveRDTSC = true; - return true; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - if (haveRDTSC) - _GA_readTimeStamp(value); - else { - struct timeval t; - gettimeofday(&t, NULL); - value->low = t.tv_sec*1000000 + t.tv_usec; - value->high = 0; - } -} diff --git a/board/MAI/bios_emulator/scitech/src/common/aados.c b/board/MAI/bios_emulator/scitech/src/common/aados.c deleted file mode 100644 index 342d2f33a4..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/aados.c +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: MSDOS -* -* Description: OS specific Nucleus Graphics Architecture services for -* the MSDOS operating system. -* -****************************************************************************/ - -#include "pm_help.h" -#include "pmapi.h" -#include -#include -#include - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the DOS -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) - return true; - return false; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - _GA_readTimeStamp(value); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/aalib.c b/board/MAI/bios_emulator/scitech/src/common/aalib.c deleted file mode 100644 index 5003b22291..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/aalib.c +++ /dev/null @@ -1,225 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Audio Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: Any 32-bit protected mode environment -* -* Description: C module for the Graphics Accelerator Driver API. Uses -* the SciTech PM library for interfacing with DOS -* extender specific functions. -* -****************************************************************************/ - -#include "nucleus/audio.h" -#ifdef __WIN32_VXD__ -#include "sdd/sddhelp.h" -#else -#include -#include -#endif - -/*---------------------------- Global Variables ---------------------------*/ - -#ifdef TEST_HARNESS -extern PM_imports _VARAPI _PM_imports; -#else -AA_exports _VARAPI _AA_exports; -static int loaded = false; -static PE_MODULE *hModBPD = NULL; - -#ifdef __DRIVER__ -extern PM_imports _PM_imports; -#else -#include "pmimp.h" -#endif - -static N_imports _N_imports = { - sizeof(N_imports), - _OS_delay, - }; - -#ifdef __DRIVER__ -extern AA_imports _AA_imports; -#else -static AA_imports _AA_imports = { - sizeof(AA_imports), - }; -#endif -#endif - -/*----------------------------- Implementation ----------------------------*/ - -#define DLL_NAME "audio.bpd" - -#ifndef TEST_HARNESS -/**************************************************************************** -REMARKS: -Fatal error handler for non-exported AA_exports. -****************************************************************************/ -static void _AA_fatalErrorHandler(void) -{ - PM_fatalError("Unsupported Nucleus export function called! Please upgrade your copy of Nucleus!\n"); -} - -/**************************************************************************** -REMARKS: -Loads the Nucleus binary portable DLL into memory and initilises it. -****************************************************************************/ -static ibool LoadDriver(void) -{ - AA_initLibrary_t AA_initLibrary; - AA_exports *aaExp; - char filename[PM_MAX_PATH]; - char bpdpath[PM_MAX_PATH]; - int i,max; - ulong *p; - - /* Check if we have already loaded the driver */ - if (loaded) - return true; - PM_init(); - _AA_exports.dwSize = sizeof(_AA_exports); - - /* Open the BPD file */ - if (!PM_findBPD(DLL_NAME,bpdpath)) - return false; - strcpy(filename,bpdpath); - strcat(filename,DLL_NAME); - if ((hModBPD = PE_loadLibrary(filename,false)) == NULL) - return false; - if ((AA_initLibrary = (AA_initLibrary_t)PE_getProcAddress(hModBPD,"_AA_initLibrary")) == NULL) - return false; - bpdpath[strlen(bpdpath)-1] = 0; - if (strcmp(bpdpath,PM_getNucleusPath()) == 0) - strcpy(bpdpath,PM_getNucleusConfigPath()); - else { - PM_backslash(bpdpath); - strcat(bpdpath,"config"); - } - if ((aaExp = AA_initLibrary(bpdpath,filename,&_PM_imports,&_N_imports,&_AA_imports)) == NULL) - PM_fatalError("AA_initLibrary failed!\n"); - - /* Initialize all default imports to point to fatal error handler - * for upwards compatibility, and copy the exported functions. - */ - max = sizeof(_AA_exports)/sizeof(AA_initLibrary_t); - for (i = 0,p = (ulong*)&_AA_exports; i < max; i++) - *p++ = (ulong)_AA_fatalErrorHandler; - memcpy(&_AA_exports,aaExp,MIN(sizeof(_AA_exports),aaExp->dwSize)); - loaded = true; - return true; -} - -/* The following are stub entry points that the application calls to - * initialise the Nucleus loader library, and we use this to load our - * driver DLL from disk and initialise the library using it. - */ - -/* {secret} */ -int NAPI AA_status(void) -{ - if (!loaded) - return nDriverNotFound; - return _AA_exports.AA_status(); -} - -/* {secret} */ -const char * NAPI AA_errorMsg( - N_int32 status) -{ - if (!loaded) - return "Unable to load Nucleus device driver!"; - return _AA_exports.AA_errorMsg(status); -} - -/* {secret} */ -int NAPI AA_getDaysLeft(void) -{ - if (!LoadDriver()) - return -1; - return _AA_exports.AA_getDaysLeft(); -} - -/* {secret} */ -int NAPI AA_registerLicense(uchar *license) -{ - if (!LoadDriver()) - return 0; - return _AA_exports.AA_registerLicense(license); -} - -/* {secret} */ -int NAPI AA_enumerateDevices(void) -{ - if (!LoadDriver()) - return 0; - return _AA_exports.AA_enumerateDevices(); -} - -/* {secret} */ -AA_devCtx * NAPI AA_loadDriver(N_int32 deviceIndex) -{ - if (!LoadDriver()) - return NULL; - return _AA_exports.AA_loadDriver(deviceIndex); -} -#endif - -typedef struct { - N_uint32 low; - N_uint32 high; - } AA_largeInteger; - -void NAPI _OS_delay8253(N_uint32 microSeconds); -ibool NAPI _GA_haveCPUID(void); -uint NAPI _GA_getCPUIDFeatures(void); -void NAPI _GA_readTimeStamp(AA_largeInteger *time); -#define CPU_HaveRDTSC 0x00000010 - -/**************************************************************************** -REMARKS: -This function delays for the specified number of microseconds -****************************************************************************/ -void NAPI _OS_delay( - N_uint32 microSeconds) -{ - static ibool inited = false; - LZTimerObject tm; - - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) { - if (!inited) { - ZTimerInit(); - inited = true; - } - LZTimerOnExt(&tm); - while (LZTimerLapExt(&tm) < microSeconds) - ; - LZTimerOnExt(&tm); - } - else - _OS_delay8253(microSeconds); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/aalinux.c b/board/MAI/bios_emulator/scitech/src/common/aalinux.c deleted file mode 100644 index d3d468ed0f..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/aalinux.c +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: Linux -* -* Description: OS specific Nucleus Graphics Architecture services for -* the Linux operating system. -* -****************************************************************************/ - -#include "nucleus/graphics.h" -#include - -/*---------------------------- Global Variables ---------------------------*/ - -static ibool haveRDTSC; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -GA_sharedInfo * NAPI GA_getSharedInfo( - int device) -{ - (void)device; - return NULL; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp) -{ - (void)gaExp; - return false; -} - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) - haveRDTSC = true; - return true; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - if (haveRDTSC) - _GA_readTimeStamp(value); - else { - struct timeval t; - gettimeofday(&t, NULL); - value->low = t.tv_sec*1000000 + t.tv_usec; - value->high = 0; - } -} diff --git a/board/MAI/bios_emulator/scitech/src/common/aaos2.c b/board/MAI/bios_emulator/scitech/src/common/aaos2.c deleted file mode 100644 index 0ec8c9fcf1..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/aaos2.c +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: OS/2 32-bit -* -* Description: OS specific Nucleus Graphics Architecture services for -* the OS/2 operating system environments. -* -****************************************************************************/ - -#include "pm_help.h" -#define INCL_DOSERRORS -#define INCL_DOS -#define INCL_SUB -#define INCL_VIO -#define INCL_KBD -#include - -/*---------------------------- Global Variables ---------------------------*/ - -static HFILE hSDDHelp; -static ulong outLen; /* Must not cross 64Kb boundary! */ -static ulong result; /* Must not cross 64Kb boundary! */ -static ibool haveRDTSC; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -REMARKS: -This function returns a pointer to the common graphics driver loaded in the -helper VxD. The memory for the VxD is shared between all processes via -the VxD, so that the VxD, 16-bit code and 32-bit code all see the same -state when accessing the graphics binary portable driver. -****************************************************************************/ -GA_sharedInfo * NAPI GA_getSharedInfo( - int device) -{ - /* Initialise the PM library and connect to our runtime DLL's */ - PM_init(); - - /* Open our helper device driver */ - if (DosOpen(PMHELP_NAME,&hSDDHelp,&result,0,0, - FILE_OPEN, OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE, - NULL)) - PM_fatalError("Unable to open SDDHELP$ helper device driver!"); - outLen = sizeof(result); - DosDevIOCtl(hSDDHelp,PMHELP_IOCTL,PMHELP_GETSHAREDINFO, - NULL, 0, NULL, - &result, outLen, &outLen); - DosClose(hSDDHelp); - if (result) { - /* We have found the shared Nucleus packet. Because not all processes - * map to SDDPMI.DLL, we need to ensure that we connect to this - * DLL so that it gets mapped into our address space (that is - * where the shared Nucleus packet is located). Simply doing a - * DosLoadModule on it is enough for this. - */ - HMODULE hModSDDPMI; - char buf[80]; - DosLoadModule((PSZ)buf,sizeof(buf),(PSZ)"SDDPMI.DLL",&hModSDDPMI); - } - return (GA_sharedInfo*)result; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp) -{ - (void)gaExp; - return false; -} - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) - haveRDTSC = true; - return true; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - if (haveRDTSC) - _GA_readTimeStamp(value); - else - DosTmrQueryTime((QWORD*)value); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/aaqnx.c b/board/MAI/bios_emulator/scitech/src/common/aaqnx.c deleted file mode 100644 index 13531be99f..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/aaqnx.c +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: QNX -* -* Description: OS specific Nucleus Graphics Architecture services for -* the QNX operating system. -* -****************************************************************************/ - -#include "nucleus/graphics.h" -#include - -/*---------------------------- Global Variables ---------------------------*/ - -static ibool haveRDTSC; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -GA_sharedInfo * NAPI GA_getSharedInfo( - int device) -{ - (void)device; - return NULL; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp) -{ - (void)gaExp; - return false; -} - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) - haveRDTSC = true; - return true; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - if (haveRDTSC) - _GA_readTimeStamp(value); - else { - struct timespec ts; - - clock_gettime(CLOCK_REALTIME, &ts); - value->low = (ts.tv_nsec / 1000 + ts.tv_sec * 1000000); - value->high = 0; - } -} diff --git a/board/MAI/bios_emulator/scitech/src/common/aartt.c b/board/MAI/bios_emulator/scitech/src/common/aartt.c deleted file mode 100644 index 1a5a67a4e9..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/aartt.c +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: RTTarget-32 -* -* Description: OS specific Nucleus Graphics Architecture services for -* the RTTarget-32 operating system environments. -* -****************************************************************************/ - -#include "nucleus/graphics.h" - -/*------------------------- Global Variables ------------------------------*/ - -static ibool haveRDTSC; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -GA_sharedInfo * NAPI GA_getSharedInfo( - int device) -{ - (void)device; - return NULL; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp) -{ - (void)gaExp; - return false; -} - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) { - haveRDTSC = true; - return true; - } - return false; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - if (haveRDTSC) - _GA_readTimeStamp(value); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/aasmx.c b/board/MAI/bios_emulator/scitech/src/common/aasmx.c deleted file mode 100644 index 163060f717..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/aasmx.c +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: smx32 -* -* Description: OS specific Nucleus Graphics Architecture services for -* the smx32 platform -- no vxD support. -* -****************************************************************************/ - -#include "pmapi.h" -#include "nucleus/graphics.h" - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -GA_sharedInfo * NAPI GA_getSharedInfo( - int device) -{ - (void)device; - return NULL; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp) -{ - (void)gaExp; - return false; -} - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) - return true; - return false; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - _GA_readTimeStamp(value); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/aavxd.c b/board/MAI/bios_emulator/scitech/src/common/aavxd.c deleted file mode 100644 index 221b02bd9b..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/aavxd.c +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: Win32 VxD -* -* Description: OS specific Nucleus Graphics Architecture services for -* the Win32 VxD's. -* -****************************************************************************/ - -#include "sdd/sddhelp.h" - -/*------------------------- Global Variables ------------------------------*/ - -static ibool haveRDTSC; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -REMARKS: -Return the internal shared info structure. -****************************************************************************/ -GA_sharedInfo * NAPI GA_getSharedInfo( - int device) -{ - static GA_sharedInfo shared = {0,-1}; - return &shared; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp) -{ - (void)gaExp; - return false; -} - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) { - haveRDTSC = true; - } - return true; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - if (haveRDTSC) - _GA_readTimeStamp(value); - else - VTD_Get_Real_Time(&value->high,&value->low); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/aawin32.c b/board/MAI/bios_emulator/scitech/src/common/aawin32.c deleted file mode 100644 index 541df4ac58..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/aawin32.c +++ /dev/null @@ -1,264 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: Win32 -* -* Description: OS specific Nucleus Graphics Architecture services for -* the Win32 operating system environments. -* -****************************************************************************/ - -#include "pm_help.h" -#include "pmapi.h" -#include -#include -#include -#define STRICT -#define WIN32_LEAN_AND_MEAN -#include - -/*------------------------- Global Variables ------------------------------*/ - -#if GA_MAX_DEVICES > 4 -#error GA_MAX_DEVICES has changed! -#endif - -static ibool haveRDTSC; -static GA_largeInteger countFreq; -static GA_loadDriver_t ORG_GA_loadDriver; -extern HANDLE _PM_hDevice; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -DESCRIPTION: -Get the current graphics driver imports from the VxD - -REMARKS: -This function returns a pointer to the common graphics driver loaded in the -helper VxD. The memory for the VxD is shared between all processes via -the VxD, so that the VxD, 16-bit code and 32-bit code all see the same -state when accessing the graphics binary portable driver. -****************************************************************************/ -GA_sharedInfo * NAPI GA_getSharedInfo( - int device) -{ - DWORD inBuf[1]; /* Buffer to send data to VxD */ - DWORD outBuf[2]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - PM_init(); - inBuf[0] = device; - if (DeviceIoControl(_PM_hDevice, PMHELP_GETSHAREDINFO32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) { - return (GA_sharedInfo*)outBuf[0]; - } - return NULL; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp) -{ - (void)gaExp; - return false; -} - -/**************************************************************************** -REMARKS: -This function initialises the software stereo module by either calling -the Nucleus libraries directly, or calling into the VxD if we are running -on the shared Nucleus libraries loaded by the Windows VxD. -****************************************************************************/ -static ibool NAPI _GA_softStereoInit( - GA_devCtx *dc) -{ - if (_PM_hDevice) { - DWORD inBuf[1]; /* Buffer to send data to VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - inBuf[0] = (ulong)dc; - if (DeviceIoControl(_PM_hDevice, PMHELP_GASTEREOINIT32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) { - return outBuf[0]; - } - } - return false; -} - -/**************************************************************************** -REMARKS: -This function turns on software stereo mode, either directly or via the VxD. -****************************************************************************/ -static void NAPI _GA_softStereoOn(void) -{ - if (_PM_hDevice) { - DeviceIoControl(_PM_hDevice, PMHELP_GASTEREOON32, NULL, 0, - NULL, 0, NULL, NULL); - } -} - -/**************************************************************************** -REMARKS: -This function schedules a software stereo mode page flip, either directly -or via the VxD. -****************************************************************************/ -static void NAPI _GA_softStereoScheduleFlip( - N_uint32 leftAddr, - N_uint32 rightAddr) -{ - if (_PM_hDevice) { - DWORD inBuf[2]; /* Buffer to send data to VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - inBuf[0] = (ulong)leftAddr; - inBuf[1] = (ulong)rightAddr; - DeviceIoControl(_PM_hDevice, PMHELP_GASTEREOFLIP32, inBuf, sizeof(inBuf), - NULL, 0, &count, NULL); - } -} - -/**************************************************************************** -REMARKS: -This function turns off software stereo mode, either directly or via the VxD. -****************************************************************************/ -static N_int32 NAPI _GA_softStereoGetFlipStatus(void) -{ - if (_PM_hDevice) { - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - if (DeviceIoControl(_PM_hDevice, PMHELP_GASTEREOFLIPSTATUS32, NULL, 0, - outBuf, sizeof(outBuf), &count, NULL)) { - return outBuf[0]; - } - } - return 0; -} - -/**************************************************************************** -REMARKS: -This function turns off software stereo mode, either directly or via the VxD. -****************************************************************************/ -static void NAPI _GA_softStereoWaitTillFlipped(void) -{ - while (!_GA_softStereoGetFlipStatus()) - ; -} - -/**************************************************************************** -REMARKS: -This function turns off software stereo mode, either directly or via the VxD. -****************************************************************************/ -static void NAPI _GA_softStereoOff(void) -{ - if (_PM_hDevice) { - DeviceIoControl(_PM_hDevice, PMHELP_GASTEREOOFF32, NULL, 0, - NULL, 0, NULL, NULL); - } -} - -/**************************************************************************** -REMARKS: -This function disable the software stereo handler, either directly or via -the VxD. -****************************************************************************/ -static void NAPI _GA_softStereoExit(void) -{ - if (_PM_hDevice) { - DeviceIoControl(_PM_hDevice, PMHELP_GASTEREOEXIT32, NULL, 0, - NULL, 0, NULL, NULL); - } -} - -/**************************************************************************** -REMARKS: -We hook this function in here so that we can avoid the memory detect and -other destructive sequences in the drivers if we are loading the driver -from a Win32 application (our display drivers in contrast load them inside -the VxD directly, but the control panel applets use this function). -****************************************************************************/ -static GA_devCtx * NAPI _GA_loadDriver( - N_int32 deviceIndex, - N_int32 shared) -{ - GA_devCtx *dc; - DWORD inBuf[1]; - DWORD outBuf[1]; - N_int32 totalMemory = 0,oldIOPL; - - if (deviceIndex >= GA_MAX_DEVICES) - PM_fatalError("DeviceIndex too large in GA_loadDriver!"); - PM_init(); - inBuf[0] = deviceIndex; - if (DeviceIoControl(_PM_hDevice, PMHELP_GETMEMSIZE32, - inBuf, sizeof(inBuf), outBuf, sizeof(outBuf), NULL, NULL)) - totalMemory = outBuf[0]; - if (totalMemory == 0) - totalMemory = 8192; - _GA_exports.GA_forceMemSize(totalMemory,shared); - oldIOPL = PM_setIOPL(3); - dc = ORG_GA_loadDriver(deviceIndex,shared); - PM_setIOPL(oldIOPL); - return dc; -} - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) { - haveRDTSC = true; - return true; - } - else if (QueryPerformanceFrequency((LARGE_INTEGER*)&countFreq)) { - haveRDTSC = false; - return true; - } - return false; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - if (haveRDTSC) - _GA_readTimeStamp(value); - else - QueryPerformanceCounter((LARGE_INTEGER*)value); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/agplib.c b/board/MAI/bios_emulator/scitech/src/common/agplib.c deleted file mode 100644 index 476eedc873..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/agplib.c +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: Any 32-bit protected mode environment -* -* Description: C module for the Graphics Accelerator Driver API. Uses -* the SciTech PM library for interfacing with DOS -* extender specific functions. -* -****************************************************************************/ - -#include "nucleus/graphics.h" -#include "nucleus/agp.h" - -/*---------------------------- Global Variables ---------------------------*/ - -#ifndef DEBUG_AGP_DRIVER -static AGP_exports _AGP_exports; -static int loaded = false; -static PE_MODULE *hModBPD = NULL; - -static N_imports _N_imports = { - sizeof(N_imports), - _OS_delay, - }; - -static AGP_imports _AGP_imports = { - sizeof(AGP_imports), - }; -#endif - -#include "pmimp.h" - -/*----------------------------- Implementation ----------------------------*/ - -#define DLL_NAME "agp.bpd" - -#ifndef DEBUG_AGP_DRIVER -/**************************************************************************** -REMARKS: -Fatal error handler for non-exported GA_exports. -****************************************************************************/ -static void _AGP_fatalErrorHandler(void) -{ - PM_fatalError("Unsupported AGP export function called! Please upgrade your copy of AGP!\n"); -} - -/**************************************************************************** -PARAMETERS: -shared - True to load the driver into shared memory. - -REMARKS: -Loads the Nucleus binary portable DLL into memory and initilises it. -****************************************************************************/ -static ibool LoadDriver(void) -{ - AGP_initLibrary_t AGP_initLibrary; - AGP_exports *agpExp; - char filename[PM_MAX_PATH]; - char bpdpath[PM_MAX_PATH]; - int i,max; - ulong *p; - - /* Check if we have already loaded the driver */ - if (loaded) - return true; - PM_init(); - - /* Open the BPD file */ - if (!PM_findBPD(DLL_NAME,bpdpath)) - return false; - strcpy(filename,bpdpath); - strcat(filename,DLL_NAME); - if ((hModBPD = PE_loadLibrary(filename,false)) == NULL) - return false; - if ((AGP_initLibrary = (AGP_initLibrary_t)PE_getProcAddress(hModBPD,"_AGP_initLibrary")) == NULL) - return false; - bpdpath[strlen(bpdpath)-1] = 0; - if (strcmp(bpdpath,PM_getNucleusPath()) == 0) - strcpy(bpdpath,PM_getNucleusConfigPath()); - else { - PM_backslash(bpdpath); - strcat(bpdpath,"config"); - } - if ((agpExp = AGP_initLibrary(bpdpath,filename,GA_getSystemPMImports(),&_N_imports,&_AGP_imports)) == NULL) - PM_fatalError("AGP_initLibrary failed!\n"); - _AGP_exports.dwSize = sizeof(_AGP_exports); - max = sizeof(_AGP_exports)/sizeof(AGP_initLibrary_t); - for (i = 0,p = (ulong*)&_AGP_exports; i < max; i++) - *p++ = (ulong)_AGP_fatalErrorHandler; - memcpy(&_AGP_exports,agpExp,MIN(sizeof(_AGP_exports),agpExp->dwSize)); - loaded = true; - return true; -} - -/* The following are stub entry points that the application calls to - * initialise the Nucleus loader library, and we use this to load our - * driver DLL from disk and initialise the library using it. - */ - -/* {secret} */ -int NAPI AGP_status(void) -{ - if (!loaded) - return nDriverNotFound; - return _AGP_exports.AGP_status(); -} - -/* {secret} */ -const char * NAPI AGP_errorMsg( - N_int32 status) -{ - if (!loaded) - return "Unable to load Nucleus device driver!"; - return _AGP_exports.AGP_errorMsg(status); -} - -/* {secret} */ -AGP_devCtx * NAPI AGP_loadDriver(N_int32 deviceIndex) -{ - if (!LoadDriver()) - return NULL; - return _AGP_exports.AGP_loadDriver(deviceIndex); -} - -/* {secret} */ -void NAPI AGP_unloadDriver( - AGP_devCtx *dc) -{ - if (loaded) - _AGP_exports.AGP_unloadDriver(dc); -} - -/* {secret} */ -void NAPI AGP_getGlobalOptions( - AGP_globalOptions *options) -{ - if (LoadDriver()) - _AGP_exports.AGP_getGlobalOptions(options); -} - -/* {secret} */ -void NAPI AGP_setGlobalOptions( - AGP_globalOptions *options) -{ - if (LoadDriver()) - _AGP_exports.AGP_setGlobalOptions(options); -} - -/* {secret} */ -void NAPI AGP_saveGlobalOptions( - AGP_globalOptions *options) -{ - if (loaded) - _AGP_exports.AGP_saveGlobalOptions(options); -} -#endif - -/* {secret} */ -void NAPI _OS_delay8253(N_uint32 microSeconds); - -/**************************************************************************** -REMARKS: -This function delays for the specified number of microseconds -****************************************************************************/ -void NAPI _OS_delay( - N_uint32 microSeconds) -{ - static ibool inited = false; - static ibool haveRDTSC; - LZTimerObject tm; - - if (!inited) { -#ifndef __WIN32_VXD__ - /* This has been causing problems in VxD's for some reason, so for now */ - /* we avoid using it. */ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) { - ZTimerInit(); - haveRDTSC = true; - } - else -#endif - haveRDTSC = false; - inited = true; - } - if (haveRDTSC) { - LZTimerOnExt(&tm); - while (LZTimerLapExt(&tm) < microSeconds) - ; - LZTimerOnExt(&tm); - } - else - _OS_delay8253(microSeconds); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/center.c b/board/MAI/bios_emulator/scitech/src/common/center.c deleted file mode 100644 index 68e17c2a94..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/center.c +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -* -* Display Doctor Windows Interface Code -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code is a proprietary trade secret of | -* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 | -* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, | -* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS | -* |STRICTLY PROHIBITED BY LAW. Unless you have current, express | -* |written authorization from SciTech to possess or use this code, you | -* |may be subject to civil and/or criminal penalties. | -* | | -* |If you received this code in error or you would like to report | -* |improper use, please immediately contact SciTech Software, Inc. at | -* |530-894-8400. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: C++ 3.0 -* Environment: Win16 -* -* Description: Dialog driven configuration program for UniVBE and -* WinDirect Professional products. -* -****************************************************************************/ - -#include "center.h" - -/*------------------------------ Implementation ---------------------------*/ - -void _EXPORT CenterWindow(HWND hWndCenter, HWND parent, BOOL repaint) -/**************************************************************************** -* -* Function: CenterWindow -* Parameters: hWndCenter - Window to center -* parent - Handle for parent window -* repaint - true if window should be re-painted -* -* Description: Centers the specified window within the bounds of the -* specified parent window. If the parent window is NULL, then -* we center it using the Desktop window. -* -****************************************************************************/ -{ - HWND hWndParent = (parent ? parent : GetDesktopWindow()); - RECT RectParent; - RECT RectCenter; - int CenterX,CenterY,Height,Width; - - GetWindowRect(hWndParent, &RectParent); - GetWindowRect(hWndCenter, &RectCenter); - - Width = (RectCenter.right - RectCenter.left); - Height = (RectCenter.bottom - RectCenter.top); - CenterX = ((RectParent.right - RectParent.left) - Width) / 2; - CenterY = ((RectParent.bottom - RectParent.top) - Height) / 2; - - if ((CenterX < 0) || (CenterY < 0)) { - /* The Center Window is smaller than the parent window. */ - if (hWndParent != GetDesktopWindow()) { - /* If the parent window is not the desktop use the desktop size. */ - CenterX = (GetSystemMetrics(SM_CXSCREEN) - Width) / 2; - CenterY = (GetSystemMetrics(SM_CYSCREEN) - Height) / 2; - } - CenterX = (CenterX < 0) ? 0: CenterX; - CenterY = (CenterY < 0) ? 0: CenterY; - } - else { - CenterX += RectParent.left; - CenterY += RectParent.top; - } - - /* Copy the values into RectCenter */ - RectCenter.left = CenterX; - RectCenter.right = CenterX + Width; - RectCenter.top = CenterY; - RectCenter.bottom = CenterY + Height; - - /* Move the window to the new location */ - MoveWindow(hWndCenter, RectCenter.left, RectCenter.top, - (RectCenter.right - RectCenter.left), - (RectCenter.bottom - RectCenter.top), repaint); -} - -void _EXPORT CenterLogo(HWND hWndLogo, HWND hWndParent, int CenterY) -/**************************************************************************** -* -* Function: CenterLogo -* Parameters: hWndLogo - Window to center -* hWndParent - Handle for parent window -* CenterY - Top coordinate for logo -* -* Description: Centers the specified window within the bounds of the -* specified parent window in the horizontal direction only. -* -****************************************************************************/ -{ - RECT RectParent; - RECT RectCenter; - int CenterX,Height,Width; - - GetWindowRect(hWndParent, &RectParent); - GetWindowRect(hWndLogo, &RectCenter); - Width = (RectCenter.right - RectCenter.left); - Height = (RectCenter.bottom - RectCenter.top); - CenterX = ((RectParent.right - RectParent.left) - Width) / 2; - - /* Copy the values into RectCenter */ - RectCenter.left = CenterX; - RectCenter.right = CenterX + Width; - RectCenter.top = CenterY; - RectCenter.bottom = CenterY + Height; - - /* Move the window to the new location */ - MoveWindow(hWndLogo, RectCenter.left, RectCenter.top, - (RectCenter.right - RectCenter.left), - (RectCenter.bottom - RectCenter.top), false); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/cmdline.c b/board/MAI/bios_emulator/scitech/src/common/cmdline.c deleted file mode 100644 index 531e5e1312..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/cmdline.c +++ /dev/null @@ -1,428 +0,0 @@ -/**************************************************************************** -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: any -* -* Description: This module contains code to parse the command line, -* extracting options and parameters in standard System V -* style. -* -****************************************************************************/ - -#include -#include -#include -#include "cmdline.h" - -/*------------------------- Global variables ------------------------------*/ - -int nextargv = 1; /* Index into argv array */ -char *nextchar = NULL; /* Pointer to next character */ - -/*-------------------------- Implementation -------------------------------*/ - -#define IS_SWITCH_CHAR(c) ((c) == '-') -#define IS_NOT_SWITCH_CHAR(c) ((c) != '-') - -/**************************************************************************** -DESCRIPTION: -Parse the command line for specific options - -HEADER: -cmdline.h - -PARAMETERS: -argc - Value passed to program through argc variable -argv - Pointer to the argv array passed to the program -format - A string representing the expected format of the command line -argument - Pointer to optional argument on command line - -RETURNS: -Character code representing the next option parsed from the command line by -getcmdopt. Returns ALLDONE (-1) when there are no more parameters to be parsed -on the command line, PARAMETER (-2) when the argument being parsed is a -parameter and not an option switch and lastly INVALID (-3) if an error -occured while parsing the command line. - -REMARKS: -Function to parse the command line option switches in UNIX System V style. -When getcmdopt is called, it returns the character code of the next valid -option that is parsed from the command line as specified by the Format -string. The format string should be in the following form: - - "abcd:e:f:" - -where a,b and c represent single switch style options and the character -code returned by getcmdopt is the only value returned. Also d, e and f -represent options that expect arguments immediately after them on the -command line. The argument that follows the option on the command line is -returned via a reference in the pointer argument. Thus a valid command line -for this format string might be: - - myprogram -adlines -b -f format infile outfile - -where a and b will be returned as single character options with no argument, -while d is returned with the argument lines and f is returned with the -argument format. - -When getcmdopt returns with PARAMETER (we attempted to parse a paramter, not -an option), the global variable NextArgv will hold an index in the argv -array to the argument on the command line AFTER the options, ie in the -above example the string 'infile'. If the parameter is successfully used, -NextArgv should be incremented and getcmdopt can be called again to parse any -more options. Thus you can also have options interspersed throught the -command line. eg: - - myprogram -adlines infile -b outfile -f format - -can be made to be a valid form of the above command line. -****************************************************************************/ -int getcmdopt( - int argc, - char **argv, - char *format, - char **argument) -{ - char ch; - char *formatchar; - - if (argc > nextargv) { - if (nextchar == NULL) { - nextchar = argv[nextargv]; /* Index next argument */ - if (nextchar == NULL) { - nextargv++; - return ALLDONE; /* No more options */ - } - if (IS_NOT_SWITCH_CHAR(*nextchar)) { - nextchar = NULL; - return PARAMETER; /* We have a parameter */ - } - nextchar++; /* Move past switch operator */ - if (IS_SWITCH_CHAR(*nextchar)) { - nextchar = NULL; - return INVALID; /* Ignore rest of line */ - } - } - if ((ch = *(nextchar++)) == 0) { - nextchar = NULL; - return INVALID; /* No options on line */ - } - - if (ch == ':' || (formatchar = strchr(format, ch)) == NULL) - return INVALID; - - if (*(++formatchar) == ':') { /* Expect an argument after option */ - nextargv++; - if (*nextchar == 0) { - if (argc <= nextargv) - return INVALID; - nextchar = argv[nextargv++]; - } - *argument = nextchar; - nextchar = NULL; - } - else { /* We have a switch style option */ - if (*nextchar == 0) { - nextargv++; - nextchar = NULL; - } - *argument = NULL; - } - return ch; /* return the option specifier */ - } - nextchar = NULL; - nextargv++; - return ALLDONE; /* no arguments on command line */ -} - -/**************************************************************************** -PARAMETERS: -optarr - Description for the option we are parsing -argument - String to parse - -RETURNS: -INVALID on error, ALLDONE on success. - -REMARKS: -Parses the argument string depending on the type of argument that is -expected, filling in the argument for that option. Note that to parse a -string, we simply return a pointer to argument. -****************************************************************************/ -static int parse_option( - Option *optarr, - char *argument) -{ - int num_read; - - switch ((int)(optarr->type)) { - case OPT_INTEGER: - num_read = sscanf(argument,"%d",(int*)optarr->arg); - break; - case OPT_HEX: - num_read = sscanf(argument,"%x",(int*)optarr->arg); - break; - case OPT_OCTAL: - num_read = sscanf(argument,"%o",(int*)optarr->arg); - break; - case OPT_UNSIGNED: - num_read = sscanf(argument,"%u",(uint*)optarr->arg); - break; - case OPT_LINTEGER: - num_read = sscanf(argument,"%ld",(long*)optarr->arg); - break; - case OPT_LHEX: - num_read = sscanf(argument,"%lx",(long*)optarr->arg); - break; - case OPT_LOCTAL: - num_read = sscanf(argument,"%lo",(long*)optarr->arg); - break; - case OPT_LUNSIGNED: - num_read = sscanf(argument,"%lu",(ulong*)optarr->arg); - break; - case OPT_FLOAT: - num_read = sscanf(argument,"%f",(float*)optarr->arg); - break; - case OPT_DOUBLE: - num_read = sscanf(argument,"%lf",(double*)optarr->arg); - break; - case OPT_LDOUBLE: - num_read = sscanf(argument,"%Lf",(long double*)optarr->arg); - break; - case OPT_STRING: - num_read = 1; /* This always works */ - *((char**)optarr->arg) = argument; - break; - default: - return INVALID; - } - - if (num_read == 0) - return INVALID; - else - return ALLDONE; -} - -/**************************************************************************** -HEADER: -cmdline.h - -PARAMETERS: -argc - Number of arguments on command line -argv - Array of command line arguments -num_opt - Number of options in option array -optarr - Array to specify how to parse the command line -do_param - Routine to handle a command line parameter - -RETURNS: -ALLDONE, INVALID or HELP - -REMARKS: -Function to parse the command line according to a table of options. This -routine calls getcmdopt above to parse each individual option and attempts -to parse each option into a variable of the specified type. The routine -can parse integers and long integers in either decimal, octal, hexadecimal -notation, unsigned integers and unsigned longs, strings and option switches. -Option switches are simply boolean variables that get turned on if the -switch was parsed. - -Parameters are extracted from the command line by calling a user supplied -routine do_param() to handle each parameter as it is encountered. The -routine do_param() should accept a pointer to the parameter on the command -line and an integer representing how many parameters have been encountered -(ie: 1 if this is the first parameter, 10 if it is the 10th etc), and return -ALLDONE upon successfully parsing it or INVALID if the parameter was invalid. - -We return either ALLDONE if all the options were successfully parsed, -INVALID if an invalid option was encountered or HELP if any of -h, -H or --? were present on the command line. -****************************************************************************/ -int getargs( - int argc, - char *argv[], - int num_opt, - Option optarr[], - int (*do_param)( - char *param, - int num)) -{ - int i,opt; - char *argument; - int param_num = 1; - char cmdstr[MAXARG*2 + 4]; - - /* Build the command string from the array of options */ - - strcpy(cmdstr,"hH?"); - for (i = 0,opt = 3; i < num_opt; i++,opt++) { - cmdstr[opt] = optarr[i].opt; - if (optarr[i].type != OPT_SWITCH) { - cmdstr[++opt] = ':'; - } - } - cmdstr[opt] = '\0'; - - for (;;) { - opt = getcmdopt(argc,argv,cmdstr,&argument); - switch (opt) { - case 'H': - case 'h': - case '?': - return HELP; - case ALLDONE: - return ALLDONE; - case INVALID: - return INVALID; - case PARAMETER: - if (do_param == NULL) - return INVALID; - if (do_param(argv[nextargv],param_num) == INVALID) - return INVALID; - nextargv++; - param_num++; - break; - default: - - /* Search for the option in the option array. We are - * guaranteed to find it. - */ - - for (i = 0; i < num_opt; i++) { - if (optarr[i].opt == opt) - break; - } - if (optarr[i].type == OPT_SWITCH) - *((ibool*)optarr[i].arg) = true; - else { - if (parse_option(&optarr[i],argument) == INVALID) - return INVALID; - } - break; - } - } -} - -/**************************************************************************** -HEADER: -cmdline.h - -PARAMETERS: -num_opt - Number of options in the table -optarr - Table of option descriptions - -REMARKS: -Prints the description of each option in a standard format to the standard -output device. The description for each option is obtained from the table -of options. -****************************************************************************/ -void print_desc( - int num_opt, - Option optarr[]) -{ - int i; - - for (i = 0; i < num_opt; i++) { - if (optarr[i].type == OPT_SWITCH) - printf(" -%c %s\n",optarr[i].opt,optarr[i].desc); - else - printf(" -%c %s\n",optarr[i].opt,optarr[i].desc); - } -} - -/**************************************************************************** -HEADER: -cmdline.h - -PARAMETERS: -moduleName - Module name for program -cmdLine - Command line to parse -pargc - Pointer to 'argc' parameter -pargv - Pointer to 'argv' parameter -maxArgc - Maximum argv array index - -REMARKS: -Parses a command line from a single string into the C style 'argc' and -'argv' format. Most useful for Windows programs where the command line -is passed in verbatim. -****************************************************************************/ -int parse_commandline( - char *moduleName, - char *cmdLine, - int *pargc, - char *argv[], - int maxArgv) -{ - static char str[512]; - static char filename[260]; - char *prevWord = NULL; - ibool inQuote = FALSE; - ibool noStrip = FALSE; - int argc; - - argc = 0; - strcpy(filename,moduleName); - argv[argc++] = filename; - cmdLine = strncpy(str, cmdLine, sizeof(str)-1); - while (*cmdLine) { - switch (*cmdLine) { - case '"' : - if (prevWord != NULL) { - if (inQuote) { - if (!noStrip) - *cmdLine = '\0'; - argv [argc++] = prevWord; - prevWord = NULL; - } - else - noStrip = TRUE; - } - inQuote = !inQuote; - break; - case ' ' : - case '\t' : - if (!inQuote) { - if (prevWord != NULL) { - *cmdLine = '\0'; - argv [argc++] = prevWord; - prevWord = NULL; - noStrip = FALSE; - } - } - break; - default : - if (prevWord == NULL) - prevWord = cmdLine; - break; - } - if (argc >= maxArgv - 1) - break; - cmdLine++; - } - - if ((prevWord != NULL || (inQuote && prevWord != NULL)) && argc < maxArgv - 1) { - *cmdLine = '\0'; - argv [argc++] = prevWord; - } - argv[argc] = NULL; - - /* Return updated parameters */ - return (*pargc = argc); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/gabeos.c b/board/MAI/bios_emulator/scitech/src/common/gabeos.c deleted file mode 100644 index a934bd1cfc..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/gabeos.c +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: Linux -* -* Description: OS specific Nucleus Graphics Architecture services for -* the Linux operating system. -* -****************************************************************************/ - -#include "nucleus/graphics.h" -#include - -static ibool haveRDTSC; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -PARAMETERS: -path - Local path to the Nucleus driver files. - -REMARKS: -This function is used by the application program to override the location -of the Nucleus driver files that are loaded. Normally the loader code -will look in the system Nucleus directories first, then in the 'drivers' -directory relative to the current working directory, and finally relative -to the MGL_ROOT environment variable. -****************************************************************************/ -void NAPI GA_setLocalPath( - const char *path) -{ - PM_setLocalBPDPath(path); -} - -/**************************************************************************** -RETURNS: -Pointer to the system wide PM library imports, or the internal version if none - -REMARKS: -In order to support deploying new Nucleus drivers that may require updated -PM library functions, we check here to see if there is a system wide version -of the PM functions available. If so we return those functions for use with -the system wide Nucleus drivers, otherwise the compiled in version of the PM -library is used with the application local version of Nucleus. -****************************************************************************/ -PM_imports * NAPI GA_getSystemPMImports(void) -{ - /* TODO: We may very well want to provide a system shared library */ - /* that eports the PM functions required by the Nucleus library */ - /* for BeOS here. That will eliminate fatal errors loading new */ - /* drivers on BeOS! */ - return &_PM_imports; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp, - ibool shared) -{ - (void)gaExp; - (void)shared; - return false; -} - -#ifndef TEST_HARNESS -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI GA_queryFunctions( - GA_devCtx *dc, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.GA_queryFunctions(dc,id,funcs); -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI REF2D_queryFunctions( - REF2D_driver *ref2d, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.REF2D_queryFunctions(ref2d,id,funcs); -} -#endif - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) - haveRDTSC = true; - return true; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - if (haveRDTSC) - _GA_readTimeStamp(value); - else { - struct timeval t; - gettimeofday(&t, NULL); - value->low = t.tv_sec*1000000 + t.tv_usec; - value->high = 0; - } -} diff --git a/board/MAI/bios_emulator/scitech/src/common/gados.c b/board/MAI/bios_emulator/scitech/src/common/gados.c deleted file mode 100644 index d2be77694f..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/gados.c +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: MSDOS -* -* Description: OS specific Nucleus Graphics Architecture services for -* the MSDOS operating system. -* -****************************************************************************/ - -#include "pm_help.h" -#include "pmapi.h" -#include -#include -#include - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -PARAMETERS: -path - Local path to the Nucleus driver files. - -REMARKS: -This function is used by the application program to override the location -of the Nucleus driver files that are loaded. Normally the loader code -will look in the system Nucleus directories first, then in the 'drivers' -directory relative to the current working directory, and finally relative -to the MGL_ROOT environment variable. -****************************************************************************/ -void NAPI GA_setLocalPath( - const char *path) -{ - PM_setLocalBPDPath(path); -} - -/**************************************************************************** -RETURNS: -Pointer to the system wide PM library imports, or the internal version if none - -REMARKS: -Nothing to do here for DOS. Basically since DOS has no system wide shared -library mechanism we are essentially screwed if the binary API changes. -By default for 32-bit DOS apps the local Nucleus drivers should always be -used in preference to the system wide Nucleus drivers. -****************************************************************************/ -PM_imports * NAPI GA_getSystemPMImports(void) -{ - return &_PM_imports; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp, - ibool shared) -{ - (void)gaExp; - (void)shared; - return false; -} - -#if !defined(TEST_HARNESS) && !defined(VBETEST) -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI GA_queryFunctions( - GA_devCtx *dc, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.GA_queryFunctions(dc,id,funcs); -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI REF2D_queryFunctions( - REF2D_driver *ref2d, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.REF2D_queryFunctions(ref2d,id,funcs); -} -#endif - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the DOS -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) - return true; - return false; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - _GA_readTimeStamp(value); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/galib.c b/board/MAI/bios_emulator/scitech/src/common/galib.c deleted file mode 100644 index f2eacc3d24..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/galib.c +++ /dev/null @@ -1,268 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: Any 32-bit protected mode environment -* -* Description: C module for the Graphics Accelerator Driver API. Uses -* the SciTech PM library for interfacing with DOS -* extender specific functions. -* -****************************************************************************/ - -#include "nucleus/graphics.h" -#if defined(__WIN32_VXD__) || defined(__NT_DRIVER__) -#include "sdd/sddhelp.h" -#else -#include -#include -#endif - -/*---------------------------- Global Variables ---------------------------*/ - -#ifndef TEST_HARNESS -GA_exports _VARAPI __GA_exports; -static int loaded = false; -static PE_MODULE *hModBPD = NULL; - -static N_imports _N_imports = { - sizeof(N_imports), - _OS_delay, - }; - -static GA_imports _GA_imports = { - sizeof(GA_imports), - GA_getSharedInfo, - GA_TimerInit, - GA_TimerRead, - GA_TimerDifference, - }; -#endif - -/*----------------------------- Implementation ----------------------------*/ - -#define DLL_NAME "graphics.bpd" - -/**************************************************************************** -REMARKS: -This function is no longer used but we must implement it and return NULL -for compatibility with older binary drivers. -****************************************************************************/ -GA_sharedInfo * NAPI GA_getSharedInfo( - int device) -{ - return NULL; -} - -#ifndef TEST_HARNESS -/**************************************************************************** -REMARKS: -Fatal error handler for non-exported GA_exports. -****************************************************************************/ -static void _GA_fatalErrorHandler(void) -{ - PM_fatalError("Unsupported Nucleus export function called! Please upgrade your copy of Nucleus!\n"); -} - -/**************************************************************************** -PARAMETERS: -shared - True to load the driver into shared memory. - -REMARKS: -Loads the Nucleus binary portable DLL into memory and initilises it. -****************************************************************************/ -static ibool LoadDriver( - ibool shared) -{ - GA_initLibrary_t GA_initLibrary; - GA_exports *gaExp; - char filename[PM_MAX_PATH]; - char bpdpath[PM_MAX_PATH]; - int i,max; - ulong *p; - - /* Check if we have already loaded the driver */ - if (loaded) - return true; - PM_init(); - - /* First try to see if we can find the system wide shared exports - * if they are available. Under OS/2 this connects to our global - * shared Nucleus loader in SDDPMI.DLL. - */ - __GA_exports.dwSize = sizeof(__GA_exports); - if (GA_getSharedExports(&__GA_exports,shared)) - return loaded = true; - - /* Open the BPD file */ - if (!PM_findBPD(DLL_NAME,bpdpath)) - return false; - strcpy(filename,bpdpath); - strcat(filename,DLL_NAME); - if ((hModBPD = PE_loadLibrary(filename,shared)) == NULL) - return false; - if ((GA_initLibrary = (GA_initLibrary_t)PE_getProcAddress(hModBPD,"_GA_initLibrary")) == NULL) - return false; - bpdpath[strlen(bpdpath)-1] = 0; - if (strcmp(bpdpath,PM_getNucleusPath()) == 0) - strcpy(bpdpath,PM_getNucleusConfigPath()); - else { - PM_backslash(bpdpath); - strcat(bpdpath,"config"); - } - if ((gaExp = GA_initLibrary(shared,bpdpath,filename,GA_getSystemPMImports(),&_N_imports,&_GA_imports)) == NULL) - PM_fatalError("GA_initLibrary failed!\n"); - - /* Initialize all default imports to point to fatal error handler - * for upwards compatibility, and copy the exported functions. - */ - max = sizeof(__GA_exports)/sizeof(GA_initLibrary_t); - for (i = 0,p = (ulong*)&__GA_exports; i < max; i++) - *p++ = (ulong)_GA_fatalErrorHandler; - memcpy(&__GA_exports,gaExp,MIN(sizeof(__GA_exports),gaExp->dwSize)); - loaded = true; - return true; -} - -/* The following are stub entry points that the application calls to - * initialise the Nucleus loader library, and we use this to load our - * driver DLL from disk and initialise the library using it. - */ - -/* {secret} */ -int NAPI GA_status(void) -{ - if (!loaded) - return nDriverNotFound; - return __GA_exports.GA_status(); -} - -/* {secret} */ -const char * NAPI GA_errorMsg( - N_int32 status) -{ - if (!loaded) - return "Unable to load Nucleus device driver!"; - return __GA_exports.GA_errorMsg(status); -} - -/* {secret} */ -int NAPI GA_getDaysLeft(N_int32 shared) -{ - if (!LoadDriver(shared)) - return -1; - return __GA_exports.GA_getDaysLeft(shared); -} - -/* {secret} */ -int NAPI GA_registerLicense(uchar *license,N_int32 shared) -{ - if (!LoadDriver(shared)) - return 0; - return __GA_exports.GA_registerLicense(license,shared); -} - -/* {secret} */ -ibool NAPI GA_loadInGUI(N_int32 shared) -{ - if (!LoadDriver(shared)) - return false; - return __GA_exports.GA_loadInGUI(shared); -} - -/* {secret} */ -int NAPI GA_enumerateDevices(N_int32 shared) -{ - if (!LoadDriver(shared)) - return 0; - return __GA_exports.GA_enumerateDevices(shared); -} - -/* {secret} */ -GA_devCtx * NAPI GA_loadDriver(N_int32 deviceIndex,N_int32 shared) -{ - if (!LoadDriver(shared)) - return NULL; - return __GA_exports.GA_loadDriver(deviceIndex,shared); -} - -/* {secret} */ -void NAPI GA_getGlobalOptions( - GA_globalOptions *options, - ibool shared) -{ - if (LoadDriver(shared)) - __GA_exports.GA_getGlobalOptions(options,shared); -} - -/* {secret} */ -PE_MODULE * NAPI GA_loadLibrary( - const char *szBPDName, - ulong *size, - ibool shared) -{ - if (!LoadDriver(shared)) - return NULL; - return __GA_exports.GA_loadLibrary(szBPDName,size,shared); -} - -/* {secret} */ -GA_devCtx * NAPI GA_getCurrentDriver( - N_int32 deviceIndex) -{ - /* Bail for older drivers that didn't export this function! */ - if (!__GA_exports.GA_getCurrentDriver) - return NULL; - return __GA_exports.GA_getCurrentDriver(deviceIndex); -} - -/* {secret} */ -REF2D_driver * NAPI GA_getCurrentRef2d( - N_int32 deviceIndex) -{ - /* Bail for older drivers that didn't export this function! */ - if (!__GA_exports.GA_getCurrentRef2d) - return NULL; - return __GA_exports.GA_getCurrentRef2d(deviceIndex); -} - -/* {secret} */ -int NAPI GA_isOEMVersion(ibool shared) -{ - if (!LoadDriver(shared)) - return 0; - return __GA_exports.GA_isOEMVersion(shared); -} - -/* {secret} */ -N_uint32 * NAPI GA_getLicensedDevices(ibool shared) -{ - if (!LoadDriver(shared)) - return 0; - return __GA_exports.GA_getLicensedDevices(shared); -} -#endif diff --git a/board/MAI/bios_emulator/scitech/src/common/galinux.c b/board/MAI/bios_emulator/scitech/src/common/galinux.c deleted file mode 100644 index 47e4e8581d..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/galinux.c +++ /dev/null @@ -1,148 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: Linux -* -* Description: OS specific Nucleus Graphics Architecture services for -* the Linux operating system. -* -****************************************************************************/ - -#include "nucleus/graphics.h" -#include - -/*---------------------------- Global Variables ---------------------------*/ - -static ibool haveRDTSC; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -PARAMETERS: -path - Local path to the Nucleus driver files. - -REMARKS: -This function is used by the application program to override the location -of the Nucleus driver files that are loaded. Normally the loader code -will look in the system Nucleus directories first, then in the 'drivers' -directory relative to the current working directory, and finally relative -to the MGL_ROOT environment variable. -****************************************************************************/ -void NAPI GA_setLocalPath( - const char *path) -{ - PM_setLocalBPDPath(path); -} - -/**************************************************************************** -RETURNS: -Pointer to the system wide PM library imports, or the internal version if none - -REMARKS: -In order to support deploying new Nucleus drivers that may require updated -PM library functions, we check here to see if there is a system wide version -of the PM functions available. If so we return those functions for use with -the system wide Nucleus drivers, otherwise the compiled in version of the PM -library is used with the application local version of Nucleus. -****************************************************************************/ -PM_imports * NAPI GA_getSystemPMImports(void) -{ - /* TODO: We may very well want to provide a system shared library */ - /* that eports the PM functions required by the Nucleus library */ - /* for Linux here. That will eliminate fatal errors loading new */ - /* drivers on Linux! */ - return &_PM_imports; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp, - ibool shared) -{ - (void)gaExp; - (void)shared; - return false; -} - -#ifndef TEST_HARNESS -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI GA_queryFunctions( - GA_devCtx *dc, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.GA_queryFunctions(dc,id,funcs); -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI REF2D_queryFunctions( - REF2D_driver *ref2d, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.REF2D_queryFunctions(ref2d,id,funcs); -} -#endif - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) - haveRDTSC = true; - return true; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - if (haveRDTSC) - _GA_readTimeStamp(value); - else { - struct timeval t; - gettimeofday(&t, NULL); - value->low = t.tv_sec*1000000 + t.tv_usec; - value->high = 0; - } -} diff --git a/board/MAI/bios_emulator/scitech/src/common/gantdrv.c b/board/MAI/bios_emulator/scitech/src/common/gantdrv.c deleted file mode 100644 index 050f73767c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/gantdrv.c +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: NT device driver -* -* Description: OS specific Nucleus Graphics Architecture services for -* the NT device drivers. -* -****************************************************************************/ - -#include "sdd/sddhelp.h" - -/*------------------------- Global Variables ------------------------------*/ - -static ibool haveRDTSC; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -PARAMETERS: -path - Local path to the Nucleus driver files. - -REMARKS: -This function is used by the application program to override the location -of the Nucleus driver files that are loaded. Normally the loader code -will look in the system Nucleus directories first, then in the 'drivers' -directory relative to the current working directory, and finally relative -to the MGL_ROOT environment variable. -****************************************************************************/ -void NAPI GA_setLocalPath( - const char *path) -{ - PM_setLocalBPDPath(path); -} - -/**************************************************************************** -RETURNS: -Pointer to the system wide PM library imports, or the internal version if none - -REMARKS: -Nothing special for this OS. -****************************************************************************/ -PM_imports * NAPI GA_getSystemPMImports(void) -{ - return &_PM_imports; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp, - ibool shared) -{ - (void)gaExp; - (void)shared; - return false; -} - -#ifndef TEST_HARNESS -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI GA_queryFunctions( - GA_devCtx *dc, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.GA_queryFunctions(dc,id,funcs); -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI REF2D_queryFunctions( - REF2D_driver *ref2d, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.REF2D_queryFunctions(ref2d,id,funcs); -} -#endif - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) { - haveRDTSC = true; - } - return true; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - if (haveRDTSC) - _GA_readTimeStamp(value); - else - KeQuerySystemTime((LARGE_INTEGER*)value); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/gaos2.c b/board/MAI/bios_emulator/scitech/src/common/gaos2.c deleted file mode 100644 index 26e6503e5f..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/gaos2.c +++ /dev/null @@ -1,248 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: OS/2 32-bit -* -* Description: OS specific Nucleus Graphics Architecture services for -* the OS/2 operating system environments. -* -****************************************************************************/ - -#include "pm_help.h" -#define INCL_DOSERRORS -#define INCL_DOS -#define INCL_SUB -#define INCL_VIO -#define INCL_KBD -#include - -/*--------------------------- Global variables ----------------------------*/ - -static ibool haveRDTSC = false; -static ulong parms[3]; /* Must not cross 64Kb boundary! */ -static ulong result[4]; /* Must not cross 64Kb boundary! */ - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -PARAMETERS: -func - Helper device driver function to call - -RETURNS: -First return value from the device driver in parmsOut[0] - -REMARKS: -Function to open our helper device driver, call it and close the file -handle. Note that we have to open the device driver for every call because -of two problems: - - 1. We cannot open a single file handle in a DLL that is shared amongst - programs, since every process must have it's own open file handle. - - 2. For some reason there appears to be a limit of about 12 open file - handles on a device driver in the system. Hence when we open more - than about 12 file handles things start to go very strange. - -Hence we simply open the file handle every time that we need to call the -device driver to work around these problems. -****************************************************************************/ -static ulong CallSDDHelp( - int func) -{ - static ulong inLen; /* Must not cross 64Kb boundary! */ - static ulong outLen; /* Must not cross 64Kb boundary! */ - HFILE hSDDHelp; - - /* If this code in here fails, we are screwed! Many of our drivers - * use this code and don't have a C library, so we simply assume we - * can't fail here. - */ - DosOpen(PMHELP_NAME,&hSDDHelp,&result[0],0,0, - FILE_OPEN, OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE, - NULL); - DosDevIOCtl(hSDDHelp,PMHELP_IOCTL,func, - &parms, inLen = sizeof(parms), &inLen, - &result, outLen = sizeof(result), &outLen); - DosClose(hSDDHelp); - return result[0]; -} - -/**************************************************************************** -PARAMETERS: -path - Local path to the Nucleus driver files. - -REMARKS: -This function is used by the application program to override the location -of the Nucleus driver files that are loaded. Normally the loader code -will look in the system Nucleus directories first, then in the 'drivers' -directory relative to the current working directory, and finally relative -to the MGL_ROOT environment variable. -****************************************************************************/ -void NAPI GA_setLocalPath( - const char *path) -{ - PM_setLocalBPDPath(path); -} - -/**************************************************************************** -RETURNS: -Pointer to the system wide PM library imports, or the internal version if none - -REMARKS: -For OS/2 we don't need to do anything special because Nucleus is always -loaded via the shared SDDPMI driver when SDD is loaded so we don't need -a system wide PM library imports function. -****************************************************************************/ -PM_imports * NAPI GA_getSystemPMImports(void) -{ - return &_PM_imports; -} - -/**************************************************************************** -PARAMETERS: -gaExp - Place to store the exported functions -shared - True if connecting to the shared, global Nucleus driver - -REMARKS: -For OS/2 if SDD is loaded we *always* connect to the shared Nucleus functions -contained within the SDDPMI driver. This allows the Nucleus functions contained -within this driver to be utilised by all Nucleus apps in the system and -maintains a consistent state between versions. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp, - ibool shared) -{ - /* In test harness mode, we need to load a local copy of Nucleus */ -#if !defined (TEST_HARNESS) || defined (DEBUG_SDDPMI) - HMODULE hModSDDPMI; - char buf[80]; - GA_exports *exp; - - /* Initialise the PM library and connect to our runtime DLL's */ - PM_init(); - if (CallSDDHelp(PMHELP_GETSHAREDEXP) != 0) { - /* We have found the shared Nucleus exports. Because not all processes - * map to SDDPMI.DLL, we need to ensure that we connect to this - * DLL so that it gets mapped into our address space (that is - * where the shared Nucleus loader code is located). Simply doing a - * DosLoadModule on it is enough for this. - */ - DosLoadModule((PSZ)buf,sizeof(buf),(PSZ)"SDDPMI.DLL",&hModSDDPMI); - exp = (GA_exports*)result[0]; - memcpy(gaExp,exp,MIN(gaExp->dwSize,exp->dwSize)); - return true; - } -#endif - (void)shared; - return false; -} - -#ifndef TEST_HARNESS -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI GA_queryFunctions( - GA_devCtx *dc, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.GA_queryFunctions(dc,id,funcs); -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI REF2D_queryFunctions( - REF2D_driver *ref2d, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.REF2D_queryFunctions(ref2d,id,funcs); -} -#endif - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) - haveRDTSC = true; - return true; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - if (haveRDTSC) - _GA_readTimeStamp(value); - else - DosTmrQueryTime((QWORD*)value); -} - -/**************************************************************************** -REMARKS: -On OS/2, we need special memory allocation functions if we build SDDPMI in -test harness mode. But if we build GATest etc. in test mode, we want to use -the normal C runtime functions, so route them back here. -****************************************************************************/ - -#if defined (TEST_HARNESS) && !defined (DEBUG_SDDPMI) - -/* Undefine these macros first or we'll recurse to hell! */ -#undef malloc -#undef calloc -#undef realloc -#undef free - -void *SDDPMI_malloc(size_t size) { - return malloc(size); -} - -void *SDDPMI_calloc(size_t num, size_t size) { - return calloc(num, size); -} - -void SDDPMI_free(void *ptr) { - free(ptr); -} - -void *SDDPMI_realloc(void *ptr, size_t size) { - return realloc(ptr, size); -} - -#endif diff --git a/board/MAI/bios_emulator/scitech/src/common/gaqnx.c b/board/MAI/bios_emulator/scitech/src/common/gaqnx.c deleted file mode 100644 index 525d662869..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/gaqnx.c +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: QNX -* -* Description: OS specific Nucleus Graphics Architecture services for -* the QNX operating system. -* -****************************************************************************/ - -#include "nucleus/graphics.h" -#include - -/*---------------------------- Global Variables ---------------------------*/ - -static ibool haveRDTSC; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -PARAMETERS: -path - Local path to the Nucleus driver files. - -REMARKS: -This function is used by the application program to override the location -of the Nucleus driver files that are loaded. Normally the loader code -will look in the system Nucleus directories first, then in the 'drivers' -directory relative to the current working directory, and finally relative -to the MGL_ROOT environment variable. -****************************************************************************/ -void NAPI GA_setLocalPath( - const char *path) -{ - PM_setLocalBPDPath(path); -} - -/**************************************************************************** -RETURNS: -Pointer to the system wide PM library imports, or the internal version if none - -REMARKS: -In order to support deploying new Nucleus drivers that may require updated -PM library functions, we check here to see if there is a system wide version -of the PM functions available. If so we return those functions for use with -the system wide Nucleus drivers, otherwise the compiled in version of the PM -library is used with the application local version of Nucleus. -****************************************************************************/ -PM_imports * NAPI GA_getSystemPMImports(void) -{ - /* TODO: We may very well want to provide a system shared library */ - /* that eports the PM functions required by the Nucleus library */ - /* for QNX here. That will eliminate fatal errors loading new */ - /* drivers on QNX! */ - return &_PM_imports; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp, - ibool shared) -{ - (void)gaExp; - (void)shared; - return false; -} - -#ifndef TEST_HARNESS -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI GA_queryFunctions( - GA_devCtx *dc, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.GA_queryFunctions(dc,id,funcs); -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI REF2D_queryFunctions( - REF2D_driver *ref2d, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.REF2D_queryFunctions(ref2d,id,funcs); -} -#endif - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) - haveRDTSC = true; - return true; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - if (haveRDTSC) - _GA_readTimeStamp(value); - else { - struct timespec ts; - - clock_gettime(CLOCK_REALTIME, &ts); - value->low = (ts.tv_nsec / 1000 + ts.tv_sec * 1000000); - value->high = 0; - } -} diff --git a/board/MAI/bios_emulator/scitech/src/common/gartt.c b/board/MAI/bios_emulator/scitech/src/common/gartt.c deleted file mode 100644 index 3a41f59c18..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/gartt.c +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: RTTarget-32 -* -* Description: OS specific Nucleus Graphics Architecture services for -* the RTTarget-32 operating system environments. -* -****************************************************************************/ - -#include "nucleus/graphics.h" - -/*------------------------- Global Variables ------------------------------*/ - -static ibool haveRDTSC; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -PARAMETERS: -path - Local path to the Nucleus driver files. - -REMARKS: -This function is used by the application program to override the location -of the Nucleus driver files that are loaded. Normally the loader code -will look in the system Nucleus directories first, then in the 'drivers' -directory relative to the current working directory, and finally relative -to the MGL_ROOT environment variable. -****************************************************************************/ -void NAPI GA_setLocalPath( - const char *path) -{ - PM_setLocalBPDPath(path); -} - -/**************************************************************************** -RETURNS: -Pointer to the system wide PM library imports, or the internal version if none - -REMARKS: -In order to support deploying new Nucleus drivers that may require updated -PM library functions, we check here to see if there is a system wide version -of the PM functions available. If so we return those functions for use with -the system wide Nucleus drivers, otherwise the compiled in version of the PM -library is used with the application local version of Nucleus. -****************************************************************************/ -PM_imports * NAPI GA_getSystemPMImports(void) -{ - return &_PM_imports; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp, - ibool shared) -{ - (void)gaExp; - (void)shared; - return false; -} - -#ifndef TEST_HARNESS -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI GA_queryFunctions( - GA_devCtx *dc, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.GA_queryFunctions(dc,id,funcs); -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI REF2D_queryFunctions( - REF2D_driver *ref2d, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.REF2D_queryFunctions(ref2d,id,funcs); -} -#endif - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) { - haveRDTSC = true; - return true; - } - return false; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - if (haveRDTSC) - _GA_readTimeStamp(value); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/gasmx.c b/board/MAI/bios_emulator/scitech/src/common/gasmx.c deleted file mode 100644 index ae31941f49..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/gasmx.c +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: smx32 -* -* Description: OS specific Nucleus Graphics Architecture services for -* the smx32 platform -- no vxD support. -* -****************************************************************************/ - -#include "pmapi.h" -#include "nucleus/graphics.h" - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -PARAMETERS: -path - Local path to the Nucleus driver files. - -REMARKS: -This function is used by the application program to override the location -of the Nucleus driver files that are loaded. Normally the loader code -will look in the system Nucleus directories first, then in the 'drivers' -directory relative to the current working directory, and finally relative -to the MGL_ROOT environment variable. -****************************************************************************/ -void NAPI GA_setLocalPath( - const char *path) -{ - PM_setLocalBPDPath(path); -} - -/**************************************************************************** -RETURNS: -Pointer to the system wide PM library imports, or the internal version if none - -REMARKS: -In order to support deploying new Nucleus drivers that may require updated -PM library functions, we check here to see if there is a system wide version -of the PM functions available. If so we return those functions for use with -the system wide Nucleus drivers, otherwise the compiled in version of the PM -library is used with the application local version of Nucleus. -****************************************************************************/ -PM_imports * NAPI GA_getSystemPMImports(void) -{ - return &_PM_imports; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp, - ibool shared) -{ - (void)gaExp; - (void)shared; - return false; -} - -#ifndef TEST_HARNESS -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI GA_queryFunctions( - GA_devCtx *dc, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.GA_queryFunctions(dc,id,funcs); -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI REF2D_queryFunctions( - REF2D_driver *ref2d, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.REF2D_queryFunctions(ref2d,id,funcs); -} -#endif - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) - return true; - return false; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - _GA_readTimeStamp(value); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/gavxd.c b/board/MAI/bios_emulator/scitech/src/common/gavxd.c deleted file mode 100644 index fc8ba8d657..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/gavxd.c +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: Win32 VxD -* -* Description: OS specific Nucleus Graphics Architecture services for -* the Win32 VxD's. -* -****************************************************************************/ - -#include "sdd/sddhelp.h" - -/*------------------------- Global Variables ------------------------------*/ - -static ibool haveRDTSC; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -PARAMETERS: -path - Local path to the Nucleus driver files. - -REMARKS: -This function is used by the application program to override the location -of the Nucleus driver files that are loaded. Normally the loader code -will look in the system Nucleus directories first, then in the 'drivers' -directory relative to the current working directory, and finally relative -to the MGL_ROOT environment variable. -****************************************************************************/ -void NAPI GA_setLocalPath( - const char *path) -{ - PM_setLocalBPDPath(path); -} - -/**************************************************************************** -RETURNS: -Pointer to the system wide PM library imports, or the internal version if none - -REMARKS: -Nothing special for this OS. -****************************************************************************/ -PM_imports * NAPI GA_getSystemPMImports(void) -{ - return &_PM_imports; -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp, - ibool shared) -{ - (void)gaExp; - (void)shared; - return false; -} - -#ifndef TEST_HARNESS -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI GA_queryFunctions( - GA_devCtx *dc, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.GA_queryFunctions(dc,id,funcs); -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI REF2D_queryFunctions( - REF2D_driver *ref2d, - N_uint32 id, - void _FAR_ *funcs) -{ - return __GA_exports.REF2D_queryFunctions(ref2d,id,funcs); -} -#endif - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) { - haveRDTSC = true; - } - return true; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - if (haveRDTSC) - _GA_readTimeStamp(value); - else - VTD_Get_Real_Time(&value->high,&value->low); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/gawin32.c b/board/MAI/bios_emulator/scitech/src/common/gawin32.c deleted file mode 100644 index 69443344f4..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/gawin32.c +++ /dev/null @@ -1,255 +0,0 @@ -/**************************************************************************** -* -* SciTech Nucleus Graphics Architecture -* -* Copyright (C) 1991-1998 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code contains proprietary technology | -* |owned by SciTech Software, Inc., located at 505 Wall Street, | -* |Chico, CA 95928 USA (http://www.scitechsoft.com). | -* | | -* |The contents of this file are subject to the SciTech Nucleus | -* |License; you may *not* use this file or related software except in | -* |compliance with the License. You may obtain a copy of the License | -* |at http://www.scitechsoft.com/nucleus-license.txt | -* | | -* |Software distributed under the License is distributed on an | -* |"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | -* |implied. See the License for the specific language governing | -* |rights and limitations under the License. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: Win32 -* -* Description: OS specific Nucleus Graphics Architecture services for -* the Win32 operating system environments. -* -****************************************************************************/ - -#include "pm_help.h" -#include "pmapi.h" -#include -#include -#include -#define STRICT -#define WIN32_LEAN_AND_MEAN -#include - -/*------------------------- Global Variables ------------------------------*/ - -#define DLL_NAME "nga_w32.dll" - -extern HANDLE _PM_hDevice; -static HMODULE hModDLL = NULL; -static ibool useRing0Driver = false; -static ibool haveRDTSC; -static GA_largeInteger countFreq; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -REMARKS: -Loads the shared "nga_w32.dll" library from disk and connects to it. This -library is *always* located in the same directory as the Nucleus -graphics.bpd file. -****************************************************************************/ -static ibool LoadSharedDLL(void) -{ - char filename[PM_MAX_PATH]; - char bpdpath[PM_MAX_PATH]; - - /* Check if we have already loaded the DLL */ - if (hModDLL) - return true; - PM_init(); - - /* Open the DLL file */ - if (!PM_findBPD(DLL_NAME,bpdpath)) - return false; - strcpy(filename,bpdpath); - strcat(filename,DLL_NAME); - if ((hModDLL = LoadLibrary(filename)) == NULL) - return false; - return true; -} - -/**************************************************************************** -PARAMETERS: -path - Local path to the Nucleus driver files. - -REMARKS: -This function is used by the application program to override the location -of the Nucleus driver files that are loaded. Normally the loader code -will look in the system Nucleus directories first, then in the 'drivers' -directory relative to the current working directory, and finally relative -to the MGL_ROOT environment variable. - -Note that for Win32 we also call into the loaded PMHELP device driver -as necessary to change the local Nucleus path for system wide Nucleus -drivers. -****************************************************************************/ -void NAPI GA_setLocalPath( - const char *path) -{ - DWORD inBuf[1]; - DWORD outBuf[1],outCnt; - - PM_setLocalBPDPath(path); - if (_PM_hDevice != INVALID_HANDLE_VALUE) { - inBuf[0] = (DWORD)path; - DeviceIoControl(_PM_hDevice, PMHELP_GASETLOCALPATH32, - inBuf, sizeof(inBuf), outBuf, sizeof(outBuf), &outCnt, NULL); - } -} - -/**************************************************************************** -RETURNS: -Pointer to the system wide PM library imports, or the internal version if none - -REMARKS: -In order to support deploying new Nucleus drivers that may require updated -PM library functions, we check here to see if there is a system wide version -of the PM functions available. If so we return those functions for use with -the system wide Nucleus drivers, otherwise the compiled in version of the PM -library is used with the application local version of Nucleus. -****************************************************************************/ -PM_imports * NAPI GA_getSystemPMImports(void) -{ - PM_imports * pmImp; - PM_imports * (NAPIP _GA_getSystemPMImports)(void); - - if (LoadSharedDLL()) { - /* Note that Visual C++ build DLL's with only a single underscore in front - * of the exported name while Watcom C provides two of them. We check for - * both to allow working with either compiled DLL. - */ - if ((_GA_getSystemPMImports = (void*)GetProcAddress(hModDLL,"_GA_getSystemPMImports")) != NULL) { - if ((_GA_getSystemPMImports = (void*)GetProcAddress(hModDLL,"__GA_getSystemPMImports")) != NULL) { - pmImp = _GA_getSystemPMImports(); - memcpy(&_PM_imports,pmImp,MIN(_PM_imports.dwSize,pmImp->dwSize)); - return pmImp; - } - } - } - return &_PM_imports; -} - -/**************************************************************************** -PARAMETERS: -gaExp - Place to store the exported functions -shared - True if connecting to the shared, global Nucleus driver - -REMARKS: -For Win32 if we are connecting to the shared, global Nucleus driver (loaded -at ring 0) then we need to load a special nga_w32.dll library which contains -thunks to call down into the Ring 0 device driver as necessary. If we are -connecting to the application local Nucleus drivers (ie: Nucleus on DirectDraw -emulation layer) then we do nothing here. -****************************************************************************/ -ibool NAPI GA_getSharedExports( - GA_exports *gaExp, - ibool shared) -{ - GA_exports * exp; - GA_exports * (NAPIP _GA_getSystemGAExports)(void); - - useRing0Driver = false; - if (shared) { - if (!LoadSharedDLL()) - PM_fatalError("Unable to load " DLL_NAME "!"); - if ((_GA_getSystemGAExports = (void*)GetProcAddress(hModDLL,"_GA_getSystemGAExports")) == NULL) - if ((_GA_getSystemGAExports = (void*)GetProcAddress(hModDLL,"__GA_getSystemGAExports")) == NULL) - PM_fatalError("Unable to load " DLL_NAME "!"); - exp = _GA_getSystemGAExports(); - memcpy(gaExp,exp,MIN(gaExp->dwSize,exp->dwSize)); - useRing0Driver = true; - return true; - } - return false; -} - -#ifndef TEST_HARNESS -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI GA_queryFunctions( - GA_devCtx *dc, - N_uint32 id, - void _FAR_ *funcs) -{ - static ibool (NAPIP _GA_queryFunctions)(GA_devCtx *dc,N_uint32 id,void _FAR_ *funcs) = NULL; - - if (useRing0Driver) { - /* Call the version in nga_w32.dll if it is loaded */ - if (!_GA_queryFunctions) { - if ((_GA_queryFunctions = (void*)GetProcAddress(hModDLL,"_GA_queryFunctions")) == NULL) - if ((_GA_queryFunctions = (void*)GetProcAddress(hModDLL,"__GA_queryFunctions")) == NULL) - PM_fatalError("Unable to get exports from " DLL_NAME "!"); - } - return _GA_queryFunctions(dc,id,funcs); - } - return __GA_exports.GA_queryFunctions(dc,id,funcs); -} - -/**************************************************************************** -REMARKS: -Nothing special for this OS -****************************************************************************/ -ibool NAPI REF2D_queryFunctions( - REF2D_driver *ref2d, - N_uint32 id, - void _FAR_ *funcs) -{ - static ibool (NAPIP _REF2D_queryFunctions)(REF2D_driver *ref2d,N_uint32 id,void _FAR_ *funcs) = NULL; - - if (useRing0Driver) { - /* Call the version in nga_w32.dll if it is loaded */ - if (!_REF2D_queryFunctions) { - if ((_REF2D_queryFunctions = (void*)GetProcAddress(hModDLL,"_REF2D_queryFunctions")) == NULL) - if ((_REF2D_queryFunctions = (void*)GetProcAddress(hModDLL,"__REF2D_queryFunctions")) == NULL) - PM_fatalError("Unable to get exports from " DLL_NAME "!"); - } - return _REF2D_queryFunctions(ref2d,id,funcs); - } - return __GA_exports.REF2D_queryFunctions(ref2d,id,funcs); -} -#endif - -/**************************************************************************** -REMARKS: -This function initialises the high precision timing functions for the -Nucleus loader library. -****************************************************************************/ -ibool NAPI GA_TimerInit(void) -{ - if (_GA_haveCPUID() && (_GA_getCPUIDFeatures() & CPU_HaveRDTSC) != 0) { - haveRDTSC = true; - return true; - } - else if (QueryPerformanceFrequency((LARGE_INTEGER*)&countFreq)) { - haveRDTSC = false; - return true; - } - return false; -} - -/**************************************************************************** -REMARKS: -This function reads the high resolution timer. -****************************************************************************/ -void NAPI GA_TimerRead( - GA_largeInteger *value) -{ - if (haveRDTSC) - _GA_readTimeStamp(value); - else - QueryPerformanceCounter((LARGE_INTEGER*)value); -} diff --git a/board/MAI/bios_emulator/scitech/src/common/gtfcalc.c b/board/MAI/bios_emulator/scitech/src/common/gtfcalc.c deleted file mode 100644 index 1d547e9abb..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/gtfcalc.c +++ /dev/null @@ -1,436 +0,0 @@ -/**************************************************************************** -* -* VESA Generalized Timing Formula (GTF) -* Version 1.1 -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Developed by: SciTech Software, Inc. -* -* Language: ANSI C -* Environment: Any. -* -* Description: C module for generating GTF compatible timings given a set -* of input requirements. Translated from the original GTF -* 1.14 spreadsheet definition. -* -* Compile with #define TESTING to build a command line test -* program. -* -* NOTE: The code in here has been written for clarity and -* to follow the original GTF spec as closely as -* possible. -* -****************************************************************************/ - -#include "gtf.h" -#ifndef __WIN32_VXD__ -#include -#include -#include -#include -#include -#endif - -/*------------------------- Global Variables ------------------------------*/ - -static GTF_constants GC = { - 1.8, /* Margin size as percentage of display */ - 8, /* Character cell granularity */ - 1, /* Minimum front porch in lines/chars */ - 3, /* Width of V sync in lines */ - 8, /* Width of H sync as percent of total */ - 550, /* Minimum vertical sync + back porch (us) */ - 600, /* Blanking formula gradient */ - 40, /* Blanking formula offset */ - 128, /* Blanking formula scaling factor */ - 20, /* Blanking formula scaling factor weight */ - }; - -/*-------------------------- Implementation -------------------------------*/ - -#ifdef __WIN32_VXD__ -/* These functions are not supported in a VxD, so we stub them out so this - * module will at least compile. Calling the functions in here will do - * something wierd! - */ -double sqrt(double x) -{ return x; } - -double floor(double x) -{ return x; } - -double pow(double x,double y) -{ return x*y; } -#endif - -static double round(double v) -{ - return floor(v + 0.5); -} - -static void GetInternalConstants(GTF_constants *c) -/**************************************************************************** -* -* Function: GetInternalConstants -* Parameters: c - Place to store the internal constants -* -* Description: Calculates the rounded, internal set of GTF constants. -* These constants are different to the real GTF constants -* that can be set up for the monitor. The calculations to -* get these real constants are defined in the 'Work Area' -* after the constants are defined in the Excel spreadsheet. -* -****************************************************************************/ -{ - c->margin = GC.margin; - c->cellGran = round(GC.cellGran); - c->minPorch = round(GC.minPorch); - c->vSyncRqd = round(GC.vSyncRqd); - c->hSync = GC.hSync; - c->minVSyncBP = GC.minVSyncBP; - if (GC.k == 0) - c->k = 0.001; - else - c->k = GC.k; - c->m = (c->k / 256) * GC.m; - c->c = (GC.c - GC.j) * (c->k / 256) + GC.j; - c->j = GC.j; -} - -void GTF_calcTimings(double hPixels,double vLines,double freq, - int type,ibool wantMargins,ibool wantInterlace,GTF_timings *t) -/**************************************************************************** -* -* Function: GTF_calcTimings -* Parameters: hPixels - X resolution -* vLines - Y resolution -* freq - Frequency (Hz, KHz or MHz depending on type) -* type - 1 - vertical, 2 - horizontal, 3 - dot clock -* margins - True if margins should be generated -* interlace - True if interlaced timings to be generated -* t - Place to store the resulting timings -* -* Description: Calculates a set of GTF timing parameters given a specified -* resolution and vertical frequency. The horizontal frequency -* and dot clock will be automatically generated by this -* routines. -* -* For interlaced modes the CRTC parameters are calculated for -* a single field, so will be half what would be used in -* a non-interlaced mode. -* -****************************************************************************/ -{ - double interlace,vFieldRate,hPeriod; - double topMarginLines,botMarginLines; - double leftMarginPixels,rightMarginPixels; - double hPeriodEst,vSyncBP,vBackPorch; - double vTotalLines,vFieldRateEst; - double hTotalPixels,hTotalActivePixels,hBlankPixels; - double idealDutyCycle,hSyncWidth,hSyncBP,hBackPorch; - double idealHPeriod; - double vFreq,hFreq,dotClock; - GTF_constants c; - - /* Get rounded GTF constants used for internal calculations */ - GetInternalConstants(&c); - - /* Move input parameters into appropriate variables */ - vFreq = hFreq = dotClock = freq; - - /* Round pixels to character cell granularity */ - hPixels = round(hPixels / c.cellGran) * c.cellGran; - - /* For interlaced mode halve the vertical parameters, and double - * the required field refresh rate. - */ - vFieldRate = vFreq; - interlace = 0; - if (wantInterlace) - dotClock *= 2; - - /* Determine the lines for margins */ - if (wantMargins) { - topMarginLines = round(c.margin / 100 * vLines); - botMarginLines = round(c.margin / 100 * vLines); - } - else { - topMarginLines = 0; - botMarginLines = 0; - } - - if (type != GTF_lockPF) { - if (type == GTF_lockVF) { - /* Estimate the horizontal period */ - hPeriodEst = ((1/vFieldRate) - (c.minVSyncBP/1000000)) / - (vLines + (2*topMarginLines) + c.minPorch + interlace) * 1000000; - - /* Find the number of lines in vSync + back porch */ - vSyncBP = round(c.minVSyncBP / hPeriodEst); - } - else if (type == GTF_lockHF) { - /* Find the number of lines in vSync + back porch */ - vSyncBP = round((c.minVSyncBP * hFreq) / 1000); - } - - /* Find the number of lines in the V back porch alone */ - vBackPorch = vSyncBP - c.vSyncRqd; - - /* Find the total number of lines in the vertical period */ - vTotalLines = vLines + topMarginLines + botMarginLines + vSyncBP - + interlace + c.minPorch; - - if (type == GTF_lockVF) { - /* Estimate the vertical frequency */ - vFieldRateEst = 1000000 / (hPeriodEst * vTotalLines); - - /* Find the actual horizontal period */ - hPeriod = (hPeriodEst * vFieldRateEst) / vFieldRate; - - /* Find the actual vertical field frequency */ - vFieldRate = 1000000 / (hPeriod * vTotalLines); - } - else if (type == GTF_lockHF) { - /* Find the actual vertical field frequency */ - vFieldRate = (hFreq / vTotalLines) * 1000; - } - } - - /* Find the number of pixels in the left and right margins */ - if (wantMargins) { - leftMarginPixels = round(hPixels * c.margin) / (100 * c.cellGran); - rightMarginPixels = round(hPixels * c.margin) / (100 * c.cellGran); - } - else { - leftMarginPixels = 0; - rightMarginPixels = 0; - } - - /* Find the total number of active pixels in image + margins */ - hTotalActivePixels = hPixels + leftMarginPixels + rightMarginPixels; - - if (type == GTF_lockVF) { - /* Find the ideal blanking duty cycle */ - idealDutyCycle = c.c - ((c.m * hPeriod) / 1000); - } - else if (type == GTF_lockHF) { - /* Find the ideal blanking duty cycle */ - idealDutyCycle = c.c - (c.m / hFreq); - } - else if (type == GTF_lockPF) { - /* Find ideal horizontal period from blanking duty cycle formula */ - idealHPeriod = (((c.c - 100) + (sqrt((pow(100-c.c,2)) + - (0.4 * c.m * (hTotalActivePixels + rightMarginPixels + - leftMarginPixels) / dotClock)))) / (2 * c.m)) * 1000; - - /* Find the ideal blanking duty cycle */ - idealDutyCycle = c.c - ((c.m * idealHPeriod) / 1000); - } - - /* Find the number of pixels in blanking time */ - hBlankPixels = round((hTotalActivePixels * idealDutyCycle) / - ((100 - idealDutyCycle) * c.cellGran)) * c.cellGran; - - /* Find the total number of pixels */ - hTotalPixels = hTotalActivePixels + hBlankPixels; - - /* Find the horizontal back porch */ - hBackPorch = round((hBlankPixels / 2) / c.cellGran) * c.cellGran; - - /* Find the horizontal sync width */ - hSyncWidth = round(((c.hSync/100) * hTotalPixels) / c.cellGran) * c.cellGran; - - /* Find the horizontal sync + back porch */ - hSyncBP = hBackPorch + hSyncWidth; - - if (type == GTF_lockPF) { - /* Find the horizontal frequency */ - hFreq = (dotClock / hTotalPixels) * 1000; - - /* Find the number of lines in vSync + back porch */ - vSyncBP = round((c.minVSyncBP * hFreq) / 1000); - - /* Find the number of lines in the V back porch alone */ - vBackPorch = vSyncBP - c.vSyncRqd; - - /* Find the total number of lines in the vertical period */ - vTotalLines = vLines + topMarginLines + botMarginLines + vSyncBP - + interlace + c.minPorch; - - /* Find the actual vertical field frequency */ - vFieldRate = (hFreq / vTotalLines) * 1000; - } - else { - if (type == GTF_lockVF) { - /* Find the horizontal frequency */ - hFreq = 1000 / hPeriod; - } - else if (type == GTF_lockHF) { - /* Find the horizontal frequency */ - hPeriod = 1000 / hFreq; - } - - /* Find the pixel clock frequency */ - dotClock = hTotalPixels / hPeriod; - } - - /* Return the computed frequencies */ - t->vFreq = vFieldRate; - t->hFreq = hFreq; - t->dotClock = dotClock; - - /* Determine the vertical timing parameters */ - t->h.hTotal = (int)hTotalPixels; - t->h.hDisp = (int)hTotalActivePixels; - t->h.hSyncStart = t->h.hTotal - (int)hSyncBP; - t->h.hSyncEnd = t->h.hTotal - (int)hBackPorch; - t->h.hFrontPorch = t->h.hSyncStart - t->h.hDisp; - t->h.hSyncWidth = (int)hSyncWidth; - t->h.hBackPorch = (int)hBackPorch; - - /* Determine the vertical timing parameters */ - t->v.vTotal = (int)vTotalLines; - t->v.vDisp = (int)vLines; - t->v.vSyncStart = t->v.vTotal - (int)vSyncBP; - t->v.vSyncEnd = t->v.vTotal - (int)vBackPorch; - t->v.vFrontPorch = t->v.vSyncStart - t->v.vDisp; - t->v.vSyncWidth = (int)c.vSyncRqd; - t->v.vBackPorch = (int)vBackPorch; - if (wantInterlace) { - /* Halve the timings for interlaced modes */ - t->v.vTotal /= 2; - t->v.vDisp /= 2; - t->v.vSyncStart /= 2; - t->v.vSyncEnd /= 2; - t->v.vFrontPorch /= 2; - t->v.vSyncWidth /= 2; - t->v.vBackPorch /= 2; - t->dotClock /= 2; - } - - /* Mark as GTF timing using the sync polarities */ - t->interlace = (wantInterlace) ? 'I' : 'N'; - t->hSyncPol = '-'; - t->vSyncPol = '+'; -} - -void GTF_getConstants(GTF_constants *constants) -{ *constants = GC; } - -void GTF_setConstants(GTF_constants *constants) -{ GC = *constants; } - -#ifdef TESTING_GTF - -void main(int argc,char *argv[]) -{ - FILE *f; - double xPixels,yPixels,freq; - ibool interlace; - GTF_timings t; - - if (argc != 5 && argc != 6) { - printf("Usage: GTFCALC [[Hz] [KHz] [MHz]] [I]\n"); - printf("\n"); - printf("where is the horizontal resolution of the mode, is the\n"); - printf("vertical resolution of the mode. The value will be the frequency to\n"); - printf("drive the calculations, and will be either the vertical frequency (in Hz)\n"); - printf("the horizontal frequency (in KHz) or the dot clock (in MHz). To generate\n"); - printf("timings for an interlaced mode, add 'I' to the end of the command line.\n"); - printf("\n"); - printf("For example to generate timings for 640x480 at 60Hz vertical:\n"); - printf("\n"); - printf(" GTFCALC 640 480 60 Hz\n"); - printf("\n"); - printf("For example to generate timings for 640x480 at 31.5KHz horizontal:\n"); - printf("\n"); - printf(" GTFCALC 640 480 31.5 KHz\n"); - printf("\n"); - printf("For example to generate timings for 640x480 with a 25.175Mhz dot clock:\n"); - printf("\n"); - printf(" GTFCALC 640 480 25.175 MHz\n"); - printf("\n"); - printf("GTFCALC will print a summary of the results found, and dump the CRTC\n"); - printf("values to the UVCONFIG.CRT file in the format used by SciTech Display Doctor.\n"); - exit(1); - } - - /* Get values from command line */ - xPixels = atof(argv[1]); - yPixels = atof(argv[2]); - freq = atof(argv[3]); - interlace = ((argc == 6) && (argv[5][0] == 'I')); - - /* Compute the CRTC timings */ - if (toupper(argv[4][0]) == 'H') - GTF_calcTimings(xPixels,yPixels,freq,GTF_lockVF,false,interlace,&t); - else if (toupper(argv[4][0]) == 'K') - GTF_calcTimings(xPixels,yPixels,freq,GTF_lockHF,false,interlace,&t); - else if (toupper(argv[4][0]) == 'M') - GTF_calcTimings(xPixels,yPixels,freq,GTF_lockPF,false,interlace,&t); - else { - printf("Unknown command line!\n"); - exit(1); - } - - /* Dump summary info to standard output */ - printf("CRTC values for %.0fx%.0f @ %.2f %s\n", xPixels, yPixels, freq, argv[4]); - printf("\n"); - printf(" hTotal = %-4d vTotal = %-4d\n", - t.h.hTotal, t.v.vTotal); - printf(" hDisp = %-4d vDisp = %-4d\n", - t.h.hDisp, t.v.vDisp); - printf(" hSyncStart = %-4d vSyncStart = %-4d\n", - t.h.hSyncStart, t.v.vSyncStart); - printf(" hSyncEnd = %-4d vSyncEnd = %-4d\n", - t.h.hSyncEnd, t.v.vSyncEnd); - printf(" hFrontPorch = %-4d vFrontPorch = %-4d\n", - t.h.hFrontPorch, t.v.vFrontPorch); - printf(" hSyncWidth = %-4d vSyncWidth = %-4d\n", - t.h.hSyncWidth, t.v.vSyncWidth); - printf(" hBackPorch = %-4d vBackPorch = %-4d\n", - t.h.hBackPorch, t.v.vBackPorch); - printf("\n"); - printf(" Interlaced = %s\n", (t.interlace == 'I') ? "Yes" : "No"); - printf(" H sync pol = %c\n", t.hSyncPol); - printf(" V sync pol = %c\n", t.vSyncPol); - printf("\n"); - printf(" Vert freq = %.2f Hz\n", t.vFreq); - printf(" Horiz freq = %.2f KHz\n", t.hFreq); - printf(" Dot Clock = %.2f Mhz\n", t.dotClock); - - /* Dump to file in format used by SciTech Display Doctor */ - if ((f = fopen("UVCONFIG.CRT","w")) != NULL) { - fprintf(f, "[%.0f %.0f]\n", xPixels, yPixels); - fprintf(f, "%d %d %d %d '%c' %s\n", - t.h.hTotal, t.h.hDisp, - t.h.hSyncStart, t.h.hSyncEnd, - t.hSyncPol, (t.interlace == 'I') ? "I" : "NI"); - fprintf(f, "%d %d %d %d '%c'\n", - t.v.vTotal, t.v.vDisp, - t.v.vSyncStart, t.v.vSyncEnd, - t.vSyncPol); - fprintf(f, "%.2f\n", t.dotClock); - fclose(f); - } -} - -#endif /* TESTING */ diff --git a/board/MAI/bios_emulator/scitech/src/common/libcimp.c b/board/MAI/bios_emulator/scitech/src/common/libcimp.c deleted file mode 100644 index ab73ad578c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/libcimp.c +++ /dev/null @@ -1,827 +0,0 @@ -/**************************************************************************** -* -* SciTech MGL Graphics Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Module to implement a the OS specific side of the Binary -* Portable DLL C runtime library. The functions in here -* are imported into the Binary Portable DLL's to implement -* OS specific services. -* -****************************************************************************/ - -#include "pmapi.h" -#if defined(__WIN32_VXD__) || defined(__NT_DRIVER__) -#include "drvlib/peloader.h" -#include "drvlib/attrib.h" -#include "drvlib/libc/init.h" -#define __BUILDING_PE_LOADER__ -#include "drvlib/libc/file.h" -#if defined(__WIN32_VXD__) -#include "vxdfile.h" -#endif -#else -#include -#include -#include -#include -#include -#include -#include -#if defined(__GNUC__) || defined(__UNIX__) -#include -#include -#include -#else -#include -#endif -#include "drvlib/attrib.h" -#include "drvlib/libc/init.h" -#define __BUILDING_PE_LOADER__ -#include "drvlib/libc/file.h" -#if defined(__WINDOWS__) || defined(TNT) || defined(__RTTARGET__) -#define WIN32_LEAN_AND_MEAN -#define STRICT -#include -#endif -#ifdef __MSDOS__ -#include -#endif -#ifdef __OS2__ -#define INCL_DOS -#define INCL_DOSERRORS -#define INCL_SUB -#include -#endif -#endif - -/* No text or binary modes for Unix */ - -#ifndef O_BINARY -#define O_BINARY 0 -#define O_TEXT 0 -#endif - -/*--------------------------- Global variables ----------------------------*/ - -#if defined(__WIN32_VXD__) || defined(__NT_DRIVER__) -#define MAX_FILES 16 -static FILE *openHandles[MAX_FILES] = {NULL}; -#endif - -/* stub functions */ -void _CDECL stub_abort(void); -int _CDECL stub_atexit(void (*)(void)); -void * _CDECL stub_calloc(size_t _nelem, size_t _size); -void _CDECL stub_exit(int _status); -void _CDECL stub_free(void *_ptr); -char * _CDECL stub_getenv(const char *_name); -void * _CDECL stub_malloc(size_t _size); -void * _CDECL stub_realloc(void *_ptr, size_t _size); -int _CDECL stub_system(const char *_s); -int _CDECL stub_putenv(const char *_val); - -/* stub functions */ -int _CDECL stub_open(const char *_path, int _oflag, unsigned _mode); -int _CDECL stub_access(const char *_path, int _amode); -int _CDECL stub_close(int _fildes); -off_t _CDECL stub_lseek(int _fildes, off_t _offset, int _whence); -size_t _CDECL stub_read(int _fildes, void *_buf, size_t _nbyte); -int _CDECL stub_unlink(const char *_path); -size_t _CDECL stub_write(int _fildes, const void *_buf, size_t _nbyte); -int _CDECL stub_isatty(int _fildes); - -/* stub functions */ -int _CDECL stub_remove(const char *_filename); -int _CDECL stub_rename(const char *_old, const char *_new); - -/* stub functions */ -time_t _CDECL stub_time(time_t *_tod); - -/* stub functions */ -int _CDECL stub_raise(int); -void * _CDECL stub_signal(int, void *); - -/* functions */ -#define stub_OS_setfileattr _OS_setfileattr -#define stub_OS_getcurrentdate _OS_getcurrentdate - -LIBC_imports _VARAPI ___imports = { - sizeof(LIBC_imports), - - /* exports */ - stub_abort, - stub_atexit, - stub_calloc, - stub_exit, - stub_free, - stub_getenv, - stub_malloc, - stub_realloc, - stub_system, - stub_putenv, - - /* exports */ - stub_open, - stub_access, - stub_close, - stub_lseek, - stub_read, - stub_unlink, - stub_write, - stub_isatty, - - /* exports */ - stub_remove, - stub_rename, - - /* functions */ - stub_raise, - stub_signal, - - /* exports */ - stub_time, - - /* exports */ - stub_OS_setfileattr, - stub_OS_getcurrentdate, - }; - -/*---------------------- Stub function implementation ---------------------*/ - -/* stub functions */ -void _CDECL stub_abort(void) -{ -#if !defined( __WIN32_VXD__) && !defined(__NT_DRIVER__) - abort(); -#endif -} - -int _CDECL stub_atexit(void (*func)(void)) -{ -#if !defined( __WIN32_VXD__) && !defined(__NT_DRIVER__) - return atexit((void(*)(void))func); -#else - return -1; -#endif -} - -void * _CDECL stub_calloc(size_t _nelem, size_t _size) -{ return __PM_calloc(_nelem,_size); } - -void _CDECL stub_exit(int _status) -{ -#if !defined( __WIN32_VXD__) && !defined(__NT_DRIVER__) - exit(_status); -#endif -} - -void _CDECL stub_free(void *_ptr) -{ __PM_free(_ptr); } - -char * _CDECL stub_getenv(const char *_name) -{ -#if defined( __WIN32_VXD__) || defined(__NT_DRIVER__) - return NULL; -#else - return getenv(_name); -#endif -} - -void * _CDECL stub_malloc(size_t _size) -{ return __PM_malloc(_size); } - -void * _CDECL stub_realloc(void *_ptr, size_t _size) -{ return __PM_realloc(_ptr,_size); } - -int _CDECL stub_system(const char *_s) -{ -#if defined(__WINDOWS__) || defined(__WIN32_VXD__) || defined(__NT_DRIVER__) || defined(__SMX32__) || defined(__RTTARGET__) - (void)_s; - return -1; -#else - return system(_s); -#endif -} - -int _CDECL stub_putenv(const char *_val) -{ -#if defined( __WIN32_VXD__) || defined(__NT_DRIVER__) - return -1; -#else - return putenv((char*)_val); -#endif -} - -time_t _CDECL stub_time(time_t *_tod) -{ -#if defined( __WIN32_VXD__) || defined(__NT_DRIVER__) - return 0; -#else - return time(_tod); -#endif -} - -#if defined(__MSDOS__) - -#if defined(TNT) && defined(_MSC_VER) - -void _CDECL _OS_setfileattr(const char *filename,unsigned attrib) -{ SetFileAttributes((LPSTR)filename, (DWORD)attrib); } - -#else - -void _CDECL _OS_setfileattr(const char *filename,unsigned attrib) -{ _dos_setfileattr(filename,attrib); } - -#endif - -#elif defined(__WIN32_VXD__) - -#define USE_LOCAL_FILEIO -#define USE_LOCAL_GETDATE - -/* stub functions */ -int _CDECL stub_open(const char *_path, int _oflag, unsigned _mode) -{ - char mode[10]; - int i; - - /* Find an empty file handle to use */ - for (i = 3; i < MAX_FILES; i++) { - if (!openHandles[i]) - break; - } - if (openHandles[i]) - return -1; - - /* Find the open flags to use */ - if (_oflag & ___O_TRUNC) - strcpy(mode,"w"); - else if (_oflag & ___O_CREAT) - strcpy(mode,"a"); - else - strcpy(mode,"r"); - if (_oflag & ___O_BINARY) - strcat(mode,"b"); - if (_oflag & ___O_TEXT) - strcat(mode,"t"); - - /* Open the file and store the file handle */ - if ((openHandles[i] = fopen(_path,mode)) == NULL) - return -1; - return i; -} - -int _CDECL stub_access(const char *_path, int _amode) -{ return -1; } - -int _CDECL stub_close(int _fildes) -{ - if (_fildes >= 3 && openHandles[_fildes]) { - fclose(openHandles[_fildes]); - openHandles[_fildes] = NULL; - } - return 0; -} - -off_t _CDECL stub_lseek(int _fildes, off_t _offset, int _whence) -{ - if (_fildes >= 3) { - fseek(openHandles[_fildes],_offset,_whence); - return ftell(openHandles[_fildes]); - } - return 0; -} - -size_t _CDECL stub_read(int _fildes, void *_buf, size_t _nbyte) -{ - if (_fildes >= 3) - return fread(_buf,1,_nbyte,openHandles[_fildes]); - return 0; -} - -int _CDECL stub_unlink(const char *_path) -{ - WORD error; - - if (initComplete) { - if (R0_DeleteFile((char*)_path,0,&error)) - return 0; - return -1; - } - else - return i_remove(_path); -} - -size_t _CDECL stub_write(int _fildes, const void *_buf, size_t _nbyte) -{ - if (_fildes >= 3) - return fwrite(_buf,1,_nbyte,openHandles[_fildes]); - return _nbyte; -} - -int _CDECL stub_isatty(int _fildes) -{ return 0; } - -/* stub functions */ -int _CDECL stub_remove(const char *_filename) -{ return stub_unlink(_filename); } - -int _CDECL stub_rename(const char *_old, const char *_new) -{ return -1; } - -void _CDECL _OS_setfileattr(const char *filename,unsigned attrib) -{ - WORD error; - if (initComplete) - R0_SetFileAttributes((char*)filename,attrib,&error); -} - -/* Return the current date in days since 1/1/1980 */ -ulong _CDECL _OS_getcurrentdate(void) -{ - DWORD date; - VTD_Get_Date_And_Time(&date); - return date; -} - -#elif defined(__NT_DRIVER__) - -#define USE_LOCAL_FILEIO -#define USE_LOCAL_GETDATE - -/* stub functions */ -int _CDECL stub_open(const char *_path, int _oflag, unsigned _mode) -{ - char mode[10]; - int i; - - /* Find an empty file handle to use */ - for (i = 3; i < MAX_FILES; i++) { - if (!openHandles[i]) - break; - } - if (openHandles[i]) - return -1; - - /* Find the open flags to use */ - if (_oflag & ___O_TRUNC) - strcpy(mode,"w"); - else if (_oflag & ___O_CREAT) - strcpy(mode,"a"); - else - strcpy(mode,"r"); - if (_oflag & ___O_BINARY) - strcat(mode,"b"); - if (_oflag & ___O_TEXT) - strcat(mode,"t"); - - /* Open the file and store the file handle */ - if ((openHandles[i] = fopen(_path,mode)) == NULL) - return -1; - return i; -} - -int _CDECL stub_close(int _fildes) -{ - if (_fildes >= 3 && openHandles[_fildes]) { - fclose(openHandles[_fildes]); - openHandles[_fildes] = NULL; - } - return 0; -} - -off_t _CDECL stub_lseek(int _fildes, off_t _offset, int _whence) -{ - if (_fildes >= 3) { - fseek(openHandles[_fildes],_offset,_whence); - return ftell(openHandles[_fildes]); - } - return 0; -} - -size_t _CDECL stub_read(int _fildes, void *_buf, size_t _nbyte) -{ - if (_fildes >= 3) - return fread(_buf,1,_nbyte,openHandles[_fildes]); - return 0; -} - -size_t _CDECL stub_write(int _fildes, const void *_buf, size_t _nbyte) -{ - if (_fildes >= 3) - return fwrite(_buf,1,_nbyte,openHandles[_fildes]); - return _nbyte; -} - -int _CDECL stub_access(const char *_path, int _amode) -{ return -1; } - -int _CDECL stub_isatty(int _fildes) -{ return 0; } - -int _CDECL stub_unlink(const char *_path) -{ - /* TODO: Implement this! */ - return -1; -} - -/* stub functions */ -int _CDECL stub_remove(const char *_filename) -{ return stub_unlink(_filename); } - -int _CDECL stub_rename(const char *_old, const char *_new) -{ - /* TODO: Implement this! */ - return -1; -} - -void _CDECL _OS_setfileattr(const char *filename,unsigned attrib) -{ - uint _attr = 0; - if (attrib & __A_RDONLY) - _attr |= FILE_ATTRIBUTE_READONLY; - if (attrib & __A_HIDDEN) - _attr |= FILE_ATTRIBUTE_HIDDEN; - if (attrib & __A_SYSTEM) - _attr |= FILE_ATTRIBUTE_SYSTEM; - PM_setFileAttr(filename,_attr); -} - -/* Return the current date in days since 1/1/1980 */ -ulong _CDECL _OS_getcurrentdate(void) -{ - TIME_FIELDS tm; - _int64 count,count_1_1_1980; - - tm.Year = 1980; - tm.Month = 1; - tm.Day = 1; - tm.Hour = 0; - tm.Minute = 0; - tm.Second = 0; - tm.Milliseconds = 0; - tm.Weekday = 0; - RtlTimeFieldsToTime(&tm,(PLARGE_INTEGER)&count_1_1_1980); - KeQuerySystemTime((PLARGE_INTEGER)&count); - return (ulong)( (count - count_1_1_1980) / ((_int64)24 * (_int64)3600 * (_int64)10000000) ); -} - -#elif defined(__WINDOWS32__) || defined(__RTTARGET__) - -void _CDECL _OS_setfileattr(const char *filename,unsigned attrib) -{ SetFileAttributes((LPSTR)filename, (DWORD)attrib); } - -#elif defined(__OS2__) - -#define USE_LOCAL_FILEIO - -#ifndef W_OK -#define W_OK 0x02 -#endif - -void _CDECL _OS_setfileattr(const char *filename,unsigned attrib) -{ - FILESTATUS3 s; - if (DosQueryPathInfo((PSZ)filename,FIL_STANDARD,(PVOID)&s,sizeof(s))) - return; - s.attrFile = attrib; - DosSetPathInfo((PSZ)filename,FIL_STANDARD,(PVOID)&s,sizeof(s),0L); -} - -/* stub functions */ - -#define BUF_SIZE 4096 - -/* Note: the implementation of the standard Unix-ish handle-based I/O isn't - * complete - but that wasn't the intent either. Note also that we - * don't presently support text file I/O, so all text files end - * up in Unix format (and are not translated!). - */ -int _CDECL stub_open(const char *_path, int _oflag, unsigned _mode) -{ - HFILE handle; - ULONG error, actiontaken, openflag, openmode; - char path[PM_MAX_PATH]; - - /* Determine open flags */ - if (_oflag & ___O_CREAT) { - if (_oflag & ___O_EXCL) - openflag = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; - else if (_oflag & ___O_TRUNC) - openflag = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; - else - openflag = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; - } - else if (_oflag & ___O_TRUNC) - openflag = OPEN_ACTION_REPLACE_IF_EXISTS; - else - openflag = OPEN_ACTION_OPEN_IF_EXISTS; - - /* Determine open mode flags */ - if (_oflag & ___O_RDONLY) - openmode = OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE; - else if (_oflag & ___O_WRONLY) - openmode = OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYWRITE; - else - openmode = OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYWRITE; - - /* Copy the path to a variable on the stack. We need to do this - * for OS/2 as when the drivers are loaded into shared kernel - * memory, we can't pass an address from that memory range to - * this function. - */ - strcpy(path,_path); - if (DosOpen(path, &handle, &actiontaken, 0, FILE_NORMAL, - openflag, openmode, NULL) != NO_ERROR) - return -1; - - /* Handle append mode of operation */ - if (_oflag & ___O_APPEND) { - if (DosSetFilePtr(handle, 0, FILE_END, &error) != NO_ERROR) - return -1; - } - return handle; -} - -int _CDECL stub_access(const char *_path, int _amode) -{ - char path[PM_MAX_PATH]; - FILESTATUS fs; - - /* Copy the path to a variable on the stack. We need to do this - * for OS/2 as when the drivers are loaded into shared kernel - * memory, we can't pass an address from that memory range to - * this function. - */ - strcpy(path,_path); - if (DosQueryPathInfo(path, FIL_STANDARD, &fs, sizeof(fs)) != NO_ERROR) - return -1; - if ((_amode & W_OK) && (fs.attrFile & FILE_READONLY)) - return -1; - return 0; -} - -int _CDECL stub_close(int _fildes) -{ - if (DosClose(_fildes) != NO_ERROR) - return -1; - return 0; -} - -off_t _CDECL stub_lseek(int _fildes, off_t _offset, int _whence) -{ - ULONG cbActual, origin; - - switch (_whence) { - case SEEK_CUR: - origin = FILE_CURRENT; - break; - case SEEK_END: - origin = FILE_END; - break; - default: - origin = FILE_BEGIN; - } - if (DosSetFilePtr(_fildes, _offset, origin, &cbActual) != NO_ERROR) - return -1; - return cbActual; -} - -size_t _CDECL stub_read(int _fildes, void *_buf, size_t _nbyte) -{ - ULONG cbActual = 0,cbRead; - uchar *p = _buf; - uchar file_io_buf[BUF_SIZE]; - - /* We need to perform the physical read in chunks into a - * a temporary static buffer, since the buffer passed in may be - * in kernel space and will cause DosRead to bail internally. - */ - while (_nbyte > BUF_SIZE) { - if (DosRead(_fildes, file_io_buf, BUF_SIZE, &cbRead) != NO_ERROR) - return -1; - cbActual += cbRead; - memcpy(p,file_io_buf,BUF_SIZE); - p += BUF_SIZE; - _nbyte -= BUF_SIZE; - } - if (_nbyte) { - if (DosRead(_fildes, file_io_buf, _nbyte, &cbRead) != NO_ERROR) - return -1; - cbActual += cbRead; - memcpy(p,file_io_buf,_nbyte); - } - return cbActual; -} - -size_t _CDECL stub_write(int _fildes, const void *_buf, size_t _nbyte) -{ - ULONG cbActual = 0,cbWrite; - uchar *p = (PVOID)_buf; - uchar file_io_buf[BUF_SIZE]; - - /* We need to perform the physical write in chunks from a - * a temporary static buffer, since the buffer passed in may be - * in kernel space and will cause DosWrite to bail internally. - */ - while (_nbyte > BUF_SIZE) { - memcpy(file_io_buf,p,BUF_SIZE); - if (DosWrite(_fildes, file_io_buf, BUF_SIZE, &cbWrite) != NO_ERROR) - return -1; - cbActual += cbWrite; - p += BUF_SIZE; - _nbyte -= BUF_SIZE; - } - if (_nbyte) { - memcpy(file_io_buf,p,_nbyte); - if (DosWrite(_fildes, file_io_buf, _nbyte, &cbWrite) != NO_ERROR) - return -1; - cbActual += cbWrite; - } - return cbActual; -} - -int _CDECL stub_unlink(const char *_path) -{ - char path[PM_MAX_PATH]; - - /* Copy the path to a variable on the stack. We need to do this - * for OS/2 as when the drivers are loaded into shared kernel - * memory, we can't pass an address from that memory range to - * this function. - */ - strcpy(path,_path); - if (DosDelete(path) != NO_ERROR) - return -1; - return 0; -} - -int _CDECL stub_isatty(int _fildes) -{ - ULONG htype, flags; - - if (DosQueryHType(_fildes, &htype, &flags) != NO_ERROR) - return 0; - return ((htype & 0xFF) == HANDTYPE_DEVICE); -} - -/* stub functions */ -int _CDECL stub_remove(const char *_path) -{ - char path[PM_MAX_PATH]; - - /* Copy the path to a variable on the stack. We need to do this - * for OS/2 as when the drivers are loaded into shared kernel - * memory, we can't pass an address from that memory range to - * this function. - */ - strcpy(path,_path); - if (DosDelete(path) != NO_ERROR) - return -1; - return 0; -} - -int _CDECL stub_rename(const char *_old, const char *_new) -{ - char old[PM_MAX_PATH]; - char new[PM_MAX_PATH]; - - /* Copy the path to a variable on the stack. We need to do this - * for OS/2 as when the drivers are loaded into shared kernel - * memory, we can't pass an address from that memory range to - * this function. - */ - strcpy(old,_old); - strcpy(new,_new); - if (DosMove(old, new) != NO_ERROR) - return -1; - return 0; -} - -#else - -void _CDECL _OS_setfileattr(const char *filename,unsigned attrib) -{ /* Unable to set hidden, system attributes on Unix. */ } - -#endif - -#ifndef USE_LOCAL_FILEIO - -/* stub functions */ -int _CDECL stub_open(const char *_path, int _oflag, unsigned _mode) -{ - int oflag_tab[] = { - ___O_RDONLY, O_RDONLY, - ___O_WRONLY, O_WRONLY, - ___O_RDWR, O_RDWR, - ___O_BINARY, O_BINARY, - ___O_TEXT, O_TEXT, - ___O_CREAT, O_CREAT, - ___O_EXCL, O_EXCL, - ___O_TRUNC, O_TRUNC, - ___O_APPEND, O_APPEND, - }; - int i,oflag = 0; - - /* Translate the oflag's to the OS dependent versions */ - for (i = 0; i < sizeof(oflag_tab) / sizeof(int); i += 2) { - if (_oflag & oflag_tab[i]) - oflag |= oflag_tab[i+1]; - } - return open(_path,oflag,_mode); -} - -int _CDECL stub_access(const char *_path, int _amode) -{ return access(_path,_amode); } - -int _CDECL stub_close(int _fildes) -{ return close(_fildes); } - -off_t _CDECL stub_lseek(int _fildes, off_t _offset, int _whence) -{ return lseek(_fildes,_offset,_whence); } - -size_t _CDECL stub_read(int _fildes, void *_buf, size_t _nbyte) -{ return read(_fildes,_buf,_nbyte); } - -int _CDECL stub_unlink(const char *_path) -{ return unlink(_path); } - -size_t _CDECL stub_write(int _fildes, const void *_buf, size_t _nbyte) -{ return write(_fildes,_buf,_nbyte); } - -int _CDECL stub_isatty(int _fildes) -{ return isatty(_fildes); } - -/* stub functions */ -int _CDECL stub_remove(const char *_filename) -{ return remove(_filename); } - -int _CDECL stub_rename(const char *_old, const char *_new) -{ return rename(_old,_new); } - -#endif - -#ifndef USE_LOCAL_GETDATE - -/* Return the current date in days since 1/1/1980 */ -ulong _CDECL _OS_getcurrentdate(void) -{ - struct tm refTime; - refTime.tm_year = 80; - refTime.tm_mon = 0; - refTime.tm_mday = 1; - refTime.tm_hour = 0; - refTime.tm_min = 0; - refTime.tm_sec = 0; - refTime.tm_isdst = -1; - return (time(NULL) - mktime(&refTime)) / (24 * 3600L); -} - -#endif - -int _CDECL stub_raise(int sig) -{ -#if defined(__WIN32_VXD__) || defined(__NT_DRIVER__) || defined(__SMX32__) - return -1; -#else - return raise(sig); -#endif -} - -#ifdef __WINDOWS32__ -typedef void (*__code_ptr)(int); -#else -typedef void (*__code_ptr)(); -#endif - -void * _CDECL stub_signal(int sig, void *handler) -{ -#if defined(__WIN32_VXD__) || defined(__NT_DRIVER__) || defined(__SMX32__) - return NULL; -#else - return (void*)signal(sig,(__code_ptr)handler); -#endif -} diff --git a/board/MAI/bios_emulator/scitech/src/common/makefile b/board/MAI/bios_emulator/scitech/src/common/makefile deleted file mode 100644 index 5aac0381b3..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/makefile +++ /dev/null @@ -1,18 +0,0 @@ -############################################################################# -# -# Copyright (C) 1996 SciTech Software. -# All rights reserved. -# -# Descripton: Makefile for UniVBE(tm), UniPOWER(tm), UVBELib(tm) and -# DPMSLib library files. Requires Borland C++ 4.52 to build -# some components. -# -# $Date: 2002/10/02 15:35:20 $ $Author: hfrieden $ -# -############################################################################# - -CFLAGS += -DTESTING_GTF - -gtfcalc$E: gtfcalc$O - -.INCLUDE: "$(SCITECH)/makedefs/common.mk" diff --git a/board/MAI/bios_emulator/scitech/src/common/peloader.c b/board/MAI/bios_emulator/scitech/src/common/peloader.c deleted file mode 100644 index a134bb012f..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/peloader.c +++ /dev/null @@ -1,586 +0,0 @@ -/**************************************************************************** -* -* SciTech MGL Graphics Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Module to implement a simple Portable Binary DLL loader -* library. This library can be used to load PE DLL's under -* any Intel based OS, provided the DLL's do not have any -* imports in the import table. -* -* NOTE: This loader module expects the DLL's to be built with -* Watcom C++ and may produce unexpected results with -* DLL's linked by another compiler. -* -****************************************************************************/ - -#include "drvlib/peloader.h" -#include "pmapi.h" -#include "drvlib/os/os.h" -#include "drvlib/libc/init.h" -#if (defined(__WINDOWS32__) || defined(__DRIVER__)) && defined(CHECKED) -#define WIN32_LEAN_AND_MEAN -#define STRICT -#include -#endif -#include "drvlib/pe.h" - -/*--------------------------- Global variables ----------------------------*/ - -static int result = PE_ok; - -/*------------------------- Implementation --------------------------------*/ - -/**************************************************************************** -PARAMETERS: -f - Handle to open file to read driver from -startOffset - Offset to the start of the driver within the file - -RETURNS: -Handle to loaded PE DLL, or NULL on failure. - -REMARKS: -This function loads a Portable Binary DLL library from disk, relocates -the code and returns a handle to the loaded library. This function is the -same as the regular PE_loadLibrary except that it take a handle to an -open file and an offset within that file for the DLL to load. -****************************************************************************/ -static int PE_readHeader( - FILE *f, - long startOffset, - FILE_HDR *filehdr, - OPTIONAL_HDR *opthdr) -{ - EXE_HDR exehdr; - ulong offset,signature; - - /* Read the EXE header and check for valid header signature */ - result = PE_invalidDLLImage; - fseek(f, startOffset, SEEK_SET); - if (fread(&exehdr, 1, sizeof(exehdr), f) != sizeof(exehdr)) - return false; - if (exehdr.signature != 0x5A4D) - return false; - - /* Now seek to the start of the PE header defined at offset 0x3C - * in the MS-DOS EXE header, and read the signature and check it. - */ - fseek(f, startOffset+0x3C, SEEK_SET); - if (fread(&offset, 1, sizeof(offset), f) != sizeof(offset)) - return false; - fseek(f, startOffset+offset, SEEK_SET); - if (fread(&signature, 1, sizeof(signature), f) != sizeof(signature)) - return false; - if (signature != 0x00004550) - return false; - - /* Now read the PE file header and check that it is correct */ - if (fread(filehdr, 1, sizeof(*filehdr), f) != sizeof(*filehdr)) - return false; - if (filehdr->Machine != IMAGE_FILE_MACHINE_I386) - return false; - if (!(filehdr->Characteristics & IMAGE_FILE_32BIT_MACHINE)) - return false; - if (!(filehdr->Characteristics & IMAGE_FILE_DLL)) - return false; - if (fread(opthdr, 1, sizeof(*opthdr), f) != sizeof(*opthdr)) - return false; - if (opthdr->Magic != 0x10B) - return false; - - /* Success, so return true! */ - return true; -} - -/**************************************************************************** -PARAMETERS: -f - Handle to open file to read driver from -startOffset - Offset to the start of the driver within the file - -RETURNS: -Size of the DLL file on disk, or -1 on error - -REMARKS: -This function scans the headers for a Portable Binary DLL to determine the -length of the DLL file on disk. -{secret} -****************************************************************************/ -ulong PEAPI PE_getFileSize( - FILE *f, - ulong startOffset) -{ - FILE_HDR filehdr; - OPTIONAL_HDR opthdr; - SECTION_HDR secthdr; - ulong size; - int i; - - /* Read the PE file headers from disk */ - if (!PE_readHeader(f,startOffset,&filehdr,&opthdr)) - return 0xFFFFFFFF; - - /* Scan all the section headers summing up the total size */ - size = opthdr.SizeOfHeaders; - for (i = 0; i < filehdr.NumberOfSections; i++) { - if (fread(§hdr, 1, sizeof(secthdr), f) != sizeof(secthdr)) - return 0xFFFFFFFF; - size += secthdr.SizeOfRawData; - } - return size; -} - -/**************************************************************************** -DESCRIPTION: -Loads a Portable Binary DLL into memory from an open file - -HEADER: -peloader.h - -PARAMETERS: -f - Handle to open file to read driver from -startOffset - Offset to the start of the driver within the file -size - Place to store the size of the driver loaded -shared - True to load module into shared memory - -RETURNS: -Handle to loaded PE DLL, or NULL on failure. - -REMARKS: -This function loads a Portable Binary DLL library from disk, relocates -the code and returns a handle to the loaded library. This function is the -same as the regular PE_loadLibrary except that it take a handle to an -open file and an offset within that file for the DLL to load. - -SEE ALSO: -PE_loadLibrary, PE_getProcAddress, PE_freeLibrary -****************************************************************************/ -PE_MODULE * PEAPI PE_loadLibraryExt( - FILE *f, - ulong startOffset, - ulong *size, - ibool shared) -{ - FILE_HDR filehdr; - OPTIONAL_HDR opthdr; - SECTION_HDR secthdr; - ulong offset,pageOffset; - ulong text_off,text_addr,text_size; - ulong data_off,data_addr,data_size,data_end; - ulong export_off,export_addr,export_size,export_end; - ulong reloc_off,reloc_size; - ulong image_size; - int i,delta,numFixups; - ushort relocType,*fixup; - PE_MODULE *hMod = NULL; - void *reloc = NULL; - BASE_RELOCATION *baseReloc; - InitLibC_t InitLibC; - - /* Read the PE file headers from disk */ - if (!PE_readHeader(f,startOffset,&filehdr,&opthdr)) - return NULL; - - /* Scan all the section headers and find the necessary sections */ - text_off = data_off = reloc_off = export_off = 0; - text_addr = text_size = 0; - data_addr = data_size = data_end = 0; - export_addr = export_size = export_end = 0; - reloc_size = 0; - for (i = 0; i < filehdr.NumberOfSections; i++) { - if (fread(§hdr, 1, sizeof(secthdr), f) != sizeof(secthdr)) - goto Error; - if (strcmp(secthdr.Name, ".edata") == 0 || strcmp(secthdr.Name, ".rdata") == 0) { - /* Exports section */ - export_off = secthdr.PointerToRawData; - export_addr = secthdr.VirtualAddress; - export_size = secthdr.SizeOfRawData; - export_end = export_addr + export_size; - } - else if (strcmp(secthdr.Name, ".idata") == 0) { - /* Imports section, ignore */ - } - else if (strcmp(secthdr.Name, ".reloc") == 0) { - /* Relocations section */ - reloc_off = secthdr.PointerToRawData; - reloc_size = secthdr.SizeOfRawData; - } - else if (!text_off && secthdr.Characteristics & IMAGE_SCN_CNT_CODE) { - /* Code section */ - text_off = secthdr.PointerToRawData; - text_addr = secthdr.VirtualAddress; - text_size = secthdr.SizeOfRawData; - } - else if (!data_off && secthdr.Characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA) { - /* Data section */ - data_off = secthdr.PointerToRawData; - data_addr = secthdr.VirtualAddress; - data_size = secthdr.SizeOfRawData; - data_end = data_addr + data_size; - } - } - - /* Check to make sure that we have all the sections we need */ - if (!text_off || !data_off || !export_off || !reloc_off) { - result = PE_invalidDLLImage; - goto Error; - } - - /* Find the size of the image to load allocate memory for it */ - image_size = MAX(export_end,data_end) - text_addr; - *size = sizeof(PE_MODULE) + image_size + 4096; - if (shared) - hMod = PM_mallocShared(*size); - else - hMod = PM_malloc(*size); - reloc = PM_malloc(reloc_size); - if (!hMod || !reloc) { - result = PE_outOfMemory; - goto Error; - } - - hMod->text = (uchar*)ROUND_4K((ulong)hMod + sizeof(PE_MODULE)); - hMod->data = (uchar*)((ulong)hMod->text + (data_addr - text_addr)); - hMod->export = (uchar*)((ulong)hMod->text + (export_addr - text_addr)); - hMod->textBase = text_addr; - hMod->dataBase = data_addr; - hMod->exportBase = export_addr; - hMod->exportDir = opthdr.DataDirectory[0].RelVirtualAddress - export_addr; - hMod->shared = shared; - - /* Now read the section images from disk */ - result = PE_invalidDLLImage; - fseek(f, startOffset+text_off, SEEK_SET); - if (fread(hMod->text, 1, text_size, f) != text_size) - goto Error; - fseek(f, startOffset+data_off, SEEK_SET); - if (fread(hMod->data, 1, data_size, f) != data_size) - goto Error; - fseek(f, startOffset+export_off, SEEK_SET); - if (fread(hMod->export, 1, export_size, f) != export_size) - goto Error; - fseek(f, startOffset+reloc_off, SEEK_SET); - if (fread(reloc, 1, reloc_size, f) != reloc_size) - goto Error; - - /* Now perform relocations on all sections in the image */ - delta = (ulong)hMod->text - opthdr.ImageBase - text_addr; - baseReloc = (BASE_RELOCATION*)reloc; - for (;;) { - /* Check for termination condition */ - if (!baseReloc->PageRVA || !baseReloc->BlockSize) - break; - - /* Do fixups */ - pageOffset = baseReloc->PageRVA - hMod->textBase; - numFixups = (baseReloc->BlockSize - sizeof(BASE_RELOCATION)) / sizeof(ushort); - fixup = (ushort*)(baseReloc + 1); - for (i = 0; i < numFixups; i++) { - relocType = *fixup >> 12; - if (relocType) { - offset = pageOffset + (*fixup & 0x0FFF); - *(ulong*)(hMod->text + offset) += delta; - } - fixup++; - } - - /* Move to next relocation block */ - baseReloc = (BASE_RELOCATION*)((ulong)baseReloc + baseReloc->BlockSize); - } - - /* Initialise the C runtime library for the loaded DLL */ - result = PE_unableToInitLibC; - if ((InitLibC = (InitLibC_t)PE_getProcAddress(hMod,"_InitLibC")) == NULL) - goto Error; - if (!InitLibC(&___imports,PM_getOSType())) - goto Error; - - /* Clean up, close the file and return the loaded module handle */ - PM_free(reloc); - result = PE_ok; - return hMod; - -Error: - if (shared) - PM_freeShared(hMod); - else - PM_free(hMod); - PM_free(reloc); - return NULL; -} - -/**************************************************************************** -DESCRIPTION: -Loads a Portable Binary DLL into memory - -HEADER: -peloader.h - -PARAMETERS: -szDLLName - Name of the PE DLL library to load -shared - True to load module into shared memory - -RETURNS: -Handle to loaded PE DLL, or NULL on failure. - -REMARKS: -This function loads a Portable Binary DLL library from disk, relocates -the code and returns a handle to the loaded library. This function -will only work on DLL's that do not have any imports, since we don't -resolve import dependencies in this function. - -SEE ALSO: -PE_getProcAddress, PE_freeLibrary -****************************************************************************/ -PE_MODULE * PEAPI PE_loadLibrary( - const char *szDLLName, - ibool shared) -{ - PE_MODULE *hMod; - -#if (defined(__WINDOWS32__) || defined(__DRIVER__)) && defined(CHECKED) - if (!shared) { - PM_MODULE hInst; - InitLibC_t InitLibC; - - /* For Win32 if are building checked libraries for debugging, we use - * the real Win32 DLL functions so that we can debug the resulting DLL - * files with the Win32 debuggers. Note that we can't do this if - * we need to load the files into a shared memory context. - */ - if ((hInst = PM_loadLibrary(szDLLName)) == NULL) { - result = PE_fileNotFound; - return NULL; - } - - /* Initialise the C runtime library for the loaded DLL */ - result = PE_unableToInitLibC; - if ((InitLibC = (void*)PM_getProcAddress(hInst,"_InitLibC")) == NULL) - return NULL; - if (!InitLibC(&___imports,PM_getOSType())) - return NULL; - - /* Allocate the PE_MODULE structure */ - if ((hMod = PM_malloc(sizeof(*hMod))) == NULL) - return NULL; - hMod->text = (void*)hInst; - hMod->shared = -1; - - /* DLL loaded successfully so return module handle */ - result = PE_ok; - return hMod; - } - else -#endif - { - FILE *f; - ulong size; - - /* Attempt to open the file on disk */ - if (shared < 0) - shared = 0; - if ((f = fopen(szDLLName,"rb")) == NULL) { - result = PE_fileNotFound; - return NULL; - } - hMod = PE_loadLibraryExt(f,0,&size,shared); - fclose(f); - return hMod; - } -} - -/**************************************************************************** -DESCRIPTION: -Loads a Portable Binary DLL into memory - -HEADER: -peloader.h - -PARAMETERS: -szDLLName - Name of the PE DLL library to load -shared - True to load module into shared memory - -RETURNS: -Handle to loaded PE DLL, or NULL on failure. - -REMARKS: -This function is the same as the regular PE_loadLibrary function, except -that it looks for the drivers in the MGL_ROOT/drivers directory or a -/drivers directory relative to the current directory. - -SEE ALSO: -PE_loadLibraryMGL, PE_getProcAddress, PE_freeLibrary -****************************************************************************/ -PE_MODULE * PEAPI PE_loadLibraryMGL( - const char *szDLLName, - ibool shared) -{ -#if !defined(__WIN32_VXD__) && !defined(__NT_DRIVER__) - PE_MODULE *hMod; -#endif - char path[256] = ""; - - /* We look in the 'drivers' directory, optionally under the MGL_ROOT - * environment variable directory. - */ -#if !defined(__WIN32_VXD__) && !defined(__NT_DRIVER__) - if (getenv("MGL_ROOT")) { - strcpy(path,getenv("MGL_ROOT")); - PM_backslash(path); - } - strcat(path,"drivers"); - PM_backslash(path); - strcat(path,szDLLName); - if ((hMod = PE_loadLibrary(path,shared)) != NULL) - return hMod; -#endif - strcpy(path,"drivers"); - PM_backslash(path); - strcat(path,szDLLName); - return PE_loadLibrary(path,shared); -} - -/**************************************************************************** -DESCRIPTION: -Gets a function address from a Portable Binary DLL - -HEADER: -peloader.h - -PARAMETERS: -hModule - Handle to a loaded PE DLL library -szProcName - Name of the function to get the address of - -RETURNS: -Pointer to the function, or NULL on failure. - -REMARKS: -This function searches for the named, exported function in a loaded PE -DLL library, and returns the address of the function. If the function is -not found in the library, this function return NULL. - -SEE ALSO: -PE_loadLibrary, PE_freeLibrary -****************************************************************************/ -void * PEAPI PE_getProcAddress( - PE_MODULE *hModule, - const char *szProcName) -{ -#if (defined(__WINDOWS32__) || defined(__DRIVER__)) && defined(CHECKED) - if (hModule->shared == -1) - return (void*)PM_getProcAddress(hModule->text,szProcName); - else -#endif - { - uint i; - EXPORT_DIRECTORY *exports; - ulong funcOffset; - ulong *AddressTable; - ulong *NameTable; - ushort *OrdinalTable; - char *name; - - /* Find the address of the export tables from the export section */ - if (!hModule) - return NULL; - exports = (EXPORT_DIRECTORY*)(hModule->export + hModule->exportDir); - AddressTable = (ulong*)(hModule->export + exports->AddressTableRVA - hModule->exportBase); - NameTable = (ulong*)(hModule->export + exports->NameTableRVA - hModule->exportBase); - OrdinalTable = (ushort*)(hModule->export + exports->OrdinalTableRVA - hModule->exportBase); - - /* Search the export name table to find the function name */ - for (i = 0; i < exports->NumberOfNamePointers; i++) { - name = (char*)(hModule->export + NameTable[i] - hModule->exportBase); - if (strcmp(name,szProcName) == 0) - break; - } - if (i == exports->NumberOfNamePointers) - return NULL; - funcOffset = AddressTable[OrdinalTable[i]]; - if (!funcOffset) - return NULL; - return (void*)(hModule->text + funcOffset - hModule->textBase); - } -} - -/**************************************************************************** -DESCRIPTION: -Frees a loaded Portable Binary DLL - -HEADER: -peloader.h - -PARAMETERS: -hModule - Handle to a loaded PE DLL library to free - -REMARKS: -This function frees a loaded PE DLL library from memory. - -SEE ALSO: -PE_getProcAddress, PE_loadLibrary -****************************************************************************/ -void PEAPI PE_freeLibrary( - PE_MODULE *hModule) -{ - TerminateLibC_t TerminateLibC; - -#if (defined(__WINDOWS32__) || defined(__DRIVER__)) && defined(CHECKED) - if (hModule->shared == -1) { - /* Run the C runtime library exit code on module unload */ - if ((TerminateLibC = (TerminateLibC_t)PM_getProcAddress(hModule->text,"_TerminateLibC")) != NULL) - TerminateLibC(); - PM_freeLibrary(hModule->text); - PM_free(hModule); - } - else -#endif - { - if (hModule) { - /* Run the C runtime library exit code on module unload */ - if ((TerminateLibC = (TerminateLibC_t)PE_getProcAddress(hModule,"_TerminateLibC")) != NULL) - TerminateLibC(); - if (hModule->shared) - PM_freeShared(hModule); - else - PM_free(hModule); - } - } -} - -/**************************************************************************** -DESCRIPTION: -Returns the error code for the last operation - -HEADER: -peloader.h - -RETURNS: -Error code for the last operation. - -SEE ALSO: -PE_getProcAddress, PE_loadLibrary -****************************************************************************/ -int PEAPI PE_getError(void) -{ - return result; -} diff --git a/board/MAI/bios_emulator/scitech/src/common/vesavbe.c b/board/MAI/bios_emulator/scitech/src/common/vesavbe.c deleted file mode 100644 index a669e5c292..0000000000 --- a/board/MAI/bios_emulator/scitech/src/common/vesavbe.c +++ /dev/null @@ -1,1214 +0,0 @@ -/**************************************************************************** -* -* The SuperVGA Kit - UniVBE Software Development Kit -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: IBM PC Real Mode and 16/32 bit Protected Mode. -* -* Description: Module to implement a C callable interface to the standard -* VESA VBE routines. You should rip out this module and use it -* directly in your own applications, or you can use the -* high level SDK functions. -* -* MUST be compiled in the LARGE or FLAT models. -* -****************************************************************************/ - -#include -#include -#include -#include "vesavbe.h" -#include "pmapi.h" -#include "drvlib/os/os.h" - -/*---------------------------- Global Variables ---------------------------*/ - -#define VBE_SUCCESS 0x004F -#define MAX_LIN_PTRS 10 - -static uint VESABuf_len = 1024;/* Length of the VESABuf buffer */ -static ibool haveRiva128; /* True if we have a Riva128 */ -static VBE_state defState = {0}; /* Default state buffer */ -static VBE_state *state = &defState; /* Pointer to current buffer */ -static int VBE_shared = 0; -#ifndef REALMODE -static char localBuf[512]; /* Global PM string translate buf */ -#define MAX_LOCAL_BUF &localBuf[511] -#endif - -/*----------------------------- Implementation ----------------------------*/ - -/* static function in WinDirect for passing 32-bit registers to BIOS */ -int PMAPI WD_int386(int intno, RMREGS *in, RMREGS *out); - -void VBEAPI VBE_init(void) -/**************************************************************************** -* -* Function: VBE_init -* -* Description: Initialises the VBE transfer buffer in real mode DC.memory. -* This routine is called by the VESAVBE module every time -* it needs to use the transfer buffer, so we simply allocate -* it once and then return. -* -****************************************************************************/ -{ - if (!state->VESABuf_ptr) { - /* Allocate a global buffer for communicating with the VESA VBE */ - if ((state->VESABuf_ptr = PM_getVESABuf(&VESABuf_len, &state->VESABuf_rseg, &state->VESABuf_roff)) == NULL) - PM_fatalError("VESAVBE.C: Real mode memory allocation failed!"); - } -} - -void * VBEAPI VBE_getRMBuf(uint *len,uint *rseg,uint *roff) -/**************************************************************************** -* -* Function: VBE_getRMBuf -* -* Description: This function returns the location and length of the real -* mode memory buffer for calling real mode functions. -* -****************************************************************************/ -{ - *len = VESABuf_len; - *rseg = state->VESABuf_rseg; - *roff = state->VESABuf_roff; - return state->VESABuf_ptr; -} - -void VBEAPI VBE_setStateBuffer(VBE_state *s) -/**************************************************************************** -* -* Function: VBE_setStateBuffer -* -* Description: This functions sets the internal state buffer for the -* VBE module to the passed in buffer. By default the internal -* global buffer is used, but you must use separate buffers -* for each device in a multi-controller environment. -* -****************************************************************************/ -{ - state = s; -} - -void VBEAPI VBE_callESDI(RMREGS *regs, void *buffer, int size) -/**************************************************************************** -* -* Function: VBE_callESDI -* Parameters: regs - Registers to load when calling VBE -* buffer - Buffer to copy VBE info block to -* size - Size of buffer to fill -* -* Description: Calls the VESA VBE and passes in a buffer for the VBE to -* store information in, which is then copied into the users -* buffer space. This works in protected mode as the buffer -* passed to the VESA VBE is allocated in conventional -* memory, and is then copied into the users memory block. -* -****************************************************************************/ -{ - RMSREGS sregs; - - if (!state->VESABuf_ptr) - PM_fatalError("You *MUST* call VBE_init() before you can call the VESAVBE.C module!"); - sregs.es = (ushort)state->VESABuf_rseg; - regs->x.di = (ushort)state->VESABuf_roff; - memcpy(state->VESABuf_ptr, buffer, size); - PM_int86x(0x10, regs, regs, &sregs); - memcpy(buffer, state->VESABuf_ptr, size); -} - -#ifndef REALMODE -static char *VBE_copyStrToLocal(char *p,char *realPtr,char *max) -/**************************************************************************** -* -* Function: VBE_copyStrToLocal -* Parameters: p - Flat model buffer to copy to -* realPtr - Real mode pointer to copy -* Returns: Pointer to the next byte after string -* -* Description: Copies the string from the real mode location pointed to -* by 'realPtr' into the flat model buffer pointed to by -* 'p'. We return a pointer to the next byte past the copied -* string. -* -****************************************************************************/ -{ - uchar *v; - - v = PM_mapRealPointer((uint)((ulong)realPtr >> 16), (uint)((ulong)realPtr & 0xFFFF)); - while (*v != 0 && p < max) - *p++ = *v++; - *p++ = 0; - return p; -} - -static void VBE_copyShortToLocal(ushort *p,ushort *realPtr) -/**************************************************************************** -* -* Function: VBE_copyShortToLocal -* Parameters: p - Flat model buffer to copy to -* realPtr - Real mode pointer to copy -* -* Description: Copies the mode table from real mode memory to the flat -* model buffer. -* -****************************************************************************/ -{ - ushort *v; - - v = PM_mapRealPointer((uint)((ulong)realPtr >> 16),(uint)((ulong)realPtr & 0xFFFF)); - while (*v != 0xFFFF) - *p++ = *v++; - *p = 0xFFFF; -} -#endif - -int VBEAPI VBE_detectEXT(VBE_vgaInfo *vgaInfo,ibool forceUniVBE) -/**************************************************************************** -* -* Function: VBE_detect -* Parameters: vgaInfo - Place to store the VGA information block -* Returns: VBE version number, or 0 if not detected. -* -* Description: Detects if a VESA VBE is out there and functioning -* correctly. If we detect a VBE interface we return the -* VGAInfoBlock returned by the VBE and the VBE version number. -* -****************************************************************************/ -{ - RMREGS regs; - - regs.x.ax = 0x4F00; /* Get SuperVGA information */ - if (forceUniVBE) { - regs.x.bx = 0x1234; - regs.x.cx = 0x4321; - } - else { - regs.x.bx = 0; - regs.x.cx = 0; - } - strncpy(vgaInfo->VESASignature,"VBE2",4); - VBE_callESDI(®s, vgaInfo, sizeof(*vgaInfo)); - if (regs.x.ax != VBE_SUCCESS) - return 0; - if (strncmp(vgaInfo->VESASignature,"VESA",4) != 0) - return 0; - - /* Check for bogus BIOSes that return a VBE version number that is - * not correct, and fix it up. We also check the OemVendorNamePtr for a - * valid value, and if it is invalid then we also reset to VBE 1.2. - */ - if (vgaInfo->VESAVersion >= 0x200 && vgaInfo->OemVendorNamePtr == 0) - vgaInfo->VESAVersion = 0x102; -#ifndef REALMODE - /* Relocate all the indirect information (mode tables, OEM strings - * etc) from the low 1Mb memory region into a static buffer in - * our default data segment. We do this to insulate the application - * from mapping the strings from real mode to protected mode. - */ - { - char *p,*p2; - p2 = VBE_copyStrToLocal(localBuf,vgaInfo->OemStringPtr,MAX_LOCAL_BUF); - vgaInfo->OemStringPtr = localBuf; - if (vgaInfo->VESAVersion >= 0x200) { - p = VBE_copyStrToLocal(p2,vgaInfo->OemVendorNamePtr,MAX_LOCAL_BUF); - vgaInfo->OemVendorNamePtr = p2; - p2 = VBE_copyStrToLocal(p,vgaInfo->OemProductNamePtr,MAX_LOCAL_BUF); - vgaInfo->OemProductNamePtr = p; - p = VBE_copyStrToLocal(p2,vgaInfo->OemProductRevPtr,MAX_LOCAL_BUF); - vgaInfo->OemProductRevPtr = p2; - VBE_copyShortToLocal((ushort*)p,vgaInfo->VideoModePtr); - vgaInfo->VideoModePtr = (ushort*)p; - } - else { - VBE_copyShortToLocal((ushort*)p2,vgaInfo->VideoModePtr); - vgaInfo->VideoModePtr = (ushort*)p2; - } - } -#endif - state->VBEMemory = vgaInfo->TotalMemory * 64; - - /* Check for Riva128 based cards since they have broken triple buffering - * and stereo support. - */ - haveRiva128 = false; - if (vgaInfo->VESAVersion >= 0x300 && - (strstr(vgaInfo->OemStringPtr,"NVidia") != NULL || - strstr(vgaInfo->OemStringPtr,"Riva") != NULL)) { - haveRiva128 = true; - } - - /* Check for Matrox G400 cards which claim to be VBE 3.0 - * compliant yet they don't implement the refresh rate control - * functions. - */ - if (vgaInfo->VESAVersion >= 0x300 && (strcmp(vgaInfo->OemProductNamePtr,"Matrox G400") == 0)) - vgaInfo->VESAVersion = 0x200; - return (state->VBEVersion = vgaInfo->VESAVersion); -} - -int VBEAPI VBE_detect(VBE_vgaInfo *vgaInfo) -/**************************************************************************** -* -* Function: VBE_detect -* Parameters: vgaInfo - Place to store the VGA information block -* Returns: VBE version number, or 0 if not detected. -* -* Description: Detects if a VESA VBE is out there and functioning -* correctly. If we detect a VBE interface we return the -* VGAInfoBlock returned by the VBE and the VBE version number. -* -****************************************************************************/ -{ - return VBE_detectEXT(vgaInfo,false); -} - -ibool VBEAPI VBE_getModeInfo(int mode,VBE_modeInfo *modeInfo) -/**************************************************************************** -* -* Function: VBE_getModeInfo -* Parameters: mode - VBE mode to get information for -* modeInfo - Place to store VBE mode information -* Returns: True on success, false if function failed. -* -* Description: Obtains information about a specific video mode from the -* VBE. You should use this function to find the video mode -* you wish to set, as the new VBE 2.0 mode numbers may be -* completely arbitrary. -* -****************************************************************************/ -{ - RMREGS regs; - int bits; - - regs.x.ax = 0x4F01; /* Get mode information */ - regs.x.cx = (ushort)mode; - VBE_callESDI(®s, modeInfo, sizeof(*modeInfo)); - if (regs.x.ax != VBE_SUCCESS) - return false; - if ((modeInfo->ModeAttributes & vbeMdAvailable) == 0) - return false; - - /* Map out triple buffer and stereo flags for NVidia Riva128 - * chips. - */ - if (haveRiva128) { - modeInfo->ModeAttributes &= ~vbeMdTripleBuf; - modeInfo->ModeAttributes &= ~vbeMdStereo; - } - - /* Support old style RGB definitions for VBE 1.1 BIOSes */ - bits = modeInfo->BitsPerPixel; - if (modeInfo->MemoryModel == vbeMemPK && bits > 8) { - modeInfo->MemoryModel = vbeMemRGB; - switch (bits) { - case 15: - modeInfo->RedMaskSize = 5; - modeInfo->RedFieldPosition = 10; - modeInfo->GreenMaskSize = 5; - modeInfo->GreenFieldPosition = 5; - modeInfo->BlueMaskSize = 5; - modeInfo->BlueFieldPosition = 0; - modeInfo->RsvdMaskSize = 1; - modeInfo->RsvdFieldPosition = 15; - break; - case 16: - modeInfo->RedMaskSize = 5; - modeInfo->RedFieldPosition = 11; - modeInfo->GreenMaskSize = 5; - modeInfo->GreenFieldPosition = 5; - modeInfo->BlueMaskSize = 5; - modeInfo->BlueFieldPosition = 0; - modeInfo->RsvdMaskSize = 0; - modeInfo->RsvdFieldPosition = 0; - break; - case 24: - modeInfo->RedMaskSize = 8; - modeInfo->RedFieldPosition = 16; - modeInfo->GreenMaskSize = 8; - modeInfo->GreenFieldPosition = 8; - modeInfo->BlueMaskSize = 8; - modeInfo->BlueFieldPosition = 0; - modeInfo->RsvdMaskSize = 0; - modeInfo->RsvdFieldPosition = 0; - break; - } - } - - /* Convert the 32k direct color modes of VBE 1.2+ BIOSes to - * be recognised as 15 bits per pixel modes. - */ - if (bits == 16 && modeInfo->RsvdMaskSize == 1) - modeInfo->BitsPerPixel = 15; - - /* Fix up bogus BIOS'es that report incorrect reserved pixel masks - * for 32K color modes. Quite a number of BIOS'es have this problem, - * and this affects our OS/2 drivers in VBE fallback mode. - */ - if (bits == 15 && (modeInfo->RsvdMaskSize != 1 || modeInfo->RsvdFieldPosition != 15)) { - modeInfo->RsvdMaskSize = 1; - modeInfo->RsvdFieldPosition = 15; - } - return true; -} - -long VBEAPI VBE_getPageSize(VBE_modeInfo *mi) -/**************************************************************************** -* -* Function: VBE_getPageSize -* Parameters: mi - Pointer to mode information block -* Returns: Caculated page size in bytes rounded to correct boundary -* -* Description: Computes the page size in bytes for the specified mode -* information block, rounded up to the appropriate boundary -* (8k, 16k, 32k or 64k). Pages >= 64k in size are always -* rounded to the nearest 64k boundary (so the start of a -* page is always bank aligned). -* -****************************************************************************/ -{ - long size; - - size = (long)mi->BytesPerScanLine * (long)mi->YResolution; - if (mi->BitsPerPixel == 4) { - /* We have a 16 color video mode, so round up the page size to - * 8k, 16k, 32k or 64k boundaries depending on how large it is. - */ - - size = (size + 0x1FFFL) & 0xFFFFE000L; - if (size != 0x2000) { - size = (size + 0x3FFFL) & 0xFFFFC000L; - if (size != 0x4000) { - size = (size + 0x7FFFL) & 0xFFFF8000L; - if (size != 0x8000) - size = (size + 0xFFFFL) & 0xFFFF0000L; - } - } - } - else size = (size + 0xFFFFL) & 0xFFFF0000L; - return size; -} - -ibool VBEAPI VBE_setVideoModeExt(int mode,VBE_CRTCInfo *crtc) -/**************************************************************************** -* -* Function: VBE_setVideoModeExt -* Parameters: mode - SuperVGA video mode to set. -* Returns: True if the mode was set, false if not. -* -* Description: Attempts to set the specified video mode. This version -* includes support for the VBE/Core 3.0 refresh rate control -* mechanism. -* -****************************************************************************/ -{ - RMREGS regs; - - if (state->VBEVersion < 0x200 && mode < 0x100) { - /* Some VBE implementations barf terribly if you try to set non-VBE - * video modes with the VBE set mode call. VBE 2.0 implementations - * must be able to handle this. - */ - regs.h.al = (ushort)mode; - regs.h.ah = 0; - PM_int86(0x10,®s,®s); - } - else { - if (state->VBEVersion < 0x300 && (mode & vbeRefreshCtrl)) - return false; - regs.x.ax = 0x4F02; - regs.x.bx = (ushort)mode; - if ((mode & vbeRefreshCtrl) && crtc) - VBE_callESDI(®s, crtc, sizeof(*crtc)); - else - PM_int86(0x10,®s,®s); - if (regs.x.ax != VBE_SUCCESS) - return false; - } - return true; -} - -ibool VBEAPI VBE_setVideoMode(int mode) -/**************************************************************************** -* -* Function: VBE_setVideoMode -* Parameters: mode - SuperVGA video mode to set. -* Returns: True if the mode was set, false if not. -* -* Description: Attempts to set the specified video mode. -* -****************************************************************************/ -{ - return VBE_setVideoModeExt(mode,NULL); -} - -int VBEAPI VBE_getVideoMode(void) -/**************************************************************************** -* -* Function: VBE_getVideoMode -* Returns: Current video mode -* -****************************************************************************/ -{ - RMREGS regs; - - regs.x.ax = 0x4F03; - PM_int86(0x10,®s,®s); - if (regs.x.ax != VBE_SUCCESS) - return -1; - return regs.x.bx; -} - -ibool VBEAPI VBE_setBank(int window,int bank) -/**************************************************************************** -* -* Function: VBE_setBank -* Parameters: window - Window to set -* bank - Bank number to set window to -* Returns: True on success, false on failure. -* -****************************************************************************/ -{ - RMREGS regs; - - regs.x.ax = 0x4F05; - regs.h.bh = 0; - regs.h.bl = window; - regs.x.dx = bank; - PM_int86(0x10,®s,®s); - return regs.x.ax == VBE_SUCCESS; -} - -int VBEAPI VBE_getBank(int window) -/**************************************************************************** -* -* Function: VBE_setBank -* Parameters: window - Window to read -* Returns: Bank number for the window (-1 on failure) -* -****************************************************************************/ -{ - RMREGS regs; - - regs.x.ax = 0x4F05; - regs.h.bh = 1; - regs.h.bl = window; - PM_int86(0x10,®s,®s); - if (regs.x.ax != VBE_SUCCESS) - return -1; - return regs.x.dx; -} - -ibool VBEAPI VBE_setPixelsPerLine(int pixelsPerLine,int *newBytes, - int *newPixels,int *maxScanlines) -/**************************************************************************** -* -* Function: VBE_setPixelsPerLine -* Parameters: pixelsPerLine - Pixels per scanline -* newBytes - Storage for bytes per line value set -* newPixels - Storage for pixels per line value set -* maxScanLines - Storage for maximum number of scanlines -* Returns: True on success, false on failure -* -* Description: Sets the scanline length for the video mode to the specified -* number of pixels per scanline. If you need more granularity -* in TrueColor modes, use the VBE_setBytesPerLine routine -* (only valid for VBE 2.0). -* -****************************************************************************/ -{ - RMREGS regs; - - regs.x.ax = 0x4F06; - regs.h.bl = 0; - regs.x.cx = pixelsPerLine; - PM_int86(0x10,®s,®s); - *newBytes = regs.x.bx; - *newPixels = regs.x.cx; - *maxScanlines = regs.x.dx; - return regs.x.ax == VBE_SUCCESS; -} - -ibool VBEAPI VBE_setBytesPerLine(int bytesPerLine,int *newBytes, - int *newPixels,int *maxScanlines) -/**************************************************************************** -* -* Function: VBE_setBytesPerLine -* Parameters: pixelsPerLine - Pixels per scanline -* newBytes - Storage for bytes per line value set -* newPixels - Storage for pixels per line value set -* maxScanLines - Storage for maximum number of scanlines -* Returns: True on success, false on failure -* -* Description: Sets the scanline length for the video mode to the specified -* number of bytes per scanline (valid for VBE 2.0 only). -* -****************************************************************************/ -{ - RMREGS regs; - - regs.x.ax = 0x4F06; - regs.h.bl = 2; - regs.x.cx = bytesPerLine; - PM_int86(0x10,®s,®s); - *newBytes = regs.x.bx; - *newPixels = regs.x.cx; - *maxScanlines = regs.x.dx; - return regs.x.ax == VBE_SUCCESS; -} - -ibool VBEAPI VBE_getScanlineLength(int *bytesPerLine,int *pixelsPerLine, - int *maxScanlines) -/**************************************************************************** -* -* Function: VBE_getScanlineLength -* Parameters: bytesPerLine - Storage for bytes per scanline -* pixelsPerLine - Storage for pixels per scanline -* maxScanLines - Storage for maximum number of scanlines -* Returns: True on success, false on failure -* -****************************************************************************/ -{ - RMREGS regs; - - regs.x.ax = 0x4F06; - regs.h.bl = 1; - PM_int86(0x10,®s,®s); - *bytesPerLine = regs.x.bx; - *pixelsPerLine = regs.x.cx; - *maxScanlines = regs.x.dx; - return regs.x.ax == VBE_SUCCESS; -} - -ibool VBEAPI VBE_getMaxScanlineLength(int *maxBytes,int *maxPixels) -/**************************************************************************** -* -* Function: VBE_getMaxScanlineLength -* Parameters: maxBytes - Maximum scanline width in bytes -* maxPixels - Maximum scanline width in pixels -* Returns: True if successful, false if function failed -* -****************************************************************************/ -{ - RMREGS regs; - - regs.x.ax = 0x4F06; - regs.h.bl = 3; - PM_int86(0x10,®s,®s); - *maxBytes = regs.x.bx; - *maxPixels = regs.x.cx; - return regs.x.ax == VBE_SUCCESS; -} - -ibool VBEAPI VBE_setDisplayStart(int x,int y,ibool waitVRT) -/**************************************************************************** -* -* Function: VBE_setDisplayStart -* Parameters: x,y - Position of the first pixel to display -* waitVRT - True to wait for retrace, false if not -* Returns: True if function was successful. -* -* Description: Sets the new starting display position to implement -* hardware scrolling. -* -****************************************************************************/ -{ - RMREGS regs; - - regs.x.ax = 0x4F07; - if (waitVRT) - regs.x.bx = 0x80; - else regs.x.bx = 0x00; - regs.x.cx = x; - regs.x.dx = y; - PM_int86(0x10,®s,®s); - return regs.x.ax == VBE_SUCCESS; -} - -ibool VBEAPI VBE_getDisplayStart(int *x,int *y) -/**************************************************************************** -* -* Function: VBE_getDisplayStart -* Parameters: x,y - Place to store starting address value -* Returns: True if function was successful. -* -****************************************************************************/ -{ - RMREGS regs; - - regs.x.ax = 0x4F07; - regs.x.bx = 0x01; - PM_int86(0x10,®s,®s); - *x = regs.x.cx; - *y = regs.x.dx; - return regs.x.ax == VBE_SUCCESS; -} - -ibool VBEAPI VBE_setDisplayStartAlt(ulong startAddr,ibool waitVRT) -/**************************************************************************** -* -* Function: VBE_setDisplayStartAlt -* Parameters: startAddr - 32-bit starting address in display memory -* waitVRT - True to wait for vertical retrace, false if not -* Returns: True if function was successful, false if not supported. -* -* Description: Sets the new starting display position to the specified -* 32-bit display start address. Note that this function is -* different the the version above, since it takes a 32-bit -* byte offset in video memory as the starting address which -* gives the programmer maximum control over the stat address. -* -* NOTE: Requires VBE/Core 3.0 -* -****************************************************************************/ -{ - RMREGS regs; - - if (state->VBEVersion >= 0x300) { - regs.x.ax = 0x4F07; - regs.x.bx = waitVRT ? 0x82 : 0x02; - regs.e.ecx = startAddr; - PM_int86(0x10,®s,®s); - return regs.x.ax == VBE_SUCCESS; - } - return false; -} - -int VBEAPI VBE_getDisplayStartStatus(void) -/**************************************************************************** -* -* Function: VBE_getDisplayStartStatus -* Returns: 0 if last flip not occurred, 1 if already flipped -* -1 if not supported -* -* Description: Returns the status of the previous display start request. -* If this function is supported the programmer can implement -* hardware triple buffering using this function. -* -* NOTE: Requires VBE/Core 3.0 -* -****************************************************************************/ -{ - RMREGS regs; - - if (state->VBEVersion >= 0x300) { - regs.x.ax = 0x4F07; - regs.x.bx = 0x0004; - PM_int86(0x10,®s,®s); - if (regs.x.ax == VBE_SUCCESS) - return (regs.x.cx != 0); - } - return -1; -} - -ibool VBEAPI VBE_enableStereoMode(void) -/**************************************************************************** -* -* Function: VBE_enableStereoMode -* Returns: True if stereo mode enabled, false if not supported. -* -* Description: Puts the system into hardware stereo mode for LC shutter -* glasses, where the display swaps between two display start -* addresses every vertical retrace. -* -* NOTE: Requires VBE/Core 3.0 -* -****************************************************************************/ -{ - RMREGS regs; - - if (state->VBEVersion >= 0x300) { - regs.x.ax = 0x4F07; - regs.x.bx = 0x0005; - PM_int86(0x10,®s,®s); - return regs.x.ax == VBE_SUCCESS; - } - return false; -} - -ibool VBEAPI VBE_disableStereoMode(void) -/**************************************************************************** -* -* Function: VBE_disableStereoMode -* Returns: True if stereo mode disabled, false if not supported. -* -* Description: Puts the system back into normal, non-stereo display mode -* after having stereo mode enabled. -* -* NOTE: Requires VBE/Core 3.0 -* -****************************************************************************/ -{ - RMREGS regs; - - if (state->VBEVersion >= 0x300) { - regs.x.ax = 0x4F07; - regs.x.bx = 0x0006; - PM_int86(0x10,®s,®s); - return regs.x.ax == VBE_SUCCESS; - } - return false; -} - -ibool VBEAPI VBE_setStereoDisplayStart(ulong leftAddr,ulong rightAddr, - ibool waitVRT) -/**************************************************************************** -* -* Function: VBE_setStereoDisplayStart -* Parameters: leftAddr - 32-bit start address for left image -* rightAddr - 32-bit start address for right image -* waitVRT - True to wait for vertical retrace, false if not -* Returns: True if function was successful, false if not supported. -* -* Description: Sets the new starting display position to the specified -* 32-bit display start address. Note that this function is -* different the the version above, since it takes a 32-bit -* byte offset in video memory as the starting address which -* gives the programmer maximum control over the stat address. -* -* NOTE: Requires VBE/Core 3.0 -* -****************************************************************************/ -{ - RMREGS regs; - - if (state->VBEVersion >= 0x300) { - regs.x.ax = 0x4F07; - regs.x.bx = waitVRT ? 0x83 : 0x03; - regs.e.ecx = leftAddr; - regs.e.edx = rightAddr; - PM_int86(0x10,®s,®s); - return regs.x.ax == VBE_SUCCESS; - } - return false; -} - -ulong VBEAPI VBE_getClosestClock(ushort mode,ulong pixelClock) -/**************************************************************************** -* -* Function: VBE_getClosestClock -* Parameters: mode - VBE mode to be used (include vbeLinearBuffer) -* pixelClock - Desired pixel clock -* Returns: Closest pixel clock to desired clock (-1 if not supported) -* -* Description: Calls the VBE/Core 3.0 interface to determine the closest -* pixel clock to the requested value. The BIOS will always -* search for a pixel clock that is no more than 1% below the -* requested clock or somewhere higher than the clock. If the -* clock is higher note that it may well be many Mhz higher -* that requested and the application will have to check that -* the returned value is suitable for it's needs. This function -* returns the actual pixel clock that will be programmed by -* the hardware. -* -* Note that if the pixel clock will be used with a linear -* framebuffer mode, make sure you pass in the linear -* framebuffer flag to this function. -* -* NOTE: Requires VBE/Core 3.0 -* -****************************************************************************/ -{ - RMREGS regs; - - if (state->VBEVersion >= 0x300) { - regs.x.ax = 0x4F0B; - regs.h.bl = 0x00; - regs.e.ecx = pixelClock; - regs.x.dx = mode; - PM_int86(0x10,®s,®s); - if (regs.x.ax == VBE_SUCCESS) - return regs.e.ecx; - } - return -1; -} - -ibool VBEAPI VBE_setDACWidth(int width) -/**************************************************************************** -* -* Function: VBE_setDACWidth -* Parameters: width - Width to set the DAC to -* Returns: True on success, false on failure -* -****************************************************************************/ -{ - RMREGS regs; - - regs.x.ax = 0x4F08; - regs.h.bl = 0x00; - regs.h.bh = width; - PM_int86(0x10,®s,®s); - return regs.x.ax == VBE_SUCCESS; -} - -int VBEAPI VBE_getDACWidth(void) -/**************************************************************************** -* -* Function: VBE_getDACWidth -* Returns: Current width of the palette DAC -* -****************************************************************************/ -{ - RMREGS regs; - - regs.x.ax = 0x4F08; - regs.h.bl = 0x01; - PM_int86(0x10,®s,®s); - if (regs.x.ax != VBE_SUCCESS) - return -1; - return regs.h.bh; -} - -ibool VBEAPI VBE_setPalette(int start,int num,VBE_palette *pal,ibool waitVRT) -/**************************************************************************** -* -* Function: VBE_setPalette -* Parameters: start - Starting palette index to program -* num - Number of palette indexes to program -* pal - Palette buffer containing values -* waitVRT - Wait for vertical retrace flag -* Returns: True on success, false on failure -* -* Description: Sets a block of palette registers by calling the VBE 2.0 -* BIOS. This function will fail on VBE 1.2 implementations. -* -****************************************************************************/ -{ - RMREGS regs; - - regs.x.ax = 0x4F09; - regs.h.bl = waitVRT ? 0x80 : 0x00; - regs.x.cx = num; - regs.x.dx = start; - VBE_callESDI(®s, pal, sizeof(VBE_palette) * num); - return regs.x.ax == VBE_SUCCESS; -} - -void * VBEAPI VBE_getBankedPointer(VBE_modeInfo *modeInfo) -/**************************************************************************** -* -* Function: VBE_getBankedPointer -* Parameters: modeInfo - Mode info block for video mode -* Returns: Selector to the linear framebuffer (0 on failure) -* -* Description: Returns a near pointer to the VGA framebuffer area. -* -****************************************************************************/ -{ - /* We just map the pointer every time, since the pointer will always - * be in real mode memory, so we wont actually be mapping any real - * memory. - * - * NOTE: We cannot currently map a near pointer to the banked frame - * buffer for Watcom Win386, so we create a 16:16 far pointer to - * the video memory. All the assembler code will render to the - * video memory by loading the selector rather than using a - * near pointer. - */ - ulong seg = (ushort)modeInfo->WinASegment; - if (seg != 0) { - if (seg == 0xA000) - return (void*)PM_getA0000Pointer(); - else - return (void*)PM_mapPhysicalAddr(seg << 4,0xFFFF,true); - } - return NULL; -} - -#ifndef REALMODE - -void * VBEAPI VBE_getLinearPointer(VBE_modeInfo *modeInfo) -/**************************************************************************** -* -* Function: VBE_getLinearPointer -* Parameters: modeInfo - Mode info block for video mode -* Returns: Selector to the linear framebuffer (0 on failure) -* -* Description: Returns a near pointer to the linear framebuffer for the video -* mode. -* -****************************************************************************/ -{ - static ulong physPtr[MAX_LIN_PTRS] = {0}; - static void *linPtr[MAX_LIN_PTRS] = {0}; - static int numPtrs = 0; - int i; - - /* Search for an already mapped pointer */ - for (i = 0; i < numPtrs; i++) { - if (physPtr[i] == modeInfo->PhysBasePtr) - return linPtr[i]; - } - if (numPtrs < MAX_LIN_PTRS) { - physPtr[numPtrs] = modeInfo->PhysBasePtr; - linPtr[numPtrs] = PM_mapPhysicalAddr(modeInfo->PhysBasePtr,(state->VBEMemory * 1024L)-1,true); - return linPtr[numPtrs++]; - } - return NULL; -} - -static void InitPMCode(void) -/**************************************************************************** -* -* Function: InitPMCode - 32 bit protected mode version -* -* Description: Finds the address of and relocates the protected mode -* code block from the VBE 2.0 into a local memory block. The -* memory block is allocated with malloc() and must be freed -* with VBE_freePMCode() after graphics processing is complete. -* -* Note that this buffer _must_ be recopied after each mode set, -* as the routines will change depending on the underlying -* video mode. -* -****************************************************************************/ -{ - RMREGS regs; - RMSREGS sregs; - uchar *code; - int pmLen; - - if (!state->pmInfo && state->VBEVersion >= 0x200) { - regs.x.ax = 0x4F0A; - regs.x.bx = 0; - PM_int86x(0x10,®s,®s,&sregs); - if (regs.x.ax != VBE_SUCCESS) - return; - if (VBE_shared) - state->pmInfo = PM_mallocShared(regs.x.cx); - else - state->pmInfo = PM_malloc(regs.x.cx); - if (state->pmInfo == NULL) - return; - state->pmInfo32 = state->pmInfo; - pmLen = regs.x.cx; - - /* Relocate the block into our local data segment */ - code = PM_mapRealPointer(sregs.es,regs.x.di); - memcpy(state->pmInfo,code,pmLen); - - /* Now do a sanity check on the information we recieve to ensure - * that is is correct. Some BIOS return totally bogus information - * in here (Matrox is one)! Under DOS this works OK, but under OS/2 - * we are screwed. - */ - if (state->pmInfo->setWindow >= pmLen || - state->pmInfo->setDisplayStart >= pmLen || - state->pmInfo->setPalette >= pmLen || - state->pmInfo->IOPrivInfo >= pmLen) { - if (VBE_shared) - PM_freeShared(state->pmInfo); - else - PM_free(state->pmInfo); - state->pmInfo32 = state->pmInfo = NULL; - return; - } - - /* Read the IO priveledge info and determine if we need to - * pass a selector to MMIO registers to the bank switch code. - * Since we no longer support selector allocation, we no longer - * support this mechanism so we disable the protected mode - * interface in this case. - */ - if (state->pmInfo->IOPrivInfo && !state->MMIOSel) { - ushort *p = (ushort*)((uchar*)state->pmInfo + state->pmInfo->IOPrivInfo); - while (*p != 0xFFFF) - p++; - p++; - if (*p != 0xFFFF) - VBE_freePMCode(); - } - } -} - -void * VBEAPI VBE_getSetBank(void) -/**************************************************************************** -* -* Function: VBE_getSetBank -* Returns: Pointer to the 32 VBE 2.0 bit bank switching routine. -* -****************************************************************************/ -{ - if (state->VBEVersion >= 0x200) { - InitPMCode(); - if (state->pmInfo) - return (uchar*)state->pmInfo + state->pmInfo->setWindow; - } - return NULL; -} - -void * VBEAPI VBE_getSetDisplayStart(void) -/**************************************************************************** -* -* Function: VBE_getSetDisplayStart -* Returns: Pointer to the 32 VBE 2.0 bit CRT start address routine. -* -****************************************************************************/ -{ - if (state->VBEVersion >= 0x200) { - InitPMCode(); - if (state->pmInfo) - return (uchar*)state->pmInfo + state->pmInfo->setDisplayStart; - } - return NULL; -} - -void * VBEAPI VBE_getSetPalette(void) -/**************************************************************************** -* -* Function: VBE_getSetPalette -* Returns: Pointer to the 32 VBE 2.0 bit palette programming routine. -* -****************************************************************************/ -{ - if (state->VBEVersion >= 0x200) { - InitPMCode(); - if (state->pmInfo) - return (uchar*)state->pmInfo + state->pmInfo->setPalette; - } - return NULL; -} - -void VBEAPI VBE_freePMCode(void) -/**************************************************************************** -* -* Function: VBE_freePMCode -* -* Description: This routine frees the protected mode code blocks that -* we copied from the VBE 2.0 interface. This routine must -* be after you have finished graphics processing to free up -* the memory occupied by the routines. This is necessary -* because the PM info memory block must be re-copied after -* every video mode set from the VBE 2.0 implementation. -* -****************************************************************************/ -{ - if (state->pmInfo) { - if (VBE_shared) - PM_freeShared(state->pmInfo); - else - PM_free(state->pmInfo); - state->pmInfo = NULL; - state->pmInfo32 = NULL; - } -} - -void VBEAPI VBE_sharePMCode(void) -/**************************************************************************** -* -* Function: VBE_sharePMCode -* -* Description: Enables internal sharing of the PM code buffer for OS/2. -* -****************************************************************************/ -{ - VBE_shared = true; -} - -/* Set of code stubs used to build the final bank switch code */ - -#define VBE20_adjustOffset 7 - -static uchar VBE20A_bankFunc32_Start[] = { - 0x53,0x51, /* push ebx,ecx */ - 0x8B,0xD0, /* mov edx,eax */ - 0x33,0xDB, /* xor ebx,ebx */ - 0xB1,0x00, /* mov cl,0 */ - 0xD2,0xE2, /* shl dl,cl */ - }; - -static uchar VBE20_bankFunc32_End[] = { - 0x59,0x5B, /* pop ecx,ebx */ - }; - -static uchar bankFunc32[100]; - -#define copy(p,b,a) memcpy(b,a,sizeof(a)); (p) = (b) + sizeof(a) - -ibool VBEAPI VBE_getBankFunc32(int *codeLen,void **bankFunc,int dualBanks, - int bankAdjust) -/**************************************************************************** -* -* Function: VBE_getBankFunc32 -* Parameters: codeLen - Place to store length of code -* bankFunc - Place to store pointer to bank switch code -* dualBanks - True if dual banks are in effect -* bankAdjust - Bank shift adjustment factor -* Returns: True on success, false if not compatible. -* -* Description: Creates a local 32 bit bank switch function from the -* VBE 2.0 bank switch code that is compatible with the -* virtual flat framebuffer devices (does not have a return -* instruction at the end and takes the bank number in EAX -* not EDX). Note that this 32 bit code cannot include int 10h -* instructions, so we can only do this if we have VBE 2.0 -* or later. -* -* Note that we need to know the length of the 32 bit -* bank switch function, which the standard VBE 2.0 spec -* does not provide. In order to support this we have -* extended the VBE 2.0 state->pmInfo structure in UniVBE 5.2 in a -* way to support this, and we hope that this will become -* a VBE 2.0 ammendment. -* -* Note also that we cannot run the linear framebuffer -* emulation code with bank switching routines that require -* a selector to the memory mapped registers passed in ES. -* -****************************************************************************/ -{ - int len; - uchar *code; - uchar *p; - - InitPMCode(); - if (state->VBEVersion >= 0x200 && state->pmInfo32 && !state->MMIOSel) { - code = (uchar*)state->pmInfo32 + state->pmInfo32->setWindow; - if (state->pmInfo32->extensionSig == VBE20_EXT_SIG) - len = state->pmInfo32->setWindowLen-1; - else { - /* We are running on a system without the UniVBE 5.2 extension. - * We do as best we can by scanning through the code for the - * ret function to determine the length. This is not foolproof, - * but is the best we can do. - */ - p = code; - while (*p != 0xC3) - p++; - len = p - code; - } - if ((len + sizeof(VBE20A_bankFunc32_Start) + sizeof(VBE20_bankFunc32_End)) > sizeof(bankFunc32)) - PM_fatalError("32-bit bank switch function too long!"); - copy(p,bankFunc32,VBE20A_bankFunc32_Start); - memcpy(p,code,len); - p += len; - copy(p,p,VBE20_bankFunc32_End); - *codeLen = p - bankFunc32; - bankFunc32[VBE20_adjustOffset] = (uchar)bankAdjust; - *bankFunc = bankFunc32; - return true; - } - return false; -} - -#endif diff --git a/board/MAI/bios_emulator/scitech/src/pm/beos/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/beos/cpuinfo.c deleted file mode 100644 index cb3afe20c1..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/beos/cpuinfo.c +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: *** TODO: ADD YOUR OS ENVIRONMENT NAME HERE *** -* -* Description: Module to implement OS specific services to measure the -* CPU frequency. -* -****************************************************************************/ - -#include - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Increase the thread priority to maximum, if possible. -****************************************************************************/ -static int SetMaxThreadPriority(void) -{ - thread_id thid = find_thread(NULL); - thread_info tinfo; - get_thread_info(thid, &tinfo); - set_thread_priority(thid, B_REAL_TIME_PRIORITY); - return tinfo.priority; -} - -/**************************************************************************** -REMARKS: -Restore the original thread priority. -****************************************************************************/ -static void RestoreThreadPriority( - int priority) -{ - thread_id thid = find_thread(NULL); - set_thread_priority(thid, priority); -} - -/**************************************************************************** -REMARKS: -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. */ - freq->low = 1000000; - freq->high = 0; -} - -/**************************************************************************** -REMARKS: -Read the counter and return the counter value. - -TODO: Implement this to read the counter. It should be done as a macro - for accuracy. -****************************************************************************/ -#define GetCounter(t) { *((bigtime_t*) t) = system_time(); } diff --git a/board/MAI/bios_emulator/scitech/src/pm/beos/event.c b/board/MAI/bios_emulator/scitech/src/pm/beos/event.c deleted file mode 100644 index 93c6c0a8fc..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/beos/event.c +++ /dev/null @@ -1,199 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: BeOS -* -* Description: BeOS implementation for the SciTech cross platform -* event library. -* -****************************************************************************/ - -/*---------------------------- Global Variables ---------------------------*/ - -static ushort keyUpMsg[256] = {0};/* Table of key up messages */ -static int rangeX,rangeY; /* Range of mouse coordinates */ - -/*---------------------------- Implementation -----------------------------*/ - -/* These are not used under non-DOS systems */ -#define _EVT_disableInt() 1 -#define _EVT_restoreInt(flags) - -/**************************************************************************** -PARAMETERS: -scanCode - Scan code to test - -REMARKS: -This macro determines if a specified key is currently down at the -time that the call is made. -****************************************************************************/ -#define _EVT_isKeyDown(scanCode) (keyUpMsg[scanCode] != 0) - -/**************************************************************************** -REMARKS: -This function is used to return the number of ticks since system -startup in milliseconds. This should be the same value that is placed into -the time stamp fields of events, and is used to implement auto mouse down -events. -****************************************************************************/ -ulong _EVT_getTicks(void) -{ - /* TODO: Implement this for your OS! */ -} - -/**************************************************************************** -REMARKS: -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. */ -} - -/**************************************************************************** -REMARKS: -This macro/function is used to converts the scan codes reported by the -keyboard to our event libraries normalised format. We only have one scan -code for the 'A' key, and use shift modifiers to determine if it is a -Ctrl-F1, Alt-F1 etc. The raw scan codes from the keyboard work this way, -but the OS gives us 'cooked' scan codes, we have to translate them back -to the raw format. -****************************************************************************/ -#define _EVT_maskKeyCode(evt) - -/**************************************************************************** -REMARKS: -Safely abort the event module upon catching a fatal error. -****************************************************************************/ -void _EVT_abort() -{ - EVT_exit(); - PM_fatalError("Unhandled exception!"); -} - -/**************************************************************************** -PARAMETERS: -mouseMove - Callback function to call wheneve the mouse needs to be moved - -REMARKS: -Initiliase the event handling module. Here we install our mouse handling ISR -to be called whenever any button's are pressed or released. We also build -the free list of events in the event queue. - -We use handler number 2 of the mouse libraries interrupt handlers for our -event handling routines. -****************************************************************************/ -void EVTAPI EVT_init( - _EVT_mouseMoveHandler mouseMove) -{ - /* Initialise the event queue */ - _mouseMove = mouseMove; - initEventQueue(); - memset(keyUpMsg,0,sizeof(keyUpMsg)); - - /* TODO: Do any OS specific initialisation here */ - - /* Catch program termination signals so we can clean up properly */ - signal(SIGABRT, _EVT_abort); - signal(SIGFPE, _EVT_abort); - signal(SIGINT, _EVT_abort); -} - -/**************************************************************************** -REMARKS -Changes the range of coordinates returned by the mouse functions to the -specified range of values. This is used when changing between graphics -modes set the range of mouse coordinates for the new display mode. -****************************************************************************/ -void EVTAPI EVT_setMouseRange( - int xRes, - int yRes) -{ - rangeX = xRes; - rangeY = yRes; -} - -/**************************************************************************** -REMARKS: -Initiailises the internal event handling modules. The EVT_suspend function -can be called to suspend event handling (such as when shelling out to DOS), -and this function can be used to resume it again later. -****************************************************************************/ -void EVT_resume(void) -{ - /* Do nothing for non DOS systems */ -} - -/**************************************************************************** -REMARKS -Suspends all of our event handling operations. This is also used to -de-install the event handling code. -****************************************************************************/ -void EVT_suspend(void) -{ - /* Do nothing for non DOS systems */ -} - -/**************************************************************************** -REMARKS -Exits the event module for program terminatation. -****************************************************************************/ -void EVT_exit(void) -{ - /* Restore signal handlers */ - signal(SIGABRT, SIG_DFL); - signal(SIGFPE, SIG_DFL); - signal(SIGINT, SIG_DFL); - - /* 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 deleted file mode 100644 index 043d73ecd1..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/beos/oshdr.h +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: BeOS -* -* Description: Include file to include all OS specific header files. -* -****************************************************************************/ - -/* 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 deleted file mode 100644 index 2dcb1b81fb..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/beos/pm.c +++ /dev/null @@ -1,539 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: BeOS -* -* Description: Implementation for the OS Portability Manager Library, which -* contains functions to implement OS specific services in a -* generic, cross platform API. Porting the OS Portability -* Manager library is the first step to porting any SciTech -* products to a new platform. -* -****************************************************************************/ - -#include "pmapi.h" -#include "drvlib/os/os.h" -#include -#include -#include - -/* TODO: Include any BeOS specific headers here! */ - -/*--------------------------- Global variables ----------------------------*/ - -static void (PMAPIP fatalErrorCleanup)(void) = NULL; - -/*----------------------------- Implementation ----------------------------*/ - -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: 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(); */ -} - -long PMAPI PM_getOSType(void) -{ return _OS_BEOS; } - -int PMAPI PM_getModeType(void) -{ return PM_386; } - -void PMAPI PM_backslash(char *s) -{ - uint pos = strlen(s); - if (s[pos-1] != '/') { - s[pos] = '/'; - s[pos+1] = '\0'; - } -} - -void PMAPI PM_setFatalErrorCleanup( - void (PMAPIP cleanup)(void)) -{ - fatalErrorCleanup = cleanup; -} - -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. */ - if (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 */ - 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. */ - 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. */ - 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). */ - 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. */ - 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. */ -} - -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. */ -} - -void PMAPI PM_closeConsole(int console_id) -{ - /* 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). */ -} - -void PM_setOSScreenWidth(int width,int height) -{ - /* 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. */ - 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. */ -} - -void PMAPI PM_restoreRealTimeClockHandler(void) -{ - /* TODO: Restores the real time clock handler. */ -} - -char * PMAPI PM_getCurrentPath( - char *path, - int maxLen) -{ - return getcwd(path,maxLen); -} - -char PMAPI PM_getBootDrive(void) -{ return '/'; } - -const char * PMAPI PM_getVBEAFPath(void) -{ return PM_getNucleusConfigPath(); } - -const char * PMAPI PM_getNucleusPath(void) -{ - char *env = getenv("NUCLEUS_PATH"); - return env ? env : "/usr/lib/nucleus"; -} - -const char * PMAPI PM_getNucleusConfigPath(void) -{ - static char path[256]; - strcpy(path,PM_getNucleusPath()); - PM_backslash(path); - strcat(path,"config"); - return path; -} - -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. */ - static char buf[128]; - gethostname(buf, 128); - return buf; -} - -const char * PMAPI PM_getMachineName(void) -{ - /* TODO: Return the network machine name for the machine. */ - static char buf[128]; - gethostname(buf, 128); - return buf; -} - -void * PMAPI PM_getBIOSPointer(void) -{ - /* No BIOS access on the BeOS */ - return NULL; -} - -void * PMAPI PM_getA0000Pointer(void) -{ - static void *bankPtr; - if (!bankPtr) - 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. */ - 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. */ -} - -ulong PMAPI PM_getPhysicalAddr(void *p) -{ - /* 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 */ -} - -int PMAPI PM_getCOMPort(int port) -{ - /* 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; - } - 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. */ - switch (port) { - 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. */ - 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. */ - 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. */ - return base; -} - -void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) -{ - /* 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 */ - return NULL; -} - -void PMAPI PM_freeRealSeg(void *mem) -{ - /* No BIOS access on the BeOS */ -} - -void PMAPI DPMI_int86(int intno, DPMI_regs *regs) -{ - /* No BIOS access on the BeOS */ -} - -int PMAPI PM_int86(int intno, RMREGS *in, RMREGS *out) -{ - /* 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 */ - return 0; -} - -void PMAPI PM_callRealMode(uint seg,uint off, RMREGS *in, - RMSREGS *sregs) -{ - /* 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. */ - *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. */ - return NULL; -} - -void PMAPI PM_freeLockedMem(void *p,uint size,ibool contiguous) -{ - /* TODO: Free a memory block allocated with PM_allocLockedMem. */ -} - -void PMAPI PM_setBankA(int bank) -{ - /* No BIOS access on the BeOS */ -} - -void PMAPI PM_setBankAB(int bank) -{ - /* No BIOS access on the BeOS */ -} - -void PMAPI PM_setCRTStart(int x,int y,int waitVRT) -{ - /* 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). */ - 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. */ - return false; -} - -/**************************************************************************** -REMARKS: -Function to find the first file matching a search criteria in a directory. -****************************************************************************/ -ulong PMAPI PM_findFirstFile( - const char *filename, - PM_findData *findData) -{ - (void)filename; - (void)findData; - return PM_FILE_INVALID; -} - -/**************************************************************************** -REMARKS: -Function to find the next file matching a search criteria in a directory. -****************************************************************************/ -ibool PMAPI PM_findNextFile( - ulong handle, - PM_findData *findData) -{ - (void)handle; - (void)findData; - return false; -} - -/**************************************************************************** -REMARKS: -Function to close the find process -****************************************************************************/ -void PMAPI PM_findClose( - ulong handle) -{ - (void)handle; -} - -/**************************************************************************** -REMARKS: -Function to determine if a drive is a valid drive or not. Under Unix this -function will return false for anything except a value of 3 (considered -the root drive, and equivalent to C: for non-Unix systems). The drive -numbering is: - - 1 - Drive A: - 2 - Drive B: - 3 - Drive C: - etc - -****************************************************************************/ -ibool PMAPI PM_driveValid( - char drive) -{ - if (drive == 3) - return true; - return false; -} - -/**************************************************************************** -REMARKS: -Function to get the current working directory for the specififed drive. -Under Unix this will always return the current working directory regardless -of what the value of 'drive' is. -****************************************************************************/ -void PMAPI PM_getdcwd( - int drive, - char *dir, - int len) -{ - (void)drive; - getcwd(dir,len); -} - -/**************************************************************************** -REMARKS: -Function to change the file attributes for a specific file. -****************************************************************************/ -void PMAPI PM_setFileAttr( - const char *filename, - uint attrib) -{ - /* TODO: Set the file attributes for a file */ - (void)filename; - (void)attrib; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/beos/vflat.c b/board/MAI/bios_emulator/scitech/src/pm/beos/vflat.c deleted file mode 100644 index 579ef2c95c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/beos/vflat.c +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Dummy module; no virtual framebuffer for this OS -* -****************************************************************************/ - -#include "pmapi.h" - -ibool PMAPI VF_available(void) -{ - return false; -} - -void * PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) -{ - baseAddr = baseAddr; - bankSize = bankSize; - codeLen = codeLen; - bankFunc = bankFunc; - return NULL; -} - -void PMAPI VF_exit(void) -{ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/beos/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/beos/ztimer.c deleted file mode 100644 index a528b73177..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/beos/ztimer.c +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: *** TODO: ADD YOUR OS ENVIRONMENT NAME HERE *** -* -* Description: OS specific implementation for the Zen Timer functions. -* -****************************************************************************/ - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Initialise the Zen Timer module internals. -****************************************************************************/ -void _ZTimerInit(void) -{ - /* TODO: Do any specific internal initialisation in here */ -} - -/**************************************************************************** -REMARKS: -Start the Zen Timer counting. -****************************************************************************/ -static void _LZTimerOn( - LZTimerObject *tm) -{ - /* TODO: Start the Zen Timer counting. This should be a macro if */ - /* possible. */ -} - -/**************************************************************************** -REMARKS: -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. */ - return 0; -} - -/**************************************************************************** -REMARKS: -Stop the Zen Timer counting. -****************************************************************************/ -static void _LZTimerOff( - LZTimerObject *tm) -{ - /* TODO: Stop the timer counting. Should be a macro if possible. */ -} - -/**************************************************************************** -REMARKS: -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. */ - return 0; -} - -/**************************************************************************** -REMARKS: -Define the resolution of the long period timer as microseconds per timer tick. -****************************************************************************/ -#define ULZTIMER_RESOLUTION 1 - -/**************************************************************************** -REMARKS: -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. */ -} - -/**************************************************************************** -REMARKS: -Compute the elapsed time from the BIOS timer tick. Note that we check to see -whether a midnight boundary has passed, and if so adjust the finish time to -account for this. We cannot detect if more that one midnight boundary has -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/codepage/us_eng.c b/board/MAI/bios_emulator/scitech/src/pm/codepage/us_eng.c deleted file mode 100644 index 9aa871423e..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/codepage/us_eng.c +++ /dev/null @@ -1,285 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Keyboard translation code pages for US English keyboards. -* -****************************************************************************/ - -#include "event.h" - -/*--------------------------- Global variables ----------------------------*/ - -/* This table is used for all normal key translations, and is the fallback - * table if the key is not found in any of the other translation tables. - * If the code is not found in this table, the ASCII code is set to 0 to - * indicate that there is no ASCII code equivalent for this key. - */ -static codepage_entry_t US_normal[] = { - {0x01, 0x1B}, - {0x02, '1'}, - {0x03, '2'}, - {0x04, '3'}, - {0x05, '4'}, - {0x06, '5'}, - {0x07, '6'}, - {0x08, '7'}, - {0x09, '8'}, - {0x0A, '9'}, - {0x0B, '0'}, - {0x0C, '-'}, - {0x0D, '='}, - {0x0E, 0x08}, - {0x0F, 0x09}, - {0x10, 'q'}, - {0x11, 'w'}, - {0x12, 'e'}, - {0x13, 'r'}, - {0x14, 't'}, - {0x15, 'y'}, - {0x16, 'u'}, - {0x17, 'i'}, - {0x18, 'o'}, - {0x19, 'p'}, - {0x1A, '['}, - {0x1B, ']'}, - {0x1C, 0x0D}, - {0x1E, 'a'}, - {0x1F, 's'}, - {0x20, 'd'}, - {0x21, 'f'}, - {0x22, 'g'}, - {0x23, 'h'}, - {0x24, 'j'}, - {0x25, 'k'}, - {0x26, 'l'}, - {0x27, ';'}, - {0x28, '\''}, - {0x29, '`'}, - {0x2B, '\\'}, - {0x2C, 'z'}, - {0x2D, 'x'}, - {0x2E, 'c'}, - {0x2F, 'v'}, - {0x30, 'b'}, - {0x31, 'n'}, - {0x32, 'm'}, - {0x33, ','}, - {0x34, '.'}, - {0x35, '/'}, - {0x37, '*'}, /* Keypad */ - {0x39, ' '}, - {0x4A, '-'}, /* Keypad */ - {0x4E, '+'}, /* Keypad */ - {0x60, 0x0D}, /* Keypad */ - {0x61, '/'}, /* Keypad */ - }; - -/* This table is used for when CAPSLOCK is active and the shift or ctrl - * keys are not down. If the code is not found in this table, the normal - * table above is then searched. - */ -static codepage_entry_t US_caps[] = { - {0x10, 'Q'}, - {0x11, 'W'}, - {0x12, 'E'}, - {0x13, 'R'}, - {0x14, 'T'}, - {0x15, 'Y'}, - {0x16, 'U'}, - {0x17, 'I'}, - {0x18, 'O'}, - {0x19, 'P'}, - {0x1E, 'A'}, - {0x1F, 'S'}, - {0x20, 'D'}, - {0x21, 'F'}, - {0x22, 'G'}, - {0x23, 'H'}, - {0x24, 'J'}, - {0x25, 'K'}, - {0x26, 'L'}, - {0x2C, 'Z'}, - {0x2D, 'X'}, - {0x2E, 'C'}, - {0x2F, 'V'}, - {0x30, 'B'}, - {0x31, 'N'}, - {0x32, 'M'}, - }; - -/* This table is used for when shift key is down, but the ctrl key is not - * down and CAPSLOCK is not active. If the code is not found in this table, - * the normal table above is then searched. - */ -static codepage_entry_t US_shift[] = { - {0x02, '!'}, - {0x03, '@'}, - {0x04, '#'}, - {0x05, '$'}, - {0x06, '%'}, - {0x07, '^'}, - {0x08, '&'}, - {0x09, '*'}, - {0x0A, '('}, - {0x0B, ')'}, - {0x0C, '_'}, - {0x0D, '+'}, - {0x10, 'Q'}, - {0x11, 'W'}, - {0x12, 'E'}, - {0x13, 'R'}, - {0x14, 'T'}, - {0x15, 'Y'}, - {0x16, 'U'}, - {0x17, 'I'}, - {0x18, 'O'}, - {0x19, 'P'}, - {0x1A, '{'}, - {0x1B, '}'}, - {0x1E, 'A'}, - {0x1F, 'S'}, - {0x20, 'D'}, - {0x21, 'F'}, - {0x22, 'G'}, - {0x23, 'H'}, - {0x24, 'J'}, - {0x25, 'K'}, - {0x26, 'L'}, - {0x27, ':'}, - {0x28, '"'}, - {0x29, '~'}, - {0x2B, '|'}, - {0x2C, 'Z'}, - {0x2D, 'X'}, - {0x2E, 'C'}, - {0x2F, 'V'}, - {0x30, 'B'}, - {0x31, 'N'}, - {0x32, 'M'}, - {0x33, '<'}, - {0x34, '>'}, - {0x35, '?'}, - }; - -/* This table is used for when CAPSLOCK is active and the shift key is - * down, but the ctrl key is not. If the code is not found in this table, - * the shift table above is then searched. - */ -static codepage_entry_t US_shiftCaps[] = { - {0x10, 'q'}, - {0x11, 'w'}, - {0x12, 'e'}, - {0x13, 'r'}, - {0x14, 't'}, - {0x15, 'y'}, - {0x16, 'u'}, - {0x17, 'i'}, - {0x18, 'o'}, - {0x19, 'p'}, - {0x1E, 'a'}, - {0x1F, 's'}, - {0x20, 'd'}, - {0x21, 'f'}, - {0x22, 'g'}, - {0x23, 'h'}, - {0x24, 'j'}, - {0x25, 'k'}, - {0x26, 'l'}, - {0x2C, 'z'}, - {0x2D, 'x'}, - {0x2E, 'c'}, - {0x2F, 'v'}, - {0x30, 'b'}, - {0x31, 'n'}, - {0x32, 'm'}, - }; - -/* This table is used for all key translations when the ctrl key is down, - * regardless of the state of the shift key and CAPSLOCK. If the code is - * not found in this table, the ASCII code is set to 0 to indicate that - * there is no ASCII code equivalent for this key. - */ -static codepage_entry_t US_ctrl[] = { - {0x01, 0x1B}, - {0x06, 0x1E}, - {0x0C, 0x1F}, - {0x0E, 0x7F}, - {0x10, 0x11}, - {0x11, 0x17}, - {0x12, 0x05}, - {0x13, 0x12}, - {0x14, 0x14}, - {0x15, 0x19}, - {0x16, 0x16}, - {0x17, 0x09}, - {0x18, 0x0F}, - {0x19, 0x10}, - {0x1A, 0x1B}, - {0x1B, 0x1D}, - {0x1C, 0x0A}, - {0x1E, 0x01}, - {0x1F, 0x13}, - {0x20, 0x04}, - {0x21, 0x06}, - {0x22, 0x07}, - {0x23, 0x08}, - {0x24, 0x0A}, - {0x25, 0x0B}, - {0x26, 0x0C}, - {0x2B, 0x1C}, - {0x2C, 0x1A}, - {0x2D, 0x18}, - {0x2E, 0x03}, - {0x2F, 0x16}, - {0x30, 0x02}, - {0x31, 0x0E}, - {0x32, 0x0D}, - {0x39, ' '}, - }; - -static codepage_entry_t US_numPad[] = { - {0x4C, '5'}, - {0x62, '4'}, - {0x63, '6'}, - {0x64, '8'}, - {0x65, '2'}, - {0x66, '0'}, - {0x67, '.'}, - {0x68, '7'}, - {0x69, '1'}, - {0x6A, '9'}, - {0x6B, '3'}, - }; - -codepage_t _CP_US_English = { - "US English", - US_normal, EVT_ARR_SIZE(US_normal), - US_caps, EVT_ARR_SIZE(US_caps), - US_shift, EVT_ARR_SIZE(US_shift), - US_shiftCaps, EVT_ARR_SIZE(US_shiftCaps), - US_ctrl, EVT_ARR_SIZE(US_ctrl), - US_numPad, EVT_ARR_SIZE(US_numPad), - }; diff --git a/board/MAI/bios_emulator/scitech/src/pm/common.c b/board/MAI/bios_emulator/scitech/src/pm/common.c deleted file mode 100644 index d5a8e8f1c7..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/common.c +++ /dev/null @@ -1,480 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Module containing code common to all platforms. -* -****************************************************************************/ - -#include "pmapi.h" -#include "drvlib/os/os.h" -#if defined(__WIN32_VXD__) || defined(__OS2_VDD__) || defined(__NT_DRIVER__) -#include "sdd/sddhelp.h" -#else -#include -#include -#include -#endif - -/*---------------------------- Global variables ---------------------------*/ - -/* {secret} */ -long _VARAPI ___drv_os_type = _OS_UNSUPPORTED; -static char localBPDPath[PM_MAX_PATH] = ""; - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -PARAMETERS: -path - Local path to the Nucleus BPD driver files. - -REMARKS: -This function is used by the application program to override the location -of the Nucleus driver files that are loaded. Normally the loader code -will look in the system Nucleus directories first, then in the 'drivers' -directory relative to the current working directory, and finally relative -to the MGL_ROOT environment variable. By default the local BPD path is -always set to the current directory if not initialised. -****************************************************************************/ -void PMAPI PM_setLocalBPDPath( - const char *path) -{ - PM_init(); - strncpy(localBPDPath,path,sizeof(localBPDPath)); - localBPDPath[sizeof(localBPDPath)-1] = 0; -} - -/**************************************************************************** -PARAMETERS: -bpdpath - Place to store the actual path to the file -cachedpath - Place to store the cached BPD driver path -trypath - Path to try to find the BPD file in -subpath - Optional sub path to append to trypath -dllname - Name of the Binary Portable DLL to load - -RETURNS: -True if found, false if not. - -REMARKS: -Trys the specified path to see if the BPD file can be found or not. If so, -the path used is returned in bpdpath and cachedpath. -****************************************************************************/ -static ibool TryPath( - char *bpdpath, - char *cachedpath, - const char *trypath, - const char *subpath, - const char *dllname) -{ - char filename[256]; - FILE *f; - - strcpy(bpdpath, trypath); - PM_backslash(bpdpath); - strcat(bpdpath,subpath); - PM_backslash(bpdpath); - strcpy(filename,bpdpath); - strcat(filename,dllname); - if ((f = fopen(filename,"rb")) == NULL) - return false; - if (cachedpath) - strcpy(cachedpath,bpdpath); - fclose(f); - return true; -} - -/**************************************************************************** -RETURNS: -True if local override enabled, false if not. - -REMARKS: -Tests to see if the local override option is enabled, and if so it will -look for the Nucleus drivers in the local application directories in -preference to the Nucleus system directories. -****************************************************************************/ -static ibool GetLocalOverride(void) -{ - char filename[256]; - FILE *f; - 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); - } - } - return local_override; -} - -/**************************************************************************** -DESCRIPTION: -Sets the location of the debug log file. - -HEADER: -pmapi.h - -PARAMETERS: -dllname - Name of the Binary Portable DLL to load -bpdpath - Place to store the actual path to the file - -RETURNS: -True if found, false if not. - -REMARKS: -Finds the location of a specific Binary Portable DLL, by searching all -the standard SciTech Nucleus driver locations. -****************************************************************************/ -ibool PMAPI PM_findBPD( - const char *dllname, - char *bpdpath) -{ - static char cachedpath[PM_MAX_PATH] = ""; - - /* 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 { -#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; - } -#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; - } - - /* Always try in the previously discovered path */ - return TryPath(bpdpath,NULL,cachedpath,"",dllname); -} - -/**************************************************************************** -REMARKS: -Copies a string into another, and returns dest + strlen(src). -****************************************************************************/ -static char *_stpcpy( - char *_dest, - const char *_src) -{ - if (!_dest || !_src) - return 0; - while ((*_dest++ = *_src++) != 0) - ; - return --_dest; -} - -/**************************************************************************** -REMARKS: -Copies a string into another, stopping at the maximum length. The string -is properly terminated (unlike strncpy). -****************************************************************************/ -static void safe_strncpy( - char *dst, - const char *src, - unsigned maxlen) -{ - if (dst) { - if(strlen(src) >= maxlen) { - strncpy(dst, src, maxlen); - dst[maxlen] = 0; - } - else - strcpy(dst, src); - } -} - -/**************************************************************************** -REMARKS: -Determins if the dot separator is present in the string. -****************************************************************************/ -static int findDot( - char *p) -{ - if (*(p-1) == '.') - p--; - switch (*--p) { - case ':': - if (*(p-2) != '\0') - break; - case '/': - case '\\': - case '\0': - return true; - } - return false; -} - -/**************************************************************************** -DESCRIPTION: -Make a full pathname from split components. - -HEADER: -pmapi.h - -PARAMETERS: -path - Place to store full path -drive - Drive component for path -dir - Directory component for path -name - Filename component for path -ext - Extension component for path - -REMARKS: -Function to make a full pathname from split components. Under Unix the -drive component will usually be empty. If the drive, dir, name, or ext -parameters are null or empty, they are not inserted in the path string. -Otherwise, if the drive doesn't end with a colon, one is inserted in the -path. If the dir doesn't end in a slash, one is inserted in the path. -If the ext doesn't start with a dot, one is inserted in the path. - -The maximum sizes for the path string is given by the constant PM_MAX_PATH, -which includes space for the null-terminator. - -SEE ALSO: -PM_splitPath -****************************************************************************/ -void PMAPI PM_makepath( - char *path, - const char *drive, - const char *dir, - const char *name, - const char *ext) -{ - if (drive && *drive) { - *path++ = *drive; - *path++ = ':'; - } - if (dir && *dir) { - path = _stpcpy(path,dir); - if (*(path-1) != '\\' && *(path-1) != '/') -#ifdef __UNIX__ - *path++ = '/'; -#else - *path++ = '\\'; -#endif - } - if (name) - path = _stpcpy(path,name); - if (ext && *ext) { - if (*ext != '.') - *path++ = '.'; - path = _stpcpy(path,ext); - } - *path = 0; -} - -/**************************************************************************** -DESCRIPTION: -Split a full pathname into components. - -HEADER: -pmapi.h - -PARAMETERS: -path - Full path to split -drive - Drive component for path -dir - Directory component for path -name - Filename component for path -ext - Extension component for path - -RETURNS: -Flags indicating what components were parsed. - -REMARKS: -Function to split a full pathmame into separate components in the form - - X:\DIR\SUBDIR\NAME.EXT - -and splits path into its four components. It then stores those components -in the strings pointed to by drive, dir, name and ext. (Each component is -required but can be a NULL, which means the corresponding component will be -parsed but not stored). - -The maximum sizes for these strings are given by the constants PM_MAX_DRIVE -and PM_MAX_PATH. PM_MAX_DRIVE is always 4, and PM_MAX_PATH is usually at -least 256 characters. Under Unix the dir, name and ext components may be -up to the full path in length. - -SEE ALSO: -PM_makePath -****************************************************************************/ -int PMAPI PM_splitpath( - const char *path, - char *drive, - char *dir, - char *name, - char *ext) -{ - char *p; - int temp,ret; - char buf[PM_MAX_PATH+2]; - - /* Set all string to default value zero */ - ret = 0; - if (drive) *drive = 0; - if (dir) *dir = 0; - if (name) *name = 0; - if (ext) *ext = 0; - - /* Copy filename into template up to PM_MAX_PATH characters */ - p = buf; - if ((temp = strlen(path)) > PM_MAX_PATH) - temp = PM_MAX_PATH; - *p++ = 0; - strncpy(p, path, temp); - *(p += temp) = 0; - - /* 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; - } - if (*p == ':') { - if (buf[1]) - ret |= PM_HAS_DRIVE; - safe_strncpy(drive, &buf[1], PM_MAX_DRIVE - 1); - } - return ret; -} - -/**************************************************************************** -DESCRIPTION: -Block until a specific time has elapsed since the last call - -HEADER: -pmapi.h - -PARAMETERS: -milliseconds - Number of milliseconds for delay - -REMARKS: -This function will block the calling thread or process until the specified -number of milliseconds have passed since the /last/ call to this function. -The first time this function is called, it will return immediately. On -subsquent calls it will block until the specified time has elapsed, or it -will return immediately if the time has already elapsed. - -This function is useful to provide constant time functionality in a -program, such as a frame rate limiter for graphics applications etc. - -SEE ALSO: -PM_sleep -****************************************************************************/ -void PMAPI PM_blockUntilTimeout( - ulong milliseconds) -{ - ulong microseconds = milliseconds * 1000L,msDelay; - static LZTimerObject tm; - static ibool firstTime = true; - - if (firstTime) { - firstTime = false; - LZTimerOnExt(&tm); - } - else { - 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/_cpuinfo.asm b/board/MAI/bios_emulator/scitech/src/pm/common/_cpuinfo.asm deleted file mode 100644 index 60ebed713f..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/common/_cpuinfo.asm +++ /dev/null @@ -1,600 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: NASM or TASM Assembler -;* Environment: Intel 32 bit Protected Mode. -;* -;* Description: Code to determine the Intel processor type. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" - -header _cpuinfo - -begdataseg _cpuinfo ; Start of data segment - -cache_id db "01234567890123456" -intel_id db "GenuineIntel" ; Intel vendor ID -cyrix_id db "CyrixInstead" ; Cyrix vendor ID -amd_id db "AuthenticAMD" ; AMD vendor ID -idt_id db "CentaurHauls" ; IDT vendor ID - -CPU_IDT EQU 01000h ; Flag for IDT processors -CPU_Cyrix EQU 02000h ; Flag for Cyrix processors -CPU_AMD EQU 04000h ; Flag for AMD processors -CPU_Intel EQU 08000h ; Flag for Intel processors - -enddataseg _cpuinfo - -begcodeseg _cpuinfo ; Start of code segment - -ifdef USE_NASM -%macro mCPU_ID 0 -db 00Fh,0A2h -%endmacro -else -MACRO mCPU_ID -db 00Fh,0A2h -ENDM -endif - -ifdef USE_NASM -%macro mRDTSC 0 -db 00Fh,031h -%endmacro -else -MACRO mRDTSC -db 00Fh,031h -ENDM -endif - -;---------------------------------------------------------------------------- -; bool _CPU_check80386(void) -;---------------------------------------------------------------------------- -; Determines if we have an i386 processor. -;---------------------------------------------------------------------------- -cprocstart _CPU_check80386 - - enter_c - - xor edx,edx ; EDX = 0, not an 80386 - mov bx, sp -ifdef USE_NASM - and sp, ~3 -else - and sp, not 3 -endif - pushfd ; Push original EFLAGS - pop eax ; Get original EFLAGS - mov ecx, eax ; Save original EFLAGS - xor eax, 40000h ; Flip AC bit in EFLAGS - push eax ; Save new EFLAGS value on - ; stack - popfd ; Replace current EFLAGS value - pushfd ; Get new EFLAGS - pop eax ; Store new EFLAGS in EAX - xor eax, ecx ; Can't toggle AC bit, - ; processor=80386 - jnz @@Done ; Jump if not an 80386 processor - inc edx ; We have an 80386 - -@@Done: push ecx - popfd - mov sp, bx - mov eax, edx - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; bool _CPU_check80486(void) -;---------------------------------------------------------------------------- -; Determines if we have an i486 processor. -;---------------------------------------------------------------------------- -cprocstart _CPU_check80486 - - enter_c - -; Distinguish between the i486 and Pentium by the ability to set the ID flag -; in the EFLAGS register. If the ID flag is set, then we can use the CPUID -; instruction to determine the final version of the chip. Otherwise we -; simply have an 80486. - -; Distinguish between the i486 and Pentium by the ability to set the ID flag -; in the EFLAGS register. If the ID flag is set, then we can use the CPUID -; instruction to determine the final version of the chip. Otherwise we -; simply have an 80486. - - pushfd ; Get original EFLAGS - pop eax - mov ecx, eax - xor eax, 200000h ; Flip ID bit in EFLAGS - push eax ; Save new EFLAGS value on stack - popfd ; Replace current EFLAGS value - pushfd ; Get new EFLAGS - pop eax ; Store new EFLAGS in EAX - xor eax, ecx ; Can not toggle ID bit, - jnz @@1 ; Processor=80486 - mov eax,1 ; We dont have a Pentium - jmp @@Done -@@1: mov eax,0 ; We have Pentium or later -@@Done: leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; bool _CPU_checkClone(void) -;---------------------------------------------------------------------------- -; Checks if the i386 or i486 processor is a clone or genuine Intel. -;---------------------------------------------------------------------------- -cprocstart _CPU_checkClone - - enter_c - - mov ax,5555h ; Check to make sure this is a 32-bit processor - xor dx,dx - mov cx,2h - div cx ; Perform Division - clc - jnz @@NoClone - jmp @@Clone -@@NoClone: - stc -@@Clone: - pushfd - pop eax ; Get the flags - and eax,1 - xor eax,1 ; EAX=0 is probably Intel, EAX=1 is a Clone - - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; bool _CPU_haveCPUID(void) -;---------------------------------------------------------------------------- -; Determines if we have support for the CPUID instruction. -;---------------------------------------------------------------------------- -cprocstart _CPU_haveCPUID - - enter_c - -ifdef flatmodel - pushfd ; Get original EFLAGS - pop eax - mov ecx, eax - xor eax, 200000h ; Flip ID bit in EFLAGS - push eax ; Save new EFLAGS value on stack - popfd ; Replace current EFLAGS value - pushfd ; Get new EFLAGS - pop eax ; Store new EFLAGS in EAX - xor eax, ecx ; Can not toggle ID bit, - jnz @@1 ; Processor=80486 - mov eax,0 ; We dont have CPUID support - jmp @@Done -@@1: mov eax,1 ; We have CPUID support -else - mov eax,0 ; CPUID requires 32-bit pmode -endif -@@Done: leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; uint _CPU_checkCPUID(void) -;---------------------------------------------------------------------------- -; Determines the CPU type using the CPUID instruction. -;---------------------------------------------------------------------------- -cprocstart _CPU_checkCPUID - - enter_c - - xor eax, eax ; Set up for CPUID instruction - mCPU_ID ; Get and save vendor ID - cmp eax, 1 ; Make sure 1 is valid input for CPUID - jl @@Fail ; We dont have the CPUID instruction - xor eax,eax ; Assume vendor is unknown - -; Check for GenuineIntel processors - - LEA_L esi,intel_id - cmp [DWORD esi], ebx - jne @@NotIntel - cmp [DWORD esi+4], edx - jne @@NotIntel - cmp [DWORD esi+8], ecx - jne @@NotIntel - mov eax,CPU_Intel ; Flag that we have GenuineIntel - jmp @@FoundVendor - -; Check for CyrixInstead processors - -@@NotIntel: - LEA_L esi,cyrix_id - cmp [DWORD esi], ebx - jne @@NotCyrix - cmp [DWORD esi+4], edx - jne @@NotCyrix - cmp [DWORD esi+8], ecx - jne @@NotCyrix - mov eax,CPU_Cyrix ; Flag that we have CyrixInstead - jmp @@FoundVendor - -; Check for AuthenticAMD processors - -@@NotCyrix: - LEA_L esi,amd_id - cmp [DWORD esi], ebx - jne @@NotAMD - cmp [DWORD esi+4], edx - jne @@NotAMD - cmp [DWORD esi+8], ecx - jne @@NotAMD - mov eax,CPU_AMD ; Flag that we have AuthenticAMD - jmp @@FoundVendor - -; Check for CentaurHauls processors - -@@NotAMD: - LEA_L esi,idt_id - cmp [DWORD esi], ebx - jne @@NotIDT - cmp [DWORD esi+4], edx - jne @@NotIDT - cmp [DWORD esi+8], ecx - jne @@NotIDT - mov eax,CPU_IDT ; Flag that we have AuthenticIDT - jmp @@FoundVendor - -@@NotIDT: - -@@FoundVendor: - push eax - xor eax, eax - inc eax - mCPU_ID ; Get family/model/stepping/features - and eax, 0F00h - shr eax, 8 ; Isolate family - and eax, 0Fh - pop ecx - or eax,ecx ; Combine in the clone flag -@@Done: leave_c - ret - -@@Fail: xor eax,eax - jmp @@Done - -cprocend - -;---------------------------------------------------------------------------- -; uint _CPU_getCPUIDModel(void) -;---------------------------------------------------------------------------- -; Determines the CPU type using the CPUID instruction. -;---------------------------------------------------------------------------- -cprocstart _CPU_getCPUIDModel - - enter_c - - xor eax, eax ; Set up for CPUID instruction - mCPU_ID ; Get and save vendor ID - cmp eax, 1 ; Make sure 1 is valid input for CPUID - jl @@Fail ; We dont have the CPUID instruction - xor eax, eax - inc eax - mCPU_ID ; Get family/model/stepping/features - and eax, 0F0h - shr eax, 4 ; Isolate model -@@Done: leave_c - ret - -@@Fail: xor eax,eax - jmp @@Done - -cprocend - -;---------------------------------------------------------------------------- -; uint _CPU_getCPUIDStepping(void) -;---------------------------------------------------------------------------- -; Determines the CPU type using the CPUID instruction. -;---------------------------------------------------------------------------- -cprocstart _CPU_getCPUIDStepping - - enter_c - - xor eax, eax ; Set up for CPUID instruction - mCPU_ID ; Get and save vendor ID - cmp eax, 1 ; Make sure 1 is valid input for CPUID - jl @@Fail ; We dont have the CPUID instruction - xor eax, eax - inc eax - mCPU_ID ; Get family/model/stepping/features - and eax, 00Fh ; Isolate stepping -@@Done: leave_c - ret - -@@Fail: xor eax,eax - jmp @@Done - -cprocend - -;---------------------------------------------------------------------------- -; uint _CPU_getCPUIDFeatures(void) -;---------------------------------------------------------------------------- -; Determines the CPU type using the CPUID instruction. -;---------------------------------------------------------------------------- -cprocstart _CPU_getCPUIDFeatures - - enter_c - - xor eax, eax ; Set up for CPUID instruction - mCPU_ID ; Get and save vendor ID - cmp eax, 1 ; Make sure 1 is valid input for CPUID - jl @@Fail ; We dont have the CPUID instruction - xor eax, eax - inc eax - mCPU_ID ; Get family/model/stepping/features - mov eax, edx -@@Done: leave_c - ret - -@@Fail: xor eax,eax - jmp @@Done - -cprocend - -;---------------------------------------------------------------------------- -; uint _CPU_getCacheSize(void) -;---------------------------------------------------------------------------- -; Determines the CPU cache size for Intel processors -;---------------------------------------------------------------------------- -cprocstart _CPU_getCacheSize - - enter_c - xor eax, eax ; Set up for CPUID instruction - mCPU_ID ; Get and save vendor ID - cmp eax,2 ; Make sure 2 is valid input for CPUID - jl @@Fail ; We dont have the CPUID instruction - mov eax,2 - mCPU_ID ; Get cache descriptors - LEA_L esi,cache_id ; Get address of cache ID (-fPIC aware) - shr eax,8 - mov [esi+0],eax - mov [esi+3],ebx - mov [esi+7],ecx - mov [esi+11],edx - xor eax,eax - LEA_L esi,cache_id ; Get address of cache ID (-fPIC aware) - mov edi,15 -@@ScanLoop: - cmp [BYTE esi],41h - mov eax,128 - je @@Done - cmp [BYTE esi],42h - mov eax,256 - je @@Done - cmp [BYTE esi],43h - mov eax,512 - je @@Done - cmp [BYTE esi],44h - mov eax,1024 - je @@Done - cmp [BYTE esi],45h - mov eax,2048 - je @@Done - inc esi - dec edi - jnz @@ScanLoop - -@@Done: leave_c - ret - -@@Fail: xor eax,eax - jmp @@Done - -cprocend - -;---------------------------------------------------------------------------- -; uint _CPU_have3DNow(void) -;---------------------------------------------------------------------------- -; Determines the CPU type using the CPUID instruction. -;---------------------------------------------------------------------------- -cprocstart _CPU_have3DNow - - enter_c - - mov eax,80000000h ; Query for extended functions - mCPU_ID ; Get extended function limit - cmp eax,80000001h - jbe @@Fail ; Nope, we dont have function 800000001h - mov eax,80000001h ; Setup extended function 800000001h - mCPU_ID ; and get the information - test edx,80000000h ; Bit 31 is set if 3DNow! present - jz @@Fail ; Nope, we dont have 3DNow support - mov eax,1 ; Yep, we have 3DNow! support! -@@Done: leave_c - ret - -@@Fail: xor eax,eax - jmp @@Done - -cprocend - -;---------------------------------------------------------------------------- -; ulong _CPU_quickRDTSC(void) -;---------------------------------------------------------------------------- -; Reads the time stamp counter and returns the low order 32-bits -;---------------------------------------------------------------------------- -cprocstart _CPU_quickRDTSC - - mRDTSC - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _CPU_runBSFLoop(ulong interations) -;---------------------------------------------------------------------------- -; Runs a loop of BSF instructions for the specified number of iterations -;---------------------------------------------------------------------------- -cprocstart _CPU_runBSFLoop - - ARG iterations:ULONG - - push _bp - mov _bp,_sp - push _bx - - mov edx,[iterations] - mov eax,80000000h - mov ebx,edx - - ALIGN 4 - -@@loop: bsf ecx,eax - dec ebx - jnz @@loop - - pop _bx - pop _bp - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _CPU_readTimeStamp(CPU_largeInteger *time); -;---------------------------------------------------------------------------- -; Reads the time stamp counter and returns the 64-bit result. -;---------------------------------------------------------------------------- -cprocstart _CPU_readTimeStamp - - mRDTSC - mov ecx,[esp+4] ; Access directly without stack frame - mov [ecx],eax - mov [ecx+4],edx - ret - -cprocend - -;---------------------------------------------------------------------------- -; ulong _CPU_diffTime64(CPU_largeInteger *t1,CPU_largeInteger *t2,CPU_largeInteger *t) -;---------------------------------------------------------------------------- -; Computes the difference between two 64-bit numbers. -;---------------------------------------------------------------------------- -cprocstart _CPU_diffTime64 - - ARG t1:DPTR, t2:DPTR, t:DPTR - - enter_c - - mov ecx,[t2] - mov eax,[ecx] ; EAX := t2.low - mov ecx,[t1] - sub eax,[ecx] - mov edx,eax ; EDX := low difference - mov ecx,[t2] - mov eax,[ecx+4] ; ECX := t2.high - mov ecx,[t1] - sbb eax,[ecx+4] ; EAX := high difference - - mov ebx,[t] ; Store the result - mov [ebx],edx ; Store low part - mov [ebx+4],eax ; Store high part - mov eax,edx ; Return low part -ifndef flatmodel - shld edx,eax,16 ; Return in DX:AX -endif - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; ulong _CPU_calcMicroSec(CPU_largeInteger *count,ulong freq); -;---------------------------------------------------------------------------- -; Computes the value in microseconds for the elapsed time with maximum -; precision. The formula we use is: -; -; us = (((diff * 0x100000) / freq) * 1000000) / 0x100000) -; -; The power of two multiple before the first divide allows us to scale the -; 64-bit difference using simple shifts, and then the divide brings the -; final result into the range to fit into a 32-bit integer. -;---------------------------------------------------------------------------- -cprocstart _CPU_calcMicroSec - - ARG count:DPTR, freq:ULONG - - enter_c - - mov ecx,[count] - mov eax,[ecx] ; EAX := low part - mov edx,[ecx+4] ; EDX := high part - shld edx,eax,20 - shl eax,20 ; diff * 0x100000 - div [DWORD freq] ; (diff * 0x100000) / freq - mov ecx,1000000 - xor edx,edx - mul ecx ; ((diff * 0x100000) / freq) * 1000000) - shrd eax,edx,20 ; ((diff * 0x100000) / freq) * 1000000) / 0x100000 -ifndef flatmodel - shld edx,eax,16 ; Return in DX:AX -endif - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; ulong _CPU_mulDiv(ulong a,ulong b,ulong c); -;---------------------------------------------------------------------------- -; Computes the following with 64-bit integer precision: -; -; result = (a * b) / c -; -;---------------------------------------------------------------------------- -cprocstart _CPU_mulDiv - - ARG a:ULONG, b:ULONG, c:ULONG - - enter_c - mov eax,[a] - imul [ULONG b] - idiv [ULONG c] -ifndef flatmodel - shld edx,eax,16 ; Return in DX:AX -endif - leave_c - ret - -cprocend - -endcodeseg _cpuinfo - - END diff --git a/board/MAI/bios_emulator/scitech/src/pm/common/_dma.asm b/board/MAI/bios_emulator/scitech/src/pm/common/_dma.asm deleted file mode 100644 index 2b6e1e8b56..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/common/_dma.asm +++ /dev/null @@ -1,246 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: 80386 Assembler, TASM 4.0 or NASM -;* Environment: 16/32 bit Ring 0 device driver -;* -;* Description: Assembler support routines for ISA DMA controller. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -header _dma ; Set up memory model - -begdataseg _dma ; Start of data segment - -cpublic _PM_DMADataStart - -; DMA register I/O addresses for channels 0-7 (except 4) - -DMAC_page db 087h,083h,081h,082h, -1,08Bh,089h,08Ah -DMAC_addr db 000h,002h,004h,006h, -1,0C4h,0C8h,0CCh -DMAC_cnt db 001h,003h,005h,007h, -1,0C6h,0CAh,0CEh -DMAC_mask db 00Ah,00Ah,00Ah,00Ah, -1,0D4h,0D4h,0D4h -DMAC_mode db 00Bh,00Bh,00Bh,00Bh, -1,0D6h,0D6h,0D6h -DMAC_FF db 00Ch,00Ch,00Ch,00Ch, -1,0D8h,0D8h,0D8h - -cpublic _PM_DMADataEnd - -enddataseg _dma - -begcodeseg _dma ; Start of code segment - -ifdef flatmodel - -cpublic _PM_DMACodeStart - -;---------------------------------------------------------------------------- -; void PM_DMACDisable(int channel); -;---------------------------------------------------------------------------- -; Masks DMA channel, inhibiting DMA transfers -;---------------------------------------------------------------------------- -cprocstart PM_DMACDisable - - ARG channel:UINT - - push ebp - mov ebp,esp - mov ecx,[channel] ; ECX indexes DMAC register tables - mov dh,0 ; DH = 0 for DMAC register port access - mov al,cl - and al,11b - or al,100b ; AL = (channel & 3) | "set mask bit" - mov dl,[DMAC_mask+ecx] - out dx,al - pop ebp - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_DMACEnable(int channel); -;---------------------------------------------------------------------------- -; Unmasks DMA channel, enabling DMA transfers -;---------------------------------------------------------------------------- -cprocstart PM_DMACEnable - - ARG channel:UINT - - push ebp - mov ebp,esp - mov ecx,[channel] ; ECX indexes DMAC register tables - mov dh,0 ; DH = 0 for DMAC register port access - mov al,cl - and al,11b ; AL = (channel & 3), "set mask bit"=0 - mov dl,[DMAC_mask+ecx] - out dx,al - pop ebp - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_DMACProgram(int channel,int mode,ulong bufferPhys,int count); -;---------------------------------------------------------------------------- -; Purpose: Program DMA controller to perform transfer from first 16MB -; based on previously selected mode and channel. DMA transfer may be enabled -; by subsequent call to PM_DMACEnable. -; -; Entry: channel - DMA channel in use (0-7) -; mode - Selected DMAMODE type for transfer -; buffer - 32-bit physical address of DMA buffer -; count - DMA byte count (1-65536 bytes) -;---------------------------------------------------------------------------- -cprocstart PM_DMACProgram - - ARG channel:UINT, mode:UINT, bufferPhys:ULONG, count:UINT - - enter_c - pushfd - cli ; Disable interrupts - -; Mask DMA channel to disable it - - mov ebx,[channel] ; EBX indexes DMAC register tables - mov dh,0 ; DH = 0 for DMAC register port access - mov al,bl - and al,11b - or al,100b ; AL = (channel & 3) | "set mask bit" - mov dl,[DMAC_mask+ebx] - out dx,al - -; Generate IOW to clear FF toggle state - - mov al,0 - mov dl,[DMAC_FF+ebx] - out dx,al - -; Compute buffer address to program - - mov eax,[bufferPhys] ; AX := DMA address offset - mov ecx,eax - shr ecx,16 ; CL := bufferPhys >> 16 (DMA page) - mov esi,[count] ; ESI = # of bytes to transfer - cmp ebx,4 ; 16-bit channel? - jb @@WriteDMAC ; No, program DMAC - shr eax,1 ; Yes, convert address and count - shr esi,1 ; to 16-bit, 128K/page format - -; Set the DMA address word (bits 0-15) - -@@WriteDMAC: - mov dl,[DMAC_addr+ebx] - out dx,al - mov al,ah - out dx,al - -; Set DMA transfer count - - mov eax,esi - dec eax ; ESI = # of bytes to transfer - 1 - mov dl,[DMAC_cnt+ebx] - out dx,al - mov al,ah - out dx,al - -; Set DMA page byte (bits 16-23) - - mov al,cl - mov dl,[DMAC_page+ebx] - out dx,al - -; Set the DMA channel mode - - mov al,bl - and al,11b - or al,[BYTE mode] ; EAX = (channel & 3) | mode - mov dl,[DMAC_mode+ebx] - out dx,al - - pop eax ; SMP safe interrupt state restore! - test eax,200h - jz @@1 - sti -@@1: leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; ulong PMAPI PM_DMACPosition(int channel); -;---------------------------------------------------------------------------- -; Returns the current position in a dma transfer. Interrupts should be -; disabled before calling this function. -;---------------------------------------------------------------------------- -cprocstart PM_DMACPosition - - ARG channel:UINT - - enter_c - mov ecx,[channel] ; ECX indexes DMAC register tables - mov dh,0 ; DH = 0 for DMAC register port access - -; Generate IOW to clear FF toggle state - - mov al,0 - mov dl,[DMAC_FF+ebx] - out dx,al - xor eax,eax - xor ecx,ecx - -; Now read the current position for the channel - -@@ReadLoop: - mov dl,[DMAC_cnt+ebx] - out dx,al - in al,dx - mov cl,al - in al,dx - mov ch,al ; ECX := first count read - in al,dx - mov ah,al - in al,dx - xchg al,ah ; EAX := second count read - sub ecx,eax - cmp ecx,40h - jg @@ReadLoop - cmp ebx,4 ; 16-bit channel? - jb @@Exit ; No, we are done - shl eax,1 ; Yes, adjust to byte address - -@@Exit: leave_c - ret - -cprocend - - -cpublic _PM_DMACodeEnd - -endif - -endcodeseg _dma - - END ; End of module diff --git a/board/MAI/bios_emulator/scitech/src/pm/common/_int64.asm b/board/MAI/bios_emulator/scitech/src/pm/common/_int64.asm deleted file mode 100644 index fdec1b58d8..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/common/_int64.asm +++ /dev/null @@ -1,309 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: NASM or TASM Assembler -;* Environment: Intel 32 bit Protected Mode. -;* -;* Description: Code for 64-bit arhithmetic -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" - -header _int64 - -begcodeseg _int64 ; Start of code segment - -a_low EQU 04h ; Access a_low directly on stack -a_high EQU 08h ; Access a_high directly on stack -b_low EQU 0Ch ; Access b_low directly on stack -shift EQU 0Ch ; Access shift directly on stack -result_2 EQU 0Ch ; Access result directly on stack -b_high EQU 10h ; Access b_high directly on stack -result_3 EQU 10h ; Access result directly on stack -result_4 EQU 14h ; Access result directly on stack - -;---------------------------------------------------------------------------- -; void _PM_add64(u32 a_low,u32 a_high,u32 b_low,u32 b_high,__u64 *result); -;---------------------------------------------------------------------------- -; Adds two 64-bit numbers. -;---------------------------------------------------------------------------- -cprocstart _PM_add64 - - mov eax,[esp+a_low] - add eax,[esp+b_low] - mov edx,[esp+a_high] - adc edx,[esp+b_high] - mov ecx,[esp+result_4] - mov [ecx],eax - mov [ecx+4],edx - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _PM_sub64(u32 a_low,u32 a_high,u32 b_low,u32 b_high,__u64 *result); -;---------------------------------------------------------------------------- -; Subtracts two 64-bit numbers. -;---------------------------------------------------------------------------- -cprocstart _PM_sub64 - - mov eax,[esp+a_low] - sub eax,[esp+b_low] - mov edx,[esp+a_high] - sbb edx,[esp+b_high] - mov ecx,[esp+result_4] - mov [ecx],eax - mov [ecx+4],edx - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _PM_mul64(u32 a_high,u32 a_low,u32 b_high,u32 b_low,__u64 *result); -;---------------------------------------------------------------------------- -; Multiples two 64-bit numbers. -;---------------------------------------------------------------------------- -cprocstart _PM_mul64 - - mov eax,[esp+a_high] - mov ecx,[esp+b_high] - or ecx,eax - mov ecx,[esp+b_low] - jnz @@FullMultiply - mov eax,[esp+a_low] ; EDX:EAX = b.low * a.low - mul ecx - mov ecx,[esp+result_4] - mov [ecx],eax - mov [ecx+4],edx - ret - -@@FullMultiply: - push ebx - mul ecx ; EDX:EAX = a.high * b.low - mov ebx,eax - mov eax,[esp+a_low+4] - mul [DWORD esp+b_high+4] ; EDX:EAX = b.high * a.low - add ebx,eax - mov eax,[esp+a_low+4] - mul ecx ; EDX:EAX = a.low * b.low - add edx,ebx - pop ebx - mov ecx,[esp+result_4] - mov [ecx],eax - mov [ecx+4],edx - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _PM_div64(u32 a_low,u32 a_high,u32 b_low,u32 b_high,__u64 *result); -;---------------------------------------------------------------------------- -; Divides two 64-bit numbers. -;---------------------------------------------------------------------------- -cprocstart _PM_div64 - - push edi - push esi - push ebx - xor edi,edi - mov eax,[esp+a_high+0Ch] - or eax,eax - jns @@ANotNeg - -; Dividend is negative, so negate it and save result for later - - inc edi - mov edx,[esp+a_low+0Ch] - neg eax - neg edx - sbb eax,0 - mov [esp+a_high+0Ch],eax - mov [esp+a_low+0Ch],edx - -@@ANotNeg: - mov eax,[esp+b_high+0Ch] - or eax,eax - jns @@BNotNeg - -; Divisor is negative, so negate it and save result for later - - inc edi - mov edx,[esp+b_low+0Ch] - neg eax - neg edx - sbb eax,0 - mov [esp+b_high+0Ch],eax - mov [esp+b_low+0Ch],edx - -@@BNotNeg: - or eax,eax - jnz @@BHighNotZero - -; b.high is zero, so handle this faster - - mov ecx,[esp+b_low+0Ch] - mov eax,[esp+a_high+0Ch] - xor edx,edx - div ecx - mov ebx,eax - mov eax,[esp+a_low+0Ch] - div ecx - mov edx,ebx - jmp @@BHighZero - -@@BHighNotZero: - mov ebx,eax - mov ecx,[esp+b_low+0Ch] - mov edx,[esp+a_high+0Ch] - mov eax,[esp+a_low+0Ch] - -; Shift values right until b.high becomes zero - -@@ShiftLoop: - shr ebx,1 - rcr ecx,1 - shr edx,1 - rcr eax,1 - or ebx,ebx - jnz @@ShiftLoop - -; Now complete the divide process - - div ecx - mov esi,eax - mul [DWORD esp+b_high+0Ch] - mov ecx,eax - mov eax,[esp+b_low+0Ch] - mul esi - add edx,ecx - jb @@8 - cmp edx,[esp+a_high+0Ch] - ja @@8 - jb @@9 - cmp eax,[esp+a_low+0Ch] - jbe @@9 -@@8: dec esi -@@9: xor edx,edx - mov eax,esi - -@@BHighZero: - dec edi - jnz @@Done - -; The result needs to be negated as either a or b was negative - - neg edx - neg eax - sbb edx,0 - -@@Done: pop ebx - pop esi - pop edi - mov ecx,[esp+result_4] - mov [ecx],eax - mov [ecx+4],edx - ret - -cprocend - -;---------------------------------------------------------------------------- -; __i64 _PM_shr64(u32 a_low,s32 a_high,s32 shift,__u64 *result); -;---------------------------------------------------------------------------- -; Shift a 64-bit number right -;---------------------------------------------------------------------------- -cprocstart _PM_shr64 - - mov eax,[esp+a_low] - mov edx,[esp+a_high] - mov cl,[esp+shift] - shrd edx,eax,cl - mov ecx,[esp+result_3] - mov [ecx],eax - mov [ecx+4],edx - ret - -cprocend - -;---------------------------------------------------------------------------- -; __i64 _PM_sar64(u32 a_low,s32 a_high,s32 shift,__u64 *result); -;---------------------------------------------------------------------------- -; Shift a 64-bit number right (signed) -;---------------------------------------------------------------------------- -cprocstart _PM_sar64 - - mov eax,[esp+a_low] - mov edx,[esp+a_high] - mov cl,[esp+shift] - sar edx,cl - rcr eax,cl - mov ecx,[esp+result_3] - mov [ecx],eax - mov [ecx+4],edx - ret - -cprocend - -;---------------------------------------------------------------------------- -; __i64 _PM_shl64(u32 a_low,s32 a_high,s32 shift,__u64 *result); -;---------------------------------------------------------------------------- -; Shift a 64-bit number left -;---------------------------------------------------------------------------- -cprocstart _PM_shl64 - - mov eax,[esp+a_low] - mov edx,[esp+a_high] - mov cl,[esp+shift] - shld edx,eax,cl - mov ecx,[esp+result_3] - mov [ecx],eax - mov [ecx+4],edx - ret - -cprocend - -;---------------------------------------------------------------------------- -; __i64 _PM_neg64(u32 a_low,s32 a_high,__u64 *result); -;---------------------------------------------------------------------------- -; Shift a 64-bit number left -;---------------------------------------------------------------------------- -cprocstart _PM_neg64 - - mov eax,[esp+a_low] - mov edx,[esp+a_high] - neg eax - neg edx - sbb eax,0 - mov ecx,[esp+result_2] - mov [ecx],eax - mov [ecx+4],edx - ret - -cprocend - - -endcodeseg _int64 - - END diff --git a/board/MAI/bios_emulator/scitech/src/pm/common/_joy.asm b/board/MAI/bios_emulator/scitech/src/pm/common/_joy.asm deleted file mode 100644 index 0ff1ecf55d..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/common/_joy.asm +++ /dev/null @@ -1,230 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: 80386 Assembler -;* Environment: Intel x86, any OS -;* -;* Description: Assembly language support routines for reading analogue -;* joysticks. -;* -;**************************************************************************** - - ideal - -include "scitech.mac" ; Memory model macros - -ifdef flatmodel - -header _joy ; Set up memory model - -begcodeseg _joy ; Start of code segment - -;---------------------------------------------------------------------------- -; initTimer -;---------------------------------------------------------------------------- -; Sets up 8253 timer 2 (PC speaker) to start timing, but not produce output. -;---------------------------------------------------------------------------- -cprocstatic initTimer - -; Start timer 2 counting - - in al,61h - and al,0FDh ; Disable speaker output (just in case) - or al,1 - out 61h,al - -; Set the timer 2 count to 0 again to start the timing interval. - - mov al,10110100b ; set up to load initial (timer 2) - out 43h,al ; timer count - sub al,al - out 42h,al ; load count lsb - out 42h,al ; load count msb - ret - -cprocend - -;---------------------------------------------------------------------------- -; readTimer2 -;---------------------------------------------------------------------------- -; Reads the number of ticks from the 8253 timer chip using channel 2 (PC -; speaker). This is non-destructive and does not screw up other libraries. -;---------------------------------------------------------------------------- -cprocstatic readTimer - - xor al,al ; Latch timer 0 command - out 43h,al ; Latch timer - in al,42h ; least significant byte - mov ah,al - in al,42h ; most significant byte - xchg ah,al - and eax,0FFFFh - ret - -cprocend - -;---------------------------------------------------------------------------- -; exitTimer -;---------------------------------------------------------------------------- -; Stops the 8253 timer 2 (PC speaker) counting -;---------------------------------------------------------------------------- -cprocstatic exitTimer - -; Stop timer 2 from counting - - push eax - in al,61h - and al,0FEh - out 61h,al - -; Some programs have a problem if we change the control port; better change it -; to something they expect (mode 3 - square wave generator)... - mov al,0B6h - out 43h,al - - pop eax - ret - -cprocend - -;---------------------------------------------------------------------------- -; int _EVT_readJoyAxis(int jmask,int *axis); -;---------------------------------------------------------------------------- -; Function to poll the joystick to read the current axis positions. -;---------------------------------------------------------------------------- -cprocstart _EVT_readJoyAxis - - ARG jmask:UINT, axis:DPTR - - LOCAL firstTick:UINT, lastTick:UINT, totalTicks:UINT = LocalSize - - enter_c - - mov ebx,[jmask] - mov edi,[axis] - mov ecx,(1193180/100) - and ebx,01111b ; Mask out supported axes - mov dx,201h ; DX := joystick I/O port - call initTimer ; Start timer 2 counting - call readTimer ; Returns counter in EAX - mov [lastTick],eax - -@@WaitStable: - in al,dx - and al,bl ; Wait for the axes in question to be - jz @@Stable ; done reading... - call readTimer ; Returns counter in EAX - xchg eax,[lastTick] - cmp eax,[lastTick] - jb @@1 - sub eax,[lastTick] -@@1: add [totalTicks],eax - cmp [totalTicks],ecx ; Check for timeout - jae @@Stable - jmp @@WaitStable - -@@Stable: - mov al,0FFh - out dx,al ; Start joystick reading - call initTimer ; Start timer 2 counting - call readTimer ; Returns counter in EAX - mov [firstTick],eax ; Store initial count - mov [lastTick],eax - mov [DWORD totalTicks],0 - cli - -@@PollLoop: - in al,dx ; Read Joystick port - not al - and al,bl ; Mask off channels we don't want to read - jnz @@AxisFlipped ; See if any of the channels flipped - call readTimer ; Returns counter in EAX - xchg eax,[lastTick] - cmp eax,[lastTick] - jb @@2 - sub eax,[lastTick] -@@2: add [totalTicks],eax - cmp [totalTicks],ecx ; Check for timeout - jae @@TimedOut - jmp @@PollLoop - -@@AxisFlipped: - xor esi,esi - mov ah,1 - test al,ah - jnz @@StoreCount ; Joystick 1, X axis flipped - add esi,4 - mov ah,2 - test al,ah - jnz @@StoreCount ; Joystick 1, Y axis flipped - add esi,4 - mov ah,4 - test al,ah - jnz @@StoreCount ; Joystick 2, X axis flipped - add esi,4 ; Joystick 2, Y axis flipped - mov ah,8 - -@@StoreCount: - or bh,ah ; Indicate this axis is active - xor bl,ah ; Unmark the channels that just tripped - call readTimer ; Returns counter in EAX - xchg eax,[lastTick] - cmp eax,[lastTick] - jb @@3 - sub eax,[lastTick] -@@3: add [totalTicks],eax - mov eax,[totalTicks] - mov [edi+esi],eax ; Record the time this channel flipped - cmp bl,0 ; If there are more channels to read, - jne @@PollLoop ; keep looping - -@@TimedOut: - sti - call exitTimer ; Stop timer 2 counting - movzx eax,bh ; Return the mask of working axes - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; int _EVT_readJoyButtons(void); -;---------------------------------------------------------------------------- -; Function to poll the current joystick buttons -;---------------------------------------------------------------------------- -cprocstart _EVT_readJoyButtons - - mov dx,0201h - in al,dx - shr al,4 - not al - and eax,0Fh - ret - -cprocend - -endcodeseg _joy - -endif - - END ; End of module diff --git a/board/MAI/bios_emulator/scitech/src/pm/common/_mtrr.asm b/board/MAI/bios_emulator/scitech/src/pm/common/_mtrr.asm deleted file mode 100644 index 1e0a6966ce..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/common/_mtrr.asm +++ /dev/null @@ -1,272 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: 80386 Assembler, TASM 4.0 or NASM -;* Environment: 16/32 bit Ring 0 device driver -;* -;* Description: Assembler support routines for the Memory Type Range Register -;* (MTRR) module. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -header _mtrr ; Set up memory model - -begdataseg _mtrr - -ifdef DOS4GW - cextern _PM_haveCauseWay,UINT -endif - -enddataseg _mtrr - -begcodeseg _mtrr ; Start of code segment - -P586 - -;---------------------------------------------------------------------------- -; ibool _MTRR_isRing0(void); -;---------------------------------------------------------------------------- -; Checks to see if we are running at ring 0. This check is only relevant -; for 32-bit DOS4GW and compatible programs. If we are not running under -; DOS4GW, then we simply assume we are a ring 0 device driver. -;---------------------------------------------------------------------------- -cprocnear _MTRR_isRing0 - -; Are we running under CauseWay? - -ifdef DOS4GW - enter_c - mov ax,cs - and eax,3 - xor eax,3 - jnz @@Exit - -; CauseWay runs the apps at ring 3, but implements support for specific -; ring 0 instructions that we need to get stuff done under real DOS. - - mov eax,1 - cmp [UINT _PM_haveCauseWay],0 - jnz @@Exit -@@Fail: xor eax,eax -@@Exit: leave_c - ret -else -ifdef __SMX32__ - mov eax,1 ; SMX is ring 0! - ret -else -ifdef __VXD__ - mov eax,1 ; VxD is ring 0! - ret -else -ifdef __NT_DRIVER__ - mov eax,1 ; NT/W2K is ring 0! - ret -else -else - xor eax,eax ; Assume ring 3 for 32-bit DOS - ret -endif -endif -endif -endif - -cprocend - -;---------------------------------------------------------------------------- -; ulong _MTRR_disableInt(void); -;---------------------------------------------------------------------------- -; Return processor interrupt status and disable interrupts. -;---------------------------------------------------------------------------- -cprocstart _MTRR_disableInt - - pushfd ; Put flag word on stack - cli ; Disable interrupts! - pop eax ; deposit flag word in return register - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _MTRR_restoreInt(ulong ps); -;---------------------------------------------------------------------------- -; Restore processor interrupt status. -;---------------------------------------------------------------------------- -cprocstart _MTRR_restoreInt - - ARG ps:ULONG - - push ebp - mov ebp,esp ; Set up stack frame - mov ecx,[ps] - test ecx,200h ; SMP safe interrupt flag restore! - jz @@1 - sti -@@1: pop ebp - ret - -cprocend - -;---------------------------------------------------------------------------- -; ulong _MTRR_saveCR4(void); -;---------------------------------------------------------------------------- -; Save the value of CR4 and clear the Page Global Enable (bit 7). We also -; disable and flush the caches. -;---------------------------------------------------------------------------- -cprocstart _MTRR_saveCR4 - - enter_c - -; Save value of CR4 and clear Page Global Enable (bit 7) - - mov ebx,cr4 - mov eax,ebx - and al,7Fh - mov cr4,eax - -; Disable and flush caches - - mov eax,cr0 - or eax,40000000h - wbinvd - mov cr0,eax - wbinvd - -; Return value from CR4 - - mov eax,ebx - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _MTRR_restoreCR4(ulong cr4Val) -;---------------------------------------------------------------------------- -; Save the value of CR4 and clear the Page Global Enable (bit 7). We also -; disable and flush the caches. -;---------------------------------------------------------------------------- -cprocstart _MTRR_restoreCR4 - - ARG cr4Val:ULONG - - enter_c - -; Enable caches - - mov eax,cr0 - and eax,0BFFFFFFFh - mov cr0,eax - mov eax,[cr4Val] - mov cr4,eax - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; uchar _MTRR_getCx86(uchar reg); -;---------------------------------------------------------------------------- -; Read a Cyrix CPU indexed register -;---------------------------------------------------------------------------- -cprocstart _MTRR_getCx86 - - ARG reg:UCHAR - - enter_c - mov al,[reg] - out 22h,al - in al,23h - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; uchar _MTRR_setCx86(uchar reg,uchar val); -;---------------------------------------------------------------------------- -; Write a Cyrix CPU indexed register -;---------------------------------------------------------------------------- -cprocstart _MTRR_setCx86 - - ARG reg:UCHAR, val:UCHAR - - enter_c - mov al,[reg] - out 22h,al - mov al,[val] - out 23h,al - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _MTRR_readMSR(uong reg, ulong FAR *eax, ulong FAR *edx); -;---------------------------------------------------------------------------- -; Writes the specific Machine Status Register used on the newer Intel -; Pentium Pro and Pentium II motherboards. -;---------------------------------------------------------------------------- -cprocnear _MTRR_readMSR - - ARG reg:ULONG, v_eax:DPTR, v_edx:DPTR - - enter_c - mov ecx,[reg] - rdmsr - mov ebx,[v_eax] - mov [ebx],eax - mov ebx,[v_edx] - mov [ebx],edx - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _MTRR_writeMSR(uong reg, ulong eax, ulong edx); -;---------------------------------------------------------------------------- -; Writes the specific Machine Status Register used on the newer Intel -; Pentium Pro and Pentium II motherboards. -;---------------------------------------------------------------------------- -cprocnear _MTRR_writeMSR - - ARG reg:ULONG, v_eax:ULONG, v_edx:ULONG - - enter_c - mov ecx,[reg] - mov eax,[v_eax] - mov edx,[v_edx] - wrmsr - leave_c - ret - -cprocend - -endcodeseg _mtrr - - END ; End of module diff --git a/board/MAI/bios_emulator/scitech/src/pm/common/_pcihelp.asm b/board/MAI/bios_emulator/scitech/src/pm/common/_pcihelp.asm deleted file mode 100644 index 5b8dbcc73a..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/common/_pcihelp.asm +++ /dev/null @@ -1,358 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: 80386 Assembler, TASM 4.0 or NASM -;* Environment: Any -;* -;* Description: Helper assembler functions for PCI access module. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -header _pcilib - -begcodeseg _pcilib - -ifdef flatmodel - -;---------------------------------------------------------------------------- -; uchar _ASMAPI _BIOS32_service( -; ulong service, -; ulong func, -; ulong *physBase, -; ulong *length, -; ulong *serviceOffset, -; PCIBIOS_entry entry); -;---------------------------------------------------------------------------- -; Call the BIOS32 services directory -;---------------------------------------------------------------------------- -cprocstart _BIOS32_service - - ARG service:ULONG, func:ULONG, physBase:DPTR, len:DPTR, off:DPTR, entry:QWORD - - enter_c - mov eax,[service] - mov ebx,[func] -ifdef USE_NASM - call far dword [entry] -else - call [FWORD entry] -endif - mov esi,[physBase] - mov [esi],ebx - mov esi,[len] - mov [esi],ecx - mov esi,[off] - mov [esi],edx - leave_c - ret - -cprocend - -endif - -;---------------------------------------------------------------------------- -; ushort _ASMAPI _PCIBIOS_isPresent(ulong i_eax,ulong *o_edx,ushort *oeax, -; uchar *o_cl,PCIBIOS_entry entry) -;---------------------------------------------------------------------------- -; Call the PCI BIOS to determine if it is present. -;---------------------------------------------------------------------------- -cprocstart _PCIBIOS_isPresent - - ARG i_eax:ULONG, o_edx:DPTR, oeax:DPTR, o_cl:DPTR, entry:QWORD - - enter_c - mov eax,[i_eax] -ifdef flatmodel -ifdef USE_NASM - call far dword [entry] -else - call [FWORD entry] -endif -else - int 1Ah -endif - _les _si,[o_edx] - mov [_ES _si],edx - _les _si,[oeax] - mov [_ES _si],ax - _les _si,[o_cl] - mov [_ES _si],cl - mov ax,bx - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; ulong _PCIBIOS_service(ulong r_eax,ulong r_ebx,ulong r_edi,ulong r_ecx, -; PCIBIOS_entry entry) -;---------------------------------------------------------------------------- -; Call the PCI BIOS services, either via the 32-bit protected mode entry -; point or via the Int 1Ah 16-bit interrupt. -;---------------------------------------------------------------------------- -cprocstart _PCIBIOS_service - - ARG r_eax:ULONG, r_ebx:ULONG, r_edi:ULONG, r_ecx:ULONG, entry:QWORD - - enter_c - mov eax,[r_eax] - mov ebx,[r_ebx] - mov edi,[r_edi] - mov ecx,[r_ecx] -ifdef flatmodel -ifdef USE_NASM - call far dword [entry] -else - call [FWORD entry] -endif -else - int 1Ah -endif - mov eax,ecx -ifndef flatmodel - shld edx,eax,16 ; Return result in DX:AX -endif - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; int _PCIBIOS_getRouting(PCIRoutingOptionsBuffer *buf,PCIBIOS_entry entry); -;---------------------------------------------------------------------------- -; Get the routing options for PCI devices -;---------------------------------------------------------------------------- -cprocstart _PCIBIOS_getRouting - - ARG buf:DPTR, entry:QWORD - - enter_c - mov eax,0B10Eh - mov bx,0 - _les _di,[buf] -ifdef flatmodel -ifdef USE_NASM - call far dword [entry] -else - call [FWORD entry] -endif -else - int 1Ah -endif - movzx eax,ah - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; ibool _PCIBIOS_setIRQ(int busDev,int intPin,int IRQ,PCIBIOS_entry entry); -;---------------------------------------------------------------------------- -; Change the IRQ routing for the PCI device -;---------------------------------------------------------------------------- -cprocstart _PCIBIOS_setIRQ - - ARG busDev:UINT, intPin:UINT, IRQ:UINT, entry:QWORD - - enter_c - mov eax,0B10Fh - mov bx,[USHORT busDev] - mov cl,[BYTE intPin] - mov ch,[BYTE IRQ] -ifdef flatmodel -ifdef USE_NASM - call far dword [entry] -else - call [FWORD entry] -endif -else - int 1Ah -endif - mov eax,1 - jnc @@1 - xor eax,eax ; Function failed! -@@1: leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; ulong _PCIBIOS_specialCycle(int bus,ulong data,PCIBIOS_entry entry); -;---------------------------------------------------------------------------- -; Generate a special cycle via the PCI BIOS. -;---------------------------------------------------------------------------- -cprocstart _PCIBIOS_specialCycle - - ARG bus:UINT, data:ULONG, entry:QWORD - - enter_c - mov eax,0B106h - mov bh,[BYTE bus] - mov ecx,[data] -ifdef flatmodel -ifdef USE_NASM - call far dword [entry] -else - call [FWORD entry] -endif -else - int 1Ah -endif - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; ushort _PCI_getCS(void) -;---------------------------------------------------------------------------- -cprocstart _PCI_getCS - - mov ax,cs - ret - -cprocend - -;---------------------------------------------------------------------------- -; int PM_inpb(int port) -;---------------------------------------------------------------------------- -; Reads a byte from the specified port -;---------------------------------------------------------------------------- -cprocstart PM_inpb - - ARG port:UINT - - push _bp - mov _bp,_sp - xor _ax,_ax - mov _dx,[port] - in al,dx - pop _bp - ret - -cprocend - -;---------------------------------------------------------------------------- -; int PM_inpw(int port) -;---------------------------------------------------------------------------- -; Reads a word from the specified port -;---------------------------------------------------------------------------- -cprocstart PM_inpw - - ARG port:UINT - - push _bp - mov _bp,_sp - xor _ax,_ax - mov _dx,[port] - in ax,dx - pop _bp - ret - -cprocend - -;---------------------------------------------------------------------------- -; ulong PM_inpd(int port) -;---------------------------------------------------------------------------- -; Reads a word from the specified port -;---------------------------------------------------------------------------- -cprocstart PM_inpd - - ARG port:UINT - - push _bp - mov _bp,_sp - mov _dx,[port] - in eax,dx -ifndef flatmodel - shld edx,eax,16 ; DX:AX = result -endif - pop _bp - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_outpb(int port,int value) -;---------------------------------------------------------------------------- -; Write a byte to the specified port. -;---------------------------------------------------------------------------- -cprocstart PM_outpb - - ARG port:UINT, value:UINT - - push _bp - mov _bp,_sp - mov _dx,[port] - mov _ax,[value] - out dx,al - pop _bp - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_outpw(int port,int value) -;---------------------------------------------------------------------------- -; Write a word to the specified port. -;---------------------------------------------------------------------------- -cprocstart PM_outpw - - ARG port:UINT, value:UINT - - push _bp - mov _bp,_sp - mov _dx,[port] - mov _ax,[value] - out dx,ax - pop _bp - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_outpd(int port,ulong value) -;---------------------------------------------------------------------------- -; Write a word to the specified port. -;---------------------------------------------------------------------------- -cprocstart PM_outpd - - ARG port:UINT, value:ULONG - - push _bp - mov _bp,_sp - mov _dx,[port] - mov eax,[value] - out dx,eax - pop _bp - ret - -cprocend - -endcodeseg _pcilib - - END diff --git a/board/MAI/bios_emulator/scitech/src/pm/common/agp.c b/board/MAI/bios_emulator/scitech/src/pm/common/agp.c deleted file mode 100644 index d53bc88e14..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/common/agp.c +++ /dev/null @@ -1,189 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit Ring 0 device driver -* -* Description: Generic module to implement AGP support functions using the -* SciTech Nucleus AGP support drivers. If the OS provides -* native AGP support, this module should *NOT* be used. Instead -* wrappers should be placed around the OS support functions -* to implement this functionality. -* -****************************************************************************/ - -#include "pmapi.h" -#ifndef REALMODE -#include "nucleus/agp.h" - -/*--------------------------- Global variables ----------------------------*/ - -static AGP_devCtx *agp; -static AGP_driverFuncs driver; - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -RETURNS: -Size of AGP aperture in MB on success, 0 on failure. - -REMARKS: -This function initialises the AGP driver in the system and returns the -size of the available AGP aperture in megabytes. -****************************************************************************/ -ulong PMAPI PM_agpInit(void) -{ - if ((agp = AGP_loadDriver(0)) == NULL) - return 0; - driver.dwSize = sizeof(driver); - if (!agp->QueryFunctions(AGP_GET_DRIVERFUNCS,&driver)) - 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; - } - return 0; -} - -/**************************************************************************** -REMARKS: -This function closes down the loaded AGP driver. -****************************************************************************/ -void PMAPI PM_agpExit(void) -{ - AGP_unloadDriver(agp); -} - -/**************************************************************************** -PARAMETERS: -numPages - Number of memory pages that should be reserved -type - Type of memory to allocate -physContext - Returns the physical context handle for the mapping -physAddr - Returns the physical address for the mapping - -RETURNS: -True on success, false on failure. - -REMARKS: -This function reserves a range of physical memory addresses on the system -bus which the AGP controller will respond to. If this function succeeds, -the AGP controller can respond to the reserved physical address range on -the bus. However you must first call AGP_commitPhysical to cause this memory -to actually be committed for use before it can be accessed. -****************************************************************************/ -ibool PMAPI PM_agpReservePhysical( - ulong numPages, - int type, - void **physContext, - 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; - } - return driver.ReservePhysical(numPages,type,physContext,physAddr) == nOK; -} - -/**************************************************************************** -PARAMETERS: -physContext - Physical AGP context to release - -RETURNS: -True on success, false on failure. - -REMARKS: -This function releases a range of physical memory addresses on the system -bus which the AGP controller will respond to. All committed memory for -the physical address range covered by the context will be released. -****************************************************************************/ -ibool PMAPI PM_agpReleasePhysical( - void *physContext) -{ - return driver.ReleasePhysical(physContext) == nOK; -} - -/**************************************************************************** -PARAMETERS: -physContext - Physical AGP context to commit memory for -numPages - Number of pages to be committed -startOffset - Offset in pages into the reserved physical context -physAddr - Returns the physical address of the committed memory - -RETURNS: -True on success, false on failure. - -REMARKS: -This function commits into the specified physical context that was previously -reserved by a call to ReservePhysical. You can use the startOffset and -numPages parameters to only commit portions of the reserved memory range at -a time. -****************************************************************************/ -ibool PMAPI PM_agpCommitPhysical( - void *physContext, - ulong numPages, - ulong startOffset, - PM_physAddr *physAddr) -{ - return driver.CommitPhysical(physContext,numPages,startOffset,physAddr) == nOK; -} - -/**************************************************************************** -PARAMETERS: -physContext - Physical AGP context to free memory for -numPages - Number of pages to be freed -startOffset - Offset in pages into the reserved physical context - -RETURNS: -True on success, false on failure. - -REMARKS: -This function frees memory previously committed by the CommitPhysical -function. Note that you can free a portion of a memory range that was -previously committed if you wish. -****************************************************************************/ -ibool PMAPI PM_agpFreePhysical( - void *physContext, - ulong numPages, - ulong startOffset) -{ - return driver.FreePhysical(physContext,numPages,startOffset) == nOK; -} - -#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 deleted file mode 100644 index 36867bdba7..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/common/keyboard.c +++ /dev/null @@ -1,449 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Direct keyboard event handling module. This module contains -* code to process raw scan code information, convert it to -* virtual scan codes and do code page translation to ASCII -* for different international keyboard layouts. -* -****************************************************************************/ - -/*---------------------------- Implementation -----------------------------*/ - -/**************************************************************************** -PARAMETERS: -scanCode - Keyboard scan code to translate -table - Code page table to search -count - Number of entries in the code page table - -REMARKS: -This function translates the scan codes from keyboard scan codes to ASCII -codes using a binary search on the code page table. -****************************************************************************/ -static uchar translateScan( - uchar scanCode, - codepage_entry_t *table, - int count) -{ - codepage_entry_t *test; - 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; - } - } - return 0; -} - -/**************************************************************************** -REMARKS: -This macro/function is used to converts the scan codes reported by the -keyboard to our event libraries normalised format. We only have one scan -code for the 'A' key, and use shift modifiers to determine if it is a -Ctrl-F1, Alt-F1 etc. The raw scan codes from the keyboard work this way, -but the OS gives us 'cooked' scan codes, we have to translate them back -to the raw format. -{secret} -****************************************************************************/ -void _EVT_maskKeyCode( - event_t *evt) -{ - int ascii,scan = EVT_scanCode(evt->message); - - evt->message &= ~0xFF; - if (evt->modifiers & EVT_NUMLOCK) { - 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; - } - 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->shift,EVT.codePage->shiftLen)) != 0) { - evt->message |= ascii; - return; - } - } - evt->message |= translateScan(scan,EVT.codePage->normal,EVT.codePage->normalLen); -} - -/**************************************************************************** -REMARKS: -Returns true if the key with the specified scan code is being held down. -****************************************************************************/ -static ibool _EVT_isKeyDown( - uchar scanCode) -{ - if (scanCode > 0x7F) - return false; - else - return EVT.keyTable[scanCode] != 0; -} - -/**************************************************************************** -PARAMETERS: -what - Event code -message - Event message (ASCII code and scan code) - -REMARKS: -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. -****************************************************************************/ -static void addKeyEvent( - uint what, - uint message) -{ - 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 { -#ifdef __QNX__ - _EVT_maskKeyCode(&evt); -#endif - addEvent(&evt); /* Add to tail of event queue */ - } - EVT.oldMove = -1; - } -} - -/**************************************************************************** -REMARKS: -This function waits for the keyboard controller to set the ready-for-write -bit. -****************************************************************************/ -static int kbWaitForWriteReady(void) -{ - int timeout = 8192; - while ((timeout > 0) && (PM_inpb(0x64) & 0x02)) - timeout--; - return (timeout > 0); -} - -/**************************************************************************** -REMARKS: -This function waits for the keyboard controller to set the ready-for-read -bit. -****************************************************************************/ -static int kbWaitForReadReady(void) -{ - int timeout = 8192; - while ((timeout > 0) && (!(PM_inpb(0x64) & 0x01))) - timeout--; - return (timeout > 0); -} - -/**************************************************************************** -PARAMETERS: -data - Data to send to the keyboard - -REMARKS: -This function sends a data byte to the keyboard controller. -****************************************************************************/ -static int kbSendData( - uchar data) -{ - int resends = 4; - 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)); - return 0; -} - -/**************************************************************************** -PARAMETERS: -modifiers - Keyboard modifier flags - -REMARKS: -This function re-programs the LED's on the keyboard to the values stored -in the passed in modifier flags. If the 'allowLEDS' flag is false, this -function does nothing. -****************************************************************************/ -static void setLEDS( - uint modifiers) -{ - if (EVT.allowLEDS) { - if (!kbSendData(0xED) || !kbSendData((modifiers>>9) & 7)) { - kbSendData(0xF4); - } - } -} - -/**************************************************************************** -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. -{secret} -****************************************************************************/ -void processRawScanCode( - int scan) -{ - static int pauseLoop = 0; - static int extended = 0; - int what; - - if (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; - } - 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; - } - 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; - } - - /* 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; - } - - /* 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; -#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); - } -} - -/**************************************************************************** -DESCRIPTION: -Enables/disables the update of the keyboard LED status indicators. - -HEADER: -event.h - -PARAMETERS: -enable - True to enable, false to disable - -REMARKS: -Enables the update of the keyboard LED status indicators. Sometimes it may -be convenient in the application to turn off the updating of the LED -status indicators (such as if a game is using the CAPSLOCK key for some -function). Passing in a value of FALSE to this function will turn off all -the LEDS, and stop updating them when the internal status changes (note -however that internally we still keep track of the toggle key status!). -****************************************************************************/ -void EVTAPI EVT_allowLEDS( - ibool enable) -{ - EVT.allowLEDS = true; - if (enable) - setLEDS(EVT.keyModifiers); - else - setLEDS(0); - EVT.allowLEDS = enable; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/common/malloc.c b/board/MAI/bios_emulator/scitech/src/pm/common/malloc.c deleted file mode 100644 index 83ef22113c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/common/malloc.c +++ /dev/null @@ -1,205 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Module for implementing the PM library overrideable memory -* allocator functions. -* -****************************************************************************/ - -#include "pmapi.h" - -/*--------------------------- Global variables ----------------------------*/ - -void * (*__PM_malloc)(size_t size) = malloc; -void * (*__PM_calloc)(size_t nelem,size_t size) = calloc; -void * (*__PM_realloc)(void *ptr,size_t size) = realloc; -void (*__PM_free)(void *p) = free; - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -DESCRIPTION: -Use local memory allocation routines. - -HEADER: -pmapi.h - -PARAMETERS: -malloc - Pointer to new malloc routine to use -calloc - Pointer to new caalloc routine to use -realloc - Pointer to new realloc routine to use -free - Pointer to new free routine to use - -REMARKS: -Tells the PM library to use a set of user specified memory allocation -routines instead of using the normal malloc/calloc/realloc/free standard -C library functions. This is useful if you wish to use a third party -debugging malloc library or perhaps a set of faster memory allocation -functions with the PM library, or any apps that use the PM library (such as -the MGL). Once you have registered your memory allocation routines, all -calls to PM_malloc, PM_calloc, PM_realloc and PM_free will be revectored to -your local memory allocation routines. - -This is also useful if you need to keep track of just how much physical -memory your program has been using. You can use the PM_availableMemory -function to find out how much physical memory is available when the program -starts, and then you can use your own local memory allocation routines to -keep track of how much memory has been used and freed. - -NOTE: This function should be called right at the start of your application, - before you initialise any other components or libraries. - -NOTE: Code compiled into Binary Portable DLL's and Drivers automatically - end up calling these functions via the BPD C runtime library. - -SEE ALSO: -PM_malloc, PM_calloc, PM_realloc, PM_free, PM_availableMemory -****************************************************************************/ -void PMAPI PM_useLocalMalloc( - void * (*malloc)(size_t size), - void * (*calloc)(size_t nelem,size_t size), - void * (*realloc)(void *ptr,size_t size), - void (*free)(void *p)) -{ - __PM_malloc = malloc; - __PM_calloc = calloc; - __PM_realloc = realloc; - __PM_free = free; -} - -/**************************************************************************** -DESCRIPTION: -Allocate a block of memory. - -HEADER: -pmapi.h - -PARAMETERS: -size - Size of block to allocate in bytes - -RETURNS: -Pointer to allocated block, or NULL if out of memory. - -REMARKS: -Allocates a block of memory of length size. If you have changed the memory -allocation routines with the PM_useLocalMalloc function, then calls to this -function will actually make calls to the local memory allocation routines -that you have registered. - -SEE ALSO: -PM_calloc, PM_realloc, PM_free, PM_useLocalMalloc -****************************************************************************/ -void * PMAPI PM_malloc( - size_t size) -{ - return __PM_malloc(size); -} - -/**************************************************************************** -DESCRIPTION: -Allocate and clear a large memory block. - -HEADER: -pmapi.h - -PARAMETERS: -nelem - number of contiguous size-byte units to allocate -size - size of unit in bytes - -RETURNS: -Pointer to allocated memory if successful, NULL if out of memory. - -REMARKS: -Allocates a block of memory of length (size * nelem), and clears the -allocated area with zeros (0). If you have changed the memory allocation -routines with the PM_useLocalMalloc function, then calls to this function -will actually make calls to the local memory allocation routines that you -have registered. - -SEE ALSO: -PM_malloc, PM_realloc, PM_free, PM_useLocalMalloc -****************************************************************************/ -void * PMAPI PM_calloc( - size_t nelem, - size_t size) -{ - return __PM_calloc(nelem,size); -} - -/**************************************************************************** -DESCRIPTION: -Re-allocate a block of memory - -HEADER: -pmapi.h - -PARAMETERS: -ptr - Pointer to block to resize -size - size of unit in bytes - -RETURNS: -Pointer to allocated memory if successful, NULL if out of memory. - -REMARKS: -This function reallocates a block of memory that has been previously been -allocated to the new of size. The new size may be smaller or larger than -the original block of memory. If you have changed the memory allocation -routines with the PM_useLocalMalloc function, then calls to this function -will actually make calls to the local memory allocation routines that you -have registered. - -SEE ALSO: -PM_malloc, PM_calloc, PM_free, PM_useLocalMalloc -****************************************************************************/ -void * PMAPI PM_realloc( - void *ptr, - size_t size) -{ - return __PM_realloc(ptr,size); -} - -/**************************************************************************** -DESCRIPTION: -Frees a block of memory. - -HEADER: -pmapi.h - -PARAMETERS: -p - Pointer to memory block to free - -REMARKS: -Frees a block of memory previously allocated with either PM_malloc, -PM_calloc or PM_realloc. - -SEE ALSO: -PM_malloc, PM_calloc, PM_realloc, PM_useLocalMalloc -****************************************************************************/ -void PMAPI PM_free( - void *p) -{ - __PM_free(p); -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/common/mtrr.c b/board/MAI/bios_emulator/scitech/src/pm/common/mtrr.c deleted file mode 100644 index eed5f45c9e..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/common/mtrr.c +++ /dev/null @@ -1,867 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Heavily based on code copyright (C) Richard Gooch -* -* Language: ANSI C -* Environment: 32-bit Ring 0 device driver -* -* Description: Generic Memory Type Range Register (MTRR) functions to -* manipulate the MTRR registers on supported CPU's. This code -* *must* run at ring 0, so you can't normally include this -* code directly in normal applications (the except is DOS4GW -* apps which run at ring 0 under real DOS). Thus this code -* will normally be compiled into a ring 0 device driver for -* the target operating system. -* -****************************************************************************/ - -#include "pmapi.h" -#include "ztimerc.h" -#include "mtrr.h" - -#ifndef REALMODE - -/*--------------------------- Global variables ----------------------------*/ - -/* Intel pre-defined MTRR registers */ - -#define NUM_FIXED_RANGES 88 -#define INTEL_cap_MSR 0x0FE -#define INTEL_defType_MSR 0x2FF -#define INTEL_fix64K_00000_MSR 0x250 -#define INTEL_fix16K_80000_MSR 0x258 -#define INTEL_fix16K_A0000_MSR 0x259 -#define INTEL_fix4K_C0000_MSR 0x268 -#define INTEL_fix4K_C8000_MSR 0x269 -#define INTEL_fix4K_D0000_MSR 0x26A -#define INTEL_fix4K_D8000_MSR 0x26B -#define INTEL_fix4K_E0000_MSR 0x26C -#define INTEL_fix4K_E8000_MSR 0x26D -#define INTEL_fix4K_F0000_MSR 0x26E -#define INTEL_fix4K_F8000_MSR 0x26F - -/* Macros to find the address of a paricular MSR register */ - -#define INTEL_physBase_MSR(reg) (0x200 + 2 * (reg)) -#define INTEL_physMask_MSR(reg) (0x200 + 2 * (reg) + 1) - -/* Cyrix CPU configuration register indexes */ -#define CX86_CCR0 0xC0 -#define CX86_CCR1 0xC1 -#define CX86_CCR2 0xC2 -#define CX86_CCR3 0xC3 -#define CX86_CCR4 0xE8 -#define CX86_CCR5 0xE9 -#define CX86_CCR6 0xEA -#define CX86_DIR0 0xFE -#define CX86_DIR1 0xFF -#define CX86_ARR_BASE 0xC4 -#define CX86_RCR_BASE 0xDC - -/* Structure to maintain machine state while updating MTRR registers */ - -typedef struct { - ulong flags; - ulong defTypeLo; - ulong defTypeHi; - ulong cr4Val; - ulong ccr3; - } MTRRContext; - -static int numMTRR = -1; -static int cpuFamily,cpuType,cpuStepping; -static void (*getMTRR)(uint reg,ulong *base,ulong *size,int *type) = NULL; -static void (*setMTRR)(uint reg,ulong base,ulong size,int type) = NULL; -static int (*getFreeRegion)(ulong base,ulong size) = NULL; - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -RETURNS: -Returns non-zero if we have the write-combining memory type -****************************************************************************/ -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; - } - return 0; -} - -/**************************************************************************** -PARAMETERS: -base - The starting physical base address of the region -size - The size in bytes of the region - -RETURNS: -The index of the region on success, else -1 on error. - -REMARKS: -Generic function to find the location of a free MTRR register to be used -for creating a new mapping. -****************************************************************************/ -static int GENERIC_getFreeRegion( - ulong base, - ulong size) -{ - int i,ltype; - ulong lbase,lsize; - - for (i = 0; i < numMTRR; i++) { - getMTRR(i,&lbase,&lsize,<ype); - if (lsize < 1) - return i; - } - (void)base; - (void)size; - return -1; -} - -/**************************************************************************** -PARAMETERS: -base - The starting physical base address of the region -size - The size in bytes of the region - -RETURNS: -The index of the region on success, else -1 on error. - -REMARKS: -Generic function to find the location of a free MTRR register to be used -for creating a new mapping. -****************************************************************************/ -static int AMDK6_getFreeRegion( - ulong base, - ulong size) -{ - int i,ltype; - ulong lbase,lsize; - - for (i = 0; i < numMTRR; i++) { - getMTRR(i,&lbase,&lsize,<ype); - if (lsize < 1) - return i; - } - (void)base; - (void)size; - return -1; -} - -/**************************************************************************** -PARAMETERS: -base - The starting physical base address of the region -size - The size in bytes of the region - -RETURNS: -The index of the region on success, else -1 on error. - -REMARKS: -Cyrix specific function to find the location of a free MTRR register to be -used for creating a new mapping. -****************************************************************************/ -static int CYRIX_getFreeRegion( - ulong base, - ulong size) -{ - int i,ltype; - 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; - } - 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; - } - (void)base; - return -1; -} - -/**************************************************************************** -PARAMETERS: -c - Place to store the machine context across the call - -REMARKS: -Puts the processor into a state where MTRRs can be safely updated -****************************************************************************/ -static void MTRR_beginUpdate( - MTRRContext *c) -{ - 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; - } - } -} - -/**************************************************************************** -PARAMETERS: -c - Place to restore the machine context from - -REMARKS: -Restores the processor after updating any of the registers -****************************************************************************/ -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; - } - } - - /* Re-enable interrupts (if enabled previously) */ - _MTRR_restoreInt(c->flags); -} - -/**************************************************************************** -PARAMETERS: -reg - MTRR register to read -base - Place to store the starting physical base address of the region -size - Place to store the size in bytes of the region -type - Place to store the type of the MTRR register - -REMARKS: -Intel specific function to read the value of a specific MTRR register. -****************************************************************************/ -static void INTEL_getMTRR( - uint reg, - ulong *base, - ulong *size, - int *type) -{ - ulong hi,maskLo,baseLo; - - _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_readMSR(INTEL_physBase_MSR(reg),&baseLo,&hi); - maskLo = (maskLo & 0xFFFFF000UL); - *size = ~(maskLo - 1); - *base = (baseLo & 0xFFFFF000UL); - *type = (baseLo & 0xFF); -} - -/**************************************************************************** -PARAMETERS: -reg - MTRR register to set -base - The starting physical base address of the region -size - The size in bytes of the region -type - Type to place into the MTRR register - -REMARKS: -Intel specific function to set the value of a specific MTRR register to -the passed in base, size and type. -****************************************************************************/ -static void INTEL_setMTRR( - uint reg, - ulong base, - ulong size, - int type) -{ - MTRRContext c; - - 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); - } - else { - _MTRR_writeMSR(INTEL_physBase_MSR(reg),base | type,0); - _MTRR_writeMSR(INTEL_physMask_MSR(reg),~(size - 1) | 0x800,0); - } - MTRR_endUpdate(&c); -} - -/**************************************************************************** -REMARKS: -Disabled banked write combing for Intel processors. We always disable this -because it invariably causes problems with older hardware. -****************************************************************************/ -static void INTEL_disableBankedWriteCombine(void) -{ - MTRRContext c; - - MTRR_beginUpdate(&c); - _MTRR_writeMSR(INTEL_fix16K_A0000_MSR,0,0); - MTRR_endUpdate(&c); -} - -/**************************************************************************** -PARAMETERS: -reg - MTRR register to set -base - The starting physical base address of the region -size - The size in bytes of the region -type - Type to place into the MTRR register - -REMARKS: -Intel specific function to set the value of a specific MTRR register to -the passed in base, size and type. -****************************************************************************/ -static void AMD_getMTRR( - uint reg, - ulong *base, - ulong *size, - int *type) -{ - ulong low,high; - - /* Upper dword is region 1, lower is region 0 */ - _MTRR_readMSR(0xC0000085, &low, &high); - if (reg == 1) - low = high; - - /* Find the base and type for the region */ - *base = low & 0xFFFE0000; - *type = 0; - if (low & 1) - *type = PM_MTRR_UNCACHABLE; - if (low & 2) - *type = PM_MTRR_WRCOMB; - if ((low & 3) == 0) { - *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 - * 2 bits - * - * So to get a size we do invert the mask and add 1 to the lowest - * mask bit (4 as its 2 bits in). This gives us a size we then shift - * to turn into 128K blocks - * - * eg 111 1111 1111 1100 is 512K - * - * invert 000 0000 0000 0011 - * +1 000 0000 0000 0100 - * *128K ... - */ - low = (~low) & 0x0FFFC; - *size = (low + 4) << 15; -} - -/**************************************************************************** -PARAMETERS: -reg - MTRR register to set -base - The starting physical base address of the region -size - The size in bytes of the region -type - Type to place into the MTRR register - -REMARKS: -Intel specific function to set the value of a specific MTRR register to -the passed in base, size and type. -****************************************************************************/ -static void AMD_setMTRR( - uint reg, - ulong base, - ulong size, - int type) -{ - ulong low,high,newVal; - MTRRContext c; - - MTRR_beginUpdate(&c); - _MTRR_readMSR(0xC0000085, &low, &high); - if (size == 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; - } - - /* The writeback rule is quite specific. See the manual. Its - * disable local interrupts, write back the cache, set the MTRR - */ - PM_flushTLB(); - _MTRR_writeMSR(0xC0000085, low, high); - MTRR_endUpdate(&c); -} - -/**************************************************************************** -PARAMETERS: -reg - MTRR register to set -base - The starting physical base address of the region -size - The size in bytes of the region -type - Type to place into the MTRR register - -REMARKS: -Intel specific function to set the value of a specific MTRR register to -the passed in base, size and type. -****************************************************************************/ -static void CYRIX_getMTRR( - uint reg, - ulong *base, - ulong *size, - int *type) -{ - MTRRContext c; - uchar arr = CX86_ARR_BASE + reg*3; - uchar rcr,shift; - - /* Save flags and disable interrupts */ - MTRR_beginUpdate(&c); - ((uchar*)base)[3] = _MTRR_getCx86(arr); - ((uchar*)base)[2] = _MTRR_getCx86((uchar)(arr+1)); - ((uchar*)base)[1] = _MTRR_getCx86((uchar)(arr+2)); - rcr = _MTRR_getCx86((uchar)(CX86_RCR_BASE + reg)); - MTRR_endUpdate(&c); - - /* Enable interrupts if it was enabled previously */ - shift = ((uchar*)base)[1] & 0x0f; - *base &= 0xFFFFF000UL; - - /* Power of two, at least 4K on ARR0-ARR6, 256K on ARR7 - * Note: shift==0xF means 4G, this is unsupported. - */ - if (shift) - *size = (reg < 7 ? 0x800UL : 0x20000UL) << shift; - else - *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; - } - } - 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; - } - } -} - -/**************************************************************************** -PARAMETERS: -reg - MTRR register to set -base - The starting physical base address of the region -size - The size in bytes of the region -type - Type to place into the MTRR register - -REMARKS: -Intel specific function to set the value of a specific MTRR register to -the passed in base, size and type. -****************************************************************************/ -static void CYRIX_setMTRR( - uint reg, - ulong base, - ulong size, - int type) -{ - MTRRContext c; - uchar arr = CX86_ARR_BASE + reg*3; - uchar arr_type,arr_size; - - /* Count down from 32M (ARR0-ARR6) or from 2G (ARR7) */ - 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; - } - } - 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; - } - } - MTRR_beginUpdate(&c); - _MTRR_setCx86((uchar)arr, ((uchar*)&base)[3]); - _MTRR_setCx86((uchar)(arr+1), ((uchar*)&base)[2]); - _MTRR_setCx86((uchar)(arr+2), (uchar)((((uchar*)&base)[1]) | arr_size)); - _MTRR_setCx86((uchar)(CX86_RCR_BASE + reg), (uchar)arr_type); - MTRR_endUpdate(&c); -} - -/**************************************************************************** -REMARKS: -On Cyrix 6x86(MX) and MII the ARR3 is special: it has connection -with the SMM (System Management Mode) mode. So we need the following: -Check whether SMI_LOCK (CCR3 bit 0) is set - if it is set, ARR3 cannot be changed (it cannot be changed until the - next processor reset) - if it is reset, then we can change it, set all the needed bits: - - disable access to SMM memory through ARR3 range (CCR1 bit 7 reset) - - disable access to SMM memory (CCR1 bit 2 reset) - - disable SMM mode (CCR1 bit 1 reset) - - disable write protection of ARR3 (CCR6 bit 1 reset) - - (maybe) disable ARR3 -Just to be sure, we enable ARR usage by the processor (CCR5 bit 5 set) -****************************************************************************/ -static void CYRIX_initARR(void) -{ - MTRRContext c; - uchar ccr[7]; - int ccrc[7] = { 0, 0, 0, 0, 0, 0, 0 }; - - /* Begin updating */ - MTRR_beginUpdate(&c); - - /* Save all CCRs locally */ - ccr[0] = _MTRR_getCx86(CX86_CCR0); - ccr[1] = _MTRR_getCx86(CX86_CCR1); - ccr[2] = _MTRR_getCx86(CX86_CCR2); - ccr[3] = (uchar)c.ccr3; - ccr[4] = _MTRR_getCx86(CX86_CCR4); - ccr[5] = _MTRR_getCx86(CX86_CCR5); - ccr[6] = _MTRR_getCx86(CX86_CCR6); - if (ccr[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]); - } - } - - /* If we changed CCR1 in memory, change it in the processor, too. */ - if (ccrc[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]); - } - - /* We are finished updating */ - MTRR_endUpdate(&c); -} - -/**************************************************************************** -REMARKS: -Initialise the MTRR module, by detecting the processor type and determining -if the processor supports the MTRR functionality. -****************************************************************************/ -void MTRR_init(void) -{ - int i,cpu,ltype; - ulong eax,edx,lbase,lsize; - - /* 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; - } - } -} - -/**************************************************************************** -PARAMETERS: -base - The starting physical base address of the region -size - The size in bytes of the region -type - Type to place into the MTRR register - -RETURNS: -Error code describing the result. - -REMARKS: -Function to enable write combining for the specified region of memory. -****************************************************************************/ -int MTRR_enableWriteCombine( - ulong base, - ulong size, - uint type) -{ - int i; - int ltype; - ulong lbase,lsize,last; - - /* 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 (type >= PM_MTRR_MAX) - return PM_MTRR_ERR_PARAMS; - - /* If the type is WC, check that this processor supports it */ - if (!MTRR_haveWriteCombine()) - 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; - } - - /* 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; - } - - /* Search for an empty MTRR */ - if ((i = getFreeRegion(base,size)) < 0) - return PM_MTRR_ERR_NONE_FREE; - setMTRR(i,base,size,type); - return PM_MTRR_ERR_OK; -} - -/**************************************************************************** -PARAMETERS: -callback - Function to callback with write combine information - -REMARKS: -Function to enumerate all write combine regions currently enabled for the -processor. -****************************************************************************/ -int PMAPI PM_enumWriteCombine( - PM_enumWriteCombine_t callback) -{ - int i,ltype; - ulong lbase,lsize; - - /* 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; - } - - /* Enumerate all existing MTRR's */ - for (i = 0; i < numMTRR; ++i) { - 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 deleted file mode 100644 index 1d542fc5df..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/common/pcilib.c +++ /dev/null @@ -1,747 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Module for interfacing to the PCI bus and configuration -* space registers. -* -****************************************************************************/ - -#include "pmapi.h" -#include "pcilib.h" -#if !defined(__WIN32_VXD__) && !defined(__NT_DRIVER__) -#include -#endif - -/*---------------------- Macros and type definitions ----------------------*/ - -#pragma pack(1) - -/* Length of the memory mapping for the PCI BIOS */ - -#define BIOS_LIMIT (128 * 1024L - 1) - -/* Macros for accessing the PCI BIOS functions from 32-bit protected mode */ - -#define BIOS32_SIGNATURE (((ulong)'_' << 0) + ((ulong)'3' << 8) + ((ulong)'2' << 16) + ((ulong)'_' << 24)) -#define PCI_SIGNATURE (((ulong)'P' << 0) + ((ulong)'C' << 8) + ((ulong)'I' << 16) + ((ulong)' ' << 24)) -#define PCI_SERVICE (((ulong)'$' << 0) + ((ulong)'P' << 8) + ((ulong)'C' << 16) + ((ulong)'I' << 24)) -#define PCI_BIOS_PRESENT 0xB101 -#define FIND_PCI_DEVICE 0xB102 -#define FIND_PCI_CLASS 0xB103 -#define GENERATE_SPECIAL 0xB106 -#define READ_CONFIG_BYTE 0xB108 -#define READ_CONFIG_WORD 0xB109 -#define READ_CONFIG_DWORD 0xB10A -#define WRITE_CONFIG_BYTE 0xB10B -#define WRITE_CONFIG_WORD 0xB10C -#define WRITE_CONFIG_DWORD 0xB10D -#define GET_IRQ_ROUTING_OPT 0xB10E -#define SET_PCI_IRQ 0xB10F - -/* This is the standard structure used to identify the entry point to the - * BIOS32 Service Directory, as documented in PCI 2.1 BIOS Specicition. - */ - -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; - char chars[16]; - } PCI_bios32; - -/* Structure for a far pointer to call the PCI BIOS services with */ - -typedef struct { - ulong address; - ushort segment; - } PCIBIOS_entry; - -/* Macros to copy a structure that includes dwSize members */ - -#define COPY_STRUCTURE(d,s) memcpy(d,s,MIN((s)->dwSize,(d)->dwSize)) - -#pragma pack() - -/*--------------------------- Global variables ----------------------------*/ - -static uchar *BIOSImage = NULL; /* BIOS image mapping */ -static int PCIBIOSVersion = -1;/* PCI BIOS version */ -static PCIBIOS_entry PCIEntry; /* PCI services entry point */ -static ulong PCIPhysEntry = 0; /* Physical address */ - -/*----------------------------- Implementation ----------------------------*/ - -/* External assembler helper functions */ - -uchar _ASMAPI _BIOS32_service(ulong service,ulong function,ulong *physBase,ulong *length,ulong *serviceOffset,PCIBIOS_entry entry); -ushort _ASMAPI _PCIBIOS_isPresent(ulong i_eax,ulong *o_edx,ushort *o_ax,uchar *o_cl,PCIBIOS_entry entry); -ulong _ASMAPI _PCIBIOS_service(ulong r_eax,ulong r_ebx,ulong r_edi,ulong r_ecx,PCIBIOS_entry entry); -int _ASMAPI _PCIBIOS_getRouting(PCIRoutingOptionsBuffer *buf,PCIBIOS_entry entry); -ibool _ASMAPI _PCIBIOS_setIRQ(int busDev,int intPin,int IRQ,PCIBIOS_entry entry); -ulong _ASMAPI _PCIBIOS_specialCycle(int bus,ulong data,PCIBIOS_entry entry); -ushort _ASMAPI _PCI_getCS(void); - -/**************************************************************************** -REMARKS: -This functions returns the physical address of the PCI BIOS entry point. -****************************************************************************/ -ulong _ASMAPI PCIBIOS_getEntry(void) -{ return PCIPhysEntry; } - -/**************************************************************************** -PARAMETERS: -hwType - Place to store the PCI hardware access mechanism flags -lastBus - Place to store the index of the last PCI bus in the system - -RETURNS: -Version number of the PCI BIOS found. - -REMARKS: -This function determines if the PCI BIOS is present in the system, and if -so returns the information returned by the PCI BIOS detect function. -****************************************************************************/ -static int PCIBIOS_detect( - uchar *hwType, - uchar *lastBus) -{ - ulong signature; - ushort stat,version; - -#ifndef __16BIT__ - PCIBIOS_entry BIOSEntry = {0}; - uchar *BIOSEnd; - PCI_bios32 *BIOSDir; - ulong physBase,length,offset; - - /* Bail if we have already detected no BIOS is present */ - if (PCIBIOSVersion == 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(); - } -#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; - } - return 0; -} - -/**************************************************************************** -PARAMETERS: -info - Array of PCIDeviceInfo structures to check against -index - Index of the current device to check - -RETURNS: -True if the device is a duplicate, false if not. - -REMARKS: -This function goes through the list of all devices preceeding the newly -found device in the info structure, and checks that the device is not a -duplicate of a previous device. Some devices incorrectly enumerate -themselves at different function addresses so we check here to exclude -those cases. -****************************************************************************/ -static ibool CheckDuplicate( - PCIDeviceInfo *info, - PCIDeviceInfo *prev) -{ - /* Ignore devices with a vendor ID of 0 */ - if (info->VendorID == 0) - 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; - return false; -} - -/**************************************************************************** -PARAMETERS: -info - Array of PCIDeviceInfo structures to fill in -maxDevices - Maximum number of of devices to enumerate into array - -RETURNS: -Number of PCI devices found and enumerated on the PCI bus, 0 if not PCI. - -REMARKS: -Function to enumerate all available devices on the PCI bus into an array -of configuration information blocks. -****************************************************************************/ -static int PCI_enumerateMech1( - PCIDeviceInfo info[]) -{ - int bus,device,function,i,numFound = 0; - ulong *lp,tmp; - PCIslot slot = {{0,0,0,0,0,0,1}}; - PCIDeviceInfo pci,prev = {0}; - - /* Try PCI access mechanism 1 */ - PM_outpb(0xCFB,0x01); - 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; - } - PM_outpd(0xCF8,tmp); - - /* No hardware access mechanism 1 found */ - return 0; -} - -/**************************************************************************** -PARAMETERS: -info - Array of PCIDeviceInfo structures to fill in -maxDevices - Maximum number of of devices to enumerate into array - -RETURNS: -Number of PCI devices found and enumerated on the PCI bus, 0 if not PCI. - -REMARKS: -Function to enumerate all available devices on the PCI bus into an array -of configuration information blocks. -****************************************************************************/ -static int PCI_enumerateMech2( - PCIDeviceInfo info[]) -{ - int bus,device,function,i,numFound = 0; - ushort deviceIO; - ulong *lp; - PCIslot slot = {{0,0,0,0,0,0,1}}; - PCIDeviceInfo pci,prev = {0}; - - /* Try PCI access mechanism 2 */ - PM_outpb(0xCFB,0x00); - 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; - } - - /* No hardware access mechanism 2 found */ - return 0; -} - -/**************************************************************************** -REMARKS: -This functions reads a configuration dword via the PCI BIOS. -****************************************************************************/ -static ulong PCIBIOS_readDWORD( - int index, - ulong slot) -{ - return (ulong)_PCIBIOS_service(READ_CONFIG_DWORD,slot >> 8,index,0,PCIEntry); -} - -/**************************************************************************** -PARAMETERS: -info - Array of PCIDeviceInfo structures to fill in -maxDevices - Maximum number of of devices to enumerate into array - -RETURNS: -Number of PCI devices found and enumerated on the PCI bus, 0 if not PCI. - -REMARKS: -Function to enumerate all available devices on the PCI bus into an array -of configuration information blocks. -****************************************************************************/ -static int PCI_enumerateBIOS( - PCIDeviceInfo info[]) -{ - uchar hwType,lastBus; - int bus,device,function,i,numFound = 0; - ulong *lp; - PCIslot slot = {{0,0,0,0,0,0,1}}; - 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; - } - } - } - } - } - - /* Return number of devices found */ - return numFound; -} - -/**************************************************************************** -PARAMETERS: -info - Array of PCIDeviceInfo structures to fill in -maxDevices - Maximum number of of devices to enumerate into array - -RETURNS: -Number of PCI devices found and enumerated on the PCI bus, 0 if not PCI. - -REMARKS: -Function to enumerate all available devices on the PCI bus into an array -of configuration information blocks. -****************************************************************************/ -int _ASMAPI PCI_enumerate( - PCIDeviceInfo info[]) -{ - int numFound; - - /* First try via the direct access mechanisms which are faster if we - * have them (nearly always). The BIOS is used as a fallback, and for - * 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; - } - } - return numFound; -} - -/**************************************************************************** -PARAMETERS: -info - Array of PCIDeviceInfo structures to fill in -maxDevices - Maximum number of of devices to enumerate into array - -RETURNS: -Number of PCI devices found and enumerated on the PCI bus, 0 if not PCI. - -REMARKS: -Function to enumerate all available devices on the PCI bus into an array -of configuration information blocks. -****************************************************************************/ -int _ASMAPI PCI_getNumDevices(void) -{ - return PCI_enumerate(NULL); -} - -/**************************************************************************** -PARAMETERS: -bar - Base address to measure -pci - PCI device to access - -RETURNS: -Size of the PCI base address in bytes - -REMARKS: -This function measures the size of the PCI base address register in bytes, -by writing all F's to the register, and reading the value back. The size -of the base address is determines by the bits that are hardwired to zero's. -****************************************************************************/ -ulong _ASMAPI PCI_findBARSize( - int bar, - PCIDeviceInfo *pci) -{ - ulong base,size = 0; - - 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); - } - } - pci->slot.p.Register = 0; - return size; -} - -/**************************************************************************** -PARAMETERS: -index - DWORD index of the register to access -value - Value to write to the register for write access -func - Function to implement - -RETURNS: -The value read from the register for read operations - -REMARKS: -The function code are defined as follows - -code - function -0 - Read BYTE -1 - Read WORD -2 - Read DWORD -3 - Write BYTE -4 - Write WORD -5 - Write DWORD -****************************************************************************/ -ulong _ASMAPI PCI_accessReg( - int index, - ulong value, - int func, - PCIDeviceInfo *info) -{ - 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; - } - } - 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); - } - return value; -} - -/**************************************************************************** -PARAMETERS: -numDevices - Number of devices to query info for - -RETURNS: -0 on success, -1 on error, number of devices to enumerate if numDevices = 0 - -REMARKS: -This function reads the PCI routing information. If you pass a value of -0 for numDevices, this function will return with the number of devices -needed in the routing buffer that will be filled in by the BIOS. -****************************************************************************/ -ibool _ASMAPI PCI_getIRQRoutingOptions( - int numDevices, - PCIRouteInfo *buffer) -{ - PCIRoutingOptionsBuffer buf; - 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; - } - - /* We currently only support this via the PCI BIOS functions */ - return -1; -} - -/**************************************************************************** -PARAMETERS: -info - PCI device information for the specified device -intPin - Value to store in the PCI InterruptPin register -IRQ - New ISA IRQ to map the PCI interrupt to (0-15) - -RETURNS: -True on success, or false if this function failed. - -REMARKS: -This function changes the PCI IRQ routing for the specified device to the -desired PCI interrupt and the desired ISA bus compatible IRQ. This function -may not be supported by the PCI BIOS, in which case this function will -fail. -****************************************************************************/ -ibool _ASMAPI PCI_setHardwareIRQ( - PCIDeviceInfo *info, - uint intPin, - 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; - } - - /* We currently only support this via the PCI BIOS functions */ - return false; -} - -/**************************************************************************** -PARAMETERS: -bus - Bus number to generate the special cycle for -specialCycleData - Data to send for the special cyle - -REMARKS: -This function generates a special cycle on the specified bus using with -the specified data. -****************************************************************************/ -void _ASMAPI PCI_generateSpecialCyle( - uint bus, - ulong specialCycleData) -{ - if (PCIPhysEntry) - _PCIBIOS_specialCycle(bus,specialCycleData,PCIEntry); - /* We currently only support this via the PCI BIOS functions */ -} - -/**************************************************************************** -PARAMETERS: -info - PCI device information block for device to access -index - Index of register to start reading from -dst - Place to store the values read from configuration space -count - Count of bytes to read from configuration space - -REMARKS: -This function is used to read a block of PCI configuration space registers -from the configuration space into the passed in data block. This function -will properly handle reading non-DWORD aligned data from the configuration -space correctly. -****************************************************************************/ -void _ASMAPI PCI_readRegBlock( - PCIDeviceInfo *info, - int index, - void *dst, - int count) -{ - uchar *pb; - ulong *pd; - int i; - int startCount = (index & 3); - int middleCount = (count - startCount) >> 2; - 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); - } - for (i = 0,pd = (ulong*)pb; i < middleCount; i++, index += 4) { - *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); - } -} - -/**************************************************************************** -PARAMETERS: -info - PCI device information block for device to access -index - Index of register to start reading from -dst - Place to store the values read from configuration space -count - Count of bytes to read from configuration space - -REMARKS: -This function is used to write a block of PCI configuration space registers -to the configuration space from the passed in data block. This function -will properly handle writing non-DWORD aligned data to the configuration -space correctly. -****************************************************************************/ -void _ASMAPI PCI_writeRegBlock( - PCIDeviceInfo *info, - int index, - void *src, - int count) -{ - uchar *pb; - ulong *pd; - int i; - int startCount = (index & 3); - int middleCount = (count - startCount) >> 2; - int endCount = count - middleCount * 4 - startCount; - - for (i = 0,pb = src; i < startCount; i++, index++) { - 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); - } - for (i = 0,pb = (uchar*)pd; i < endCount; i++, index++) { - 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 deleted file mode 100644 index c3a66a7c14..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/common/unixio.c +++ /dev/null @@ -1,306 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Module containing Unix I/O functions. -* -****************************************************************************/ - -#include "pmapi.h" -#include -#include -#include -#include -#include -#include - -/*----------------------------- Implementation ----------------------------*/ - -/* {secret} */ -typedef struct { - DIR *d; - char path[PM_MAX_PATH]; - char mask[PM_MAX_PATH]; - } PM_findHandle; - -/**************************************************************************** -REMARKS: -Internal function to convert the find data to the generic interface. -****************************************************************************/ -static void convertFindData( - PM_findData *findData, - struct dirent *blk, - const char *path) -{ - ulong dwSize = findData->dwSize; - struct stat st; - char filename[PM_MAX_PATH]; - - memset(findData,0,findData->dwSize); - findData->dwSize = dwSize; - strcpy(filename,path); - PM_backslash(filename); - strcat(filename,blk->d_name); - stat(filename,&st); - if (!(st.st_mode & S_IWRITE)) - findData->attrib |= PM_FILE_READONLY; - if (st.st_mode & S_IFDIR) - findData->attrib |= PM_FILE_DIRECTORY; - findData->sizeLo = st.st_size; - findData->sizeHi = 0; - strncpy(findData->name,blk->d_name,PM_MAX_PATH); - findData->name[PM_MAX_PATH-1] = 0; -} - -/**************************************************************************** -REMARKS: -Determines if a file name matches the passed in pattern. -****************************************************************************/ -static ibool filematch( - char *pattern, - char *dirpath, - struct dirent *dire) -{ - struct stat st; - int i = 0,j = 0,lastchar = '\0'; - char fullpath[PM_MAX_PATH]; - - strcpy(fullpath,dirpath); - PM_backslash(fullpath); - strcat(fullpath, dire->d_name); - if (stat(fullpath, &st) != 0) - 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 (j == (int)strlen(pattern) && i == (int)strlen(dire->d_name)) - return true; - return false; -} - -/**************************************************************************** -REMARKS: -Function to find the first file matching a search criteria in a directory. -****************************************************************************/ -void * PMAPI PM_findFirstFile( - const char *filename, - PM_findData *findData) -{ - PM_findHandle *d; - struct dirent *dire; - char name[PM_MAX_PATH]; - char ext[PM_MAX_PATH]; - - if ((d = PM_malloc(sizeof(*d))) == NULL) - 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, "."); - if (d->path[strlen(d->path)-1] == '/') - 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); - } - PM_free(d); - return PM_FILE_INVALID; -} - -/**************************************************************************** -REMARKS: -Function to find the next file matching a search criteria in a directory. -****************************************************************************/ -ibool PMAPI PM_findNextFile( - void *handle, - PM_findData *findData) -{ - PM_findHandle *d = handle; - struct dirent *dire; - - while ((dire = readdir(d->d)) != NULL) { - if (filematch(d->mask,d->path,dire)) { - convertFindData(findData,dire,d->path); - return true; - } - } - return false; -} - -/**************************************************************************** -REMARKS: -Function to close the find process -****************************************************************************/ -void PMAPI PM_findClose( - void *handle) -{ - PM_findHandle *d = handle; - - closedir(d->d); - free(d); -} - -/**************************************************************************** -REMARKS: -Function to determine if a drive is a valid drive or not. Under Unix this -function will return false for anything except a value of 3 (considered -the root drive, and equivalent to C: for non-Unix systems). The drive -numbering is: - - 1 - Drive A: - 2 - Drive B: - 3 - Drive C: - etc - -****************************************************************************/ -ibool PMAPI PM_driveValid( - char drive) -{ - if (drive == 3) - return true; - return false; -} - -/**************************************************************************** -REMARKS: -Function to get the current working directory for the specififed drive. -Under Unix this will always return the current working directory regardless -of what the value of 'drive' is. -****************************************************************************/ -void PMAPI PM_getdcwd( - int drive, - char *dir, - int len) -{ - (void)drive; - getcwd(dir,len); -} - -/**************************************************************************** -REMARKS: -Function to change the file attributes for a specific file. -****************************************************************************/ -void PMAPI PM_setFileAttr( - const char *filename, - uint attrib) -{ - struct stat st; - mode_t mode; - - stat(filename,&st); - mode = st.st_mode; - if (attrib & PM_FILE_READONLY) - mode &= ~S_IWRITE; - else - mode |= S_IWRITE; - chmod(filename,mode); -} - -/**************************************************************************** -REMARKS: -Function to get the file attributes for a specific file. -****************************************************************************/ -uint PMAPI PM_getFileAttr( - const char *filename) -{ - struct stat st; - - stat(filename,&st); - if (st.st_mode & S_IWRITE) - return 0; - return PM_FILE_READONLY; -} - -/**************************************************************************** -REMARKS: -Function to create a directory. -****************************************************************************/ -ibool PMAPI PM_mkdir( - const char *filename) -{ - return mkdir(filename,0x1FF) == 0; -} - -/**************************************************************************** -REMARKS: -Function to remove a directory. -****************************************************************************/ -ibool PMAPI PM_rmdir( - const char *filename) -{ - return rmdir(filename) == 0; -} - -/**************************************************************************** -REMARKS: -Function to get the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_getFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - /* TODO: Implement this! */ - (void)filename; - (void)gmTime; - (void)time; - PM_fatalError("PM_getFileTime not implemented yet!"); - return false; -} - -/**************************************************************************** -REMARKS: -Function to set the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_setFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - /* 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/common/vgastate.c b/board/MAI/bios_emulator/scitech/src/pm/common/vgastate.c deleted file mode 100644 index 8056e9a33f..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/common/vgastate.c +++ /dev/null @@ -1,377 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Portions copyright (C) Josh Vanderhoof -* -* Language: ANSI C -* Environment: Any -* -* Description: Functions to save and restore the VGA hardware state. -* -****************************************************************************/ - -#include "pmapi.h" -#if defined(__WIN32_VXD__) || defined(__NT_DRIVER__) -#include "sdd/sddhelp.h" -#else -#include -#endif - -/*--------------------------- Global variables ----------------------------*/ - -/* VGA index register ports */ -#define CRT_I 0x3D4 /* CRT Controller Index */ -#define ATT_IW 0x3C0 /* Attribute Controller Index & Data */ -#define GRA_I 0x3CE /* Graphics Controller Index */ -#define SEQ_I 0x3C4 /* Sequencer Index */ - -/* VGA data register ports */ -#define CRT_D 0x3D5 /* CRT Controller Data Register */ -#define ATT_R 0x3C1 /* Attribute Controller Data Read Register */ -#define GRA_D 0x3CF /* Graphics Controller Data Register */ -#define SEQ_D 0x3C5 /* Sequencer Data Register */ -#define MIS_R 0x3CC /* Misc Output Read Register */ -#define MIS_W 0x3C2 /* Misc Output Write Register */ -#define IS1_R 0x3DA /* Input Status Register 1 */ -#define PEL_IW 0x3C8 /* PEL Write Index */ -#define PEL_IR 0x3C7 /* PEL Read Index */ -#define PEL_D 0x3C9 /* PEL Data Register */ - -/* standard VGA indexes max counts */ -#define CRT_C 24 /* 24 CRT Controller Registers */ -#define ATT_C 21 /* 21 Attribute Controller Registers */ -#define GRA_C 9 /* 9 Graphics Controller Registers */ -#define SEQ_C 5 /* 5 Sequencer Registers */ -#define MIS_C 1 /* 1 Misc Output Register */ -#define PAL_C 768 /* 768 Palette Registers */ -#define FONT_C 8192 /* Total size of character generator RAM */ - -/* VGA registers saving indexes */ -#define CRT 0 /* CRT Controller Registers start */ -#define ATT (CRT+CRT_C) /* Attribute Controller Registers start */ -#define GRA (ATT+ATT_C) /* Graphics Controller Registers start */ -#define SEQ (GRA+GRA_C) /* Sequencer Registers */ -#define MIS (SEQ+SEQ_C) /* General Registers */ -#define PAL (MIS+MIS_C) /* VGA Palette Registers */ -#define FONT (PAL+PAL_C) /* VGA font data */ - -/* Macros for port I/O with arguments reversed */ - -#define _port_out(v,p) PM_outpb(p,(uchar)(v)) -#define _port_in(p) PM_inpb(p) - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Returns the size of the VGA state buffer. -****************************************************************************/ -int PMAPI PM_getVGAStateSize(void) -{ - return CRT_C + ATT_C + GRA_C + SEQ_C + MIS_C + PAL_C + FONT_C; -} - -/**************************************************************************** -REMARKS: -Delay for a short period of time. -****************************************************************************/ -static void vga_delay(void) -{ - int i; - - /* For the loop here we program the POST register. The length of this - * delay is dependant only on ISA bus speed, but it is enough for - * what we need. - */ - for (i = 0; i <= 10; i++) - PM_outpb(0x80, 0); -} - -/**************************************************************************** -PARAMETERS: -port - I/O port to read value from -index - Port index to read - -RETURNS: -Byte read from 'port' register 'index'. -****************************************************************************/ -static ushort vga_rdinx( - ushort port, - ushort index) -{ - PM_outpb(port,(uchar)index); - return PM_inpb(port+1); -} - -/**************************************************************************** -PARAMETERS: -port - I/O port to write to -index - Port index to write -value - Byte to write to port - -REMARKS: -Writes a byte value to the 'port' register 'index'. -****************************************************************************/ -static void vga_wrinx( - ushort port, - ushort index, - ushort value) -{ - PM_outpb(port,(uchar)index); - PM_outpb(port+1,(uchar)value); -} - -/**************************************************************************** -REMARKS: -Save the color palette values -****************************************************************************/ -static void vga_savepalette( - uchar *pal) -{ - int i; - - _port_out(0, PEL_IR); - for (i = 0; i < 768; i++) { - vga_delay(); - *pal++ = _port_in(PEL_D); - } -} - -/**************************************************************************** -REMARKS: -Restore the color palette values -****************************************************************************/ -static void vga_restorepalette( - const uchar *pal) -{ - int i; - - /* restore saved palette */ - _port_out(0, PEL_IW); - for (i = 0; i < 768; i++) { - vga_delay(); - _port_out(*pal++, PEL_D); - } -} - -/**************************************************************************** -REMARKS: -Read the font data from the VGA character generator RAM -****************************************************************************/ -static void vga_saveFont( - uchar *data) -{ - uchar *A0000Ptr = PM_getA0000Pointer(); - uchar save[7]; - - /* Enable access to character generator RAM */ - save[0] = (uchar)vga_rdinx(SEQ_I,0x00); - save[1] = (uchar)vga_rdinx(SEQ_I,0x02); - save[2] = (uchar)vga_rdinx(SEQ_I,0x04); - save[3] = (uchar)vga_rdinx(SEQ_I,0x00); - save[4] = (uchar)vga_rdinx(GRA_I,0x04); - save[5] = (uchar)vga_rdinx(GRA_I,0x05); - save[6] = (uchar)vga_rdinx(GRA_I,0x06); - vga_wrinx(SEQ_I,0x00,0x01); - vga_wrinx(SEQ_I,0x02,0x04); - vga_wrinx(SEQ_I,0x04,0x07); - vga_wrinx(SEQ_I,0x00,0x03); - vga_wrinx(GRA_I,0x04,0x02); - vga_wrinx(GRA_I,0x05,0x00); - vga_wrinx(GRA_I,0x06,0x00); - - /* Copy character generator RAM */ - memcpy(data,A0000Ptr,FONT_C); - - /* Restore VGA state */ - vga_wrinx(SEQ_I,0x00,save[0]); - vga_wrinx(SEQ_I,0x02,save[1]); - vga_wrinx(SEQ_I,0x04,save[2]); - vga_wrinx(SEQ_I,0x00,save[3]); - vga_wrinx(GRA_I,0x04,save[4]); - vga_wrinx(GRA_I,0x05,save[5]); - vga_wrinx(GRA_I,0x06,save[6]); -} - -/**************************************************************************** -REMARKS: -Downloads the font data to the VGA character generator RAM -****************************************************************************/ -static void vga_restoreFont( - const uchar *data) -{ - uchar *A0000Ptr = PM_getA0000Pointer(); - - /* Enable access to character generator RAM */ - vga_wrinx(SEQ_I,0x00,0x01); - vga_wrinx(SEQ_I,0x02,0x04); - vga_wrinx(SEQ_I,0x04,0x07); - vga_wrinx(SEQ_I,0x00,0x03); - vga_wrinx(GRA_I,0x04,0x02); - vga_wrinx(GRA_I,0x05,0x00); - vga_wrinx(GRA_I,0x06,0x00); - - /* Copy font back to character generator RAM */ - memcpy(A0000Ptr,data,FONT_C); -} - -/**************************************************************************** -REMARKS: -Save the state of all VGA compatible registers -****************************************************************************/ -void PMAPI PM_saveVGAState( - void *stateBuf) -{ - uchar *regs = stateBuf; - int i; - - /* Save state of VGA registers */ - for (i = 0; i < CRT_C; i++) { - _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(); - } - for (i = 0; i < GRA_C; i++) { - _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); - } - regs[MIS] = _port_in(MIS_R); - - /* Save the VGA palette values */ - vga_savepalette(®s[PAL]); - - /* Save the VGA character generator RAM */ - vga_saveFont(®s[FONT]); - - /* Turn the VGA display back on */ - PM_vgaUnblankDisplay(); -} - -/**************************************************************************** -REMARKS: -Retore the state of all VGA compatible registers -****************************************************************************/ -void PMAPI PM_restoreVGAState( - const void *stateBuf) -{ - const uchar *regs = stateBuf; - int i; - - /* Blank the display before we start the restore */ - PM_vgaBlankDisplay(); - - /* Restore the VGA character generator RAM */ - vga_restoreFont(®s[FONT]); - - /* Restore the VGA palette values */ - vga_restorepalette(®s[PAL]); - - /* Restore the state of the VGA compatible registers */ - _port_out(regs[MIS], MIS_W); - - /* Delay to allow clock change to settle */ - for (i = 0; i < 10; i++) - vga_delay(); - - /* Synchronous reset on */ - _port_out(0x00,SEQ_I); - _port_out(0x01,SEQ_D); - - /* Write seqeuencer registers */ - _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); - } - - /* Synchronous reset off */ - _port_out(0x00,SEQ_I); - _port_out(0x03,SEQ_D); - - /* Deprotect CRT registers 0-7 and write CRTC */ - _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); - } - for (i = 0; i < GRA_C; i++) { - _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(); - } - - /* Ensure the VGA screen is turned on */ - PM_vgaUnblankDisplay(); -} - -/**************************************************************************** -REMARKS: -Disables the VGA display for screen output making it blank. -****************************************************************************/ -void PMAPI PM_vgaBlankDisplay(void) -{ - /* Turn screen off */ - _port_out(0x01, SEQ_I); - _port_out(_port_in(SEQ_D) | 0x20, SEQ_D); - - /* Disable video output */ - _port_in(IS1_R); - vga_delay(); - _port_out(0x00, ATT_IW); -} - -/**************************************************************************** -REMARKS: -Enables the VGA display for screen output. -****************************************************************************/ -void PMAPI PM_vgaUnblankDisplay(void) -{ - /* Turn screen back on */ - _port_out(0x01, SEQ_I); - _port_out(_port_in(SEQ_D) & 0xDF, SEQ_D); - - /* Enable video output */ - _port_in(IS1_R); - vga_delay(); - _port_out(0x20, ATT_IW); -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/cpuinfo.c deleted file mode 100644 index ac62e81c10..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/cpuinfo.c +++ /dev/null @@ -1,808 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Main module to implement the Zen Timer support functions. -* -****************************************************************************/ - -#include "ztimer.h" -#include "pmapi.h" -#include "oshdr.h" -#if !defined(__WIN32_VXD__) && !defined(__OS2_VDD__) && !defined(__NT_DRIVER__) -#include -#include -#endif - -/*----------------------------- Implementation ----------------------------*/ - -/* External Intel assembler functions */ -#ifdef __INTEL__ -/* {secret} */ -ibool _ASMAPI _CPU_haveCPUID(void); -/* {secret} */ -ibool _ASMAPI _CPU_check80386(void); -/* {secret} */ -ibool _ASMAPI _CPU_check80486(void); -/* {secret} */ -uint _ASMAPI _CPU_checkCPUID(void); -/* {secret} */ -uint _ASMAPI _CPU_getCPUIDModel(void); -/* {secret} */ -uint _ASMAPI _CPU_getCPUIDStepping(void); -/* {secret} */ -uint _ASMAPI _CPU_getCPUIDFeatures(void); -/* {secret} */ -uint _ASMAPI _CPU_getCacheSize(void); -/* {secret} */ -uint _ASMAPI _CPU_have3DNow(void); -/* {secret} */ -ibool _ASMAPI _CPU_checkClone(void); -/* {secret} */ -void _ASMAPI _CPU_readTimeStamp(CPU_largeInteger *time); -/* {secret} */ -void _ASMAPI _CPU_runBSFLoop(ulong iterations); -/* {secret} */ -ulong _ASMAPI _CPU_mulDiv(ulong a,ulong b,ulong c); -/* {secret} */ -void ZTimerQuickInit(void); -#define CPU_HaveMMX 0x00800000 -#define CPU_HaveRDTSC 0x00000010 -#define CPU_HaveSSE 0x02000000 -#endif - -#if defined(__SMX32__) -#include "smx/cpuinfo.c" -#elif defined(__RTTARGET__) -#include "rttarget/cpuinfo.c" -#elif defined(__REALDOS__) -#include "dos/cpuinfo.c" -#elif defined(__NT_DRIVER__) -#include "ntdrv/cpuinfo.c" -#elif defined(__WIN32_VXD__) -#include "vxd/cpuinfo.c" -#elif defined(__WINDOWS32__) -#include "win32/cpuinfo.c" -#elif defined(__OS2_VDD__) -#include "vdd/cpuinfo.c" -#elif defined(__OS2__) -#include "os2/cpuinfo.c" -#elif defined(__LINUX__) -#include "linux/cpuinfo.c" -#elif defined(__QNX__) -#include "qnx/cpuinfo.c" -#elif defined(__BEOS__) -#include "beos/cpuinfo.c" -#else -#error CPU library not ported to this platform yet! -#endif - -/*------------------------ Public interface routines ----------------------*/ - -/**************************************************************************** -REMARKS: -Read an I/O port location. -****************************************************************************/ -static uchar rdinx( - int port, - int index) -{ - PM_outpb(port,(uchar)index); - return PM_inpb(port+1); -} - -/**************************************************************************** -REMARKS: -Write an I/O port location. -****************************************************************************/ -static void wrinx( - ushort port, - ushort index, - ushort value) -{ - PM_outpb(port,(uchar)index); - PM_outpb(port+1,(uchar)value); -} - -/**************************************************************************** -REMARKS: -Enables the Cyrix CPUID instruction to properly detect MediaGX and 6x86 -processors. -****************************************************************************/ -static void _CPU_enableCyrixCPUID(void) -{ - uchar ccr3; - - PM_init(); - ccr3 = rdinx(0x22,0xC3); - wrinx(0x22,0xC3,(uchar)(ccr3 | 0x10)); - wrinx(0x22,0xE8,(uchar)(rdinx(0x22,0xE8) | 0x80)); - wrinx(0x22,0xC3,ccr3); -} - -/**************************************************************************** -DESCRIPTION: -Returns the type of processor in the system. - -HEADER: -ztimer.h - -RETURNS: -Numerical identifier for the installed processor - -REMARKS: -Returns the type of processor in the system. Note that if the CPU is an -unknown Pentium family processor that we don't have an enumeration for, -the return value will be greater than or equal to the value of CPU_UnkPentium -(depending on the value returned by the CPUID instruction). - -SEE ALSO: -CPU_getProcessorSpeed, CPU_haveMMX, CPU_getProcessorName -****************************************************************************/ -uint ZAPI CPU_getProcessorType(void) -{ -#if defined(__INTEL__) - uint cpu,vendor,model,cacheSize; - 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); - } - 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; - } -#elif defined(__ALPHA__) - return CPU_Alpha; -#elif defined(__MIPS__) - return CPU_Mips; -#elif defined(__PPC__) - return CPU_PowerPC; -#endif -} - -/**************************************************************************** -DESCRIPTION: -Returns true if the processor supports Intel MMX extensions. - -HEADER: -ztimer.h - -RETURNS: -True if MMX is available, false if not. - -REMARKS: -This function determines if the processor supports the Intel MMX extended -instruction set. - -SEE ALSO: -CPU_getProcessorType, CPU_getProcessorSpeed, CPU_have3DNow, CPU_haveSSE, -CPU_getProcessorName -****************************************************************************/ -ibool ZAPI CPU_haveMMX(void) -{ -#ifdef __INTEL__ - if (_CPU_haveCPUID()) - return (_CPU_getCPUIDFeatures() & CPU_HaveMMX) != 0; - return false; -#else - return false; -#endif -} - -/**************************************************************************** -DESCRIPTION: -Returns true if the processor supports AMD 3DNow! extensions. - -HEADER: -ztimer.h - -RETURNS: -True if 3DNow! is available, false if not. - -REMARKS: -This function determines if the processor supports the AMD 3DNow! extended -instruction set. - -SEE ALSO: -CPU_getProcessorType, CPU_getProcessorSpeed, CPU_haveMMX, CPU_haveSSE, -CPU_getProcessorName -****************************************************************************/ -ibool ZAPI CPU_have3DNow(void) -{ -#ifdef __INTEL__ - if (_CPU_haveCPUID()) - return _CPU_have3DNow(); - return false; -#else - return false; -#endif -} - -/**************************************************************************** -DESCRIPTION: -Returns true if the processor supports Intel KNI extensions. - -HEADER: -ztimer.h - -RETURNS: -True if Intel KNI is available, false if not. - -REMARKS: -This function determines if the processor supports the Intel KNI extended -instruction set. - -SEE ALSO: -CPU_getProcessorType, CPU_getProcessorSpeed, CPU_haveMMX, CPU_have3DNow, -CPU_getProcessorName -****************************************************************************/ -ibool ZAPI CPU_haveSSE(void) -{ -#ifdef __INTEL__ - if (_CPU_haveCPUID()) - return (_CPU_getCPUIDFeatures() & CPU_HaveSSE) != 0; - return false; -#else - return false; -#endif -} - -/**************************************************************************** -RETURNS: -True if the RTSC instruction is available, false if not. - -REMARKS: -This function determines if the processor supports the Intel RDTSC -instruction, for high precision timing. If the processor is not an Intel or -Intel clone CPU, this function will always return false. - -DESCRIPTION: -Returns true if the processor supports RDTSC extensions. - -HEADER: -ztimer.h - -RETURNS: -True if RTSC is available, false if not. - -REMARKS: -This function determines if the processor supports the RDTSC instruction -for reading the processor time stamp counter. - -SEE ALSO: -CPU_getProcessorType, CPU_getProcessorSpeed, CPU_haveMMX, CPU_have3DNow, -CPU_getProcessorName -****************************************************************************/ -ibool ZAPI CPU_haveRDTSC(void) -{ -#ifdef __INTEL__ - if (_CPU_haveCPUID()) - return (_CPU_getCPUIDFeatures() & CPU_HaveRDTSC) != 0; - return false; -#else - return false; -#endif -} - -#ifdef __INTEL__ - -#define ITERATIONS 16000 -#define SAMPLINGS 2 -#define INNER_LOOPS 400 - -/**************************************************************************** -REMARKS: -If processor does not support time stamp reading, but is at least a 386 or -above, utilize method of timing a loop of BSF instructions which take a -known number of cycles to run on i386(tm), i486(tm), and Pentium(R) -processors. -****************************************************************************/ -static ulong GetBSFCpuSpeed( - ulong cycles) -{ - CPU_largeInteger t0,t1,count_freq; - ulong ticks; /* Microseconds elapsed during test */ - ulong current; /* Variable to store time elapsed */ - int i,j,iPriority; - ulong lowest = (ulong)-1; - - 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; - } - 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 */ - if (ticks == 0) - return 0; - return ((cycles*INNER_LOOPS)/ticks); -} - -#define TOLERANCE 1 - -/**************************************************************************** -REMARKS: -On processors supporting the Read Time Stamp opcode, compare elapsed -time on the High-Resolution Counter with elapsed cycles on the Time -Stamp Register. - -The inner loop runs up to 20 times oruntil the average of the previous -three calculated frequencies is within 1 MHz of each of the individual -calculated frequencies. This resampling increases the accuracy of the -results since outside factors could affect this calculation. -****************************************************************************/ -static ulong GetRDTSCCpuSpeed( - ibool accurate) -{ - CPU_largeInteger t0,t1,s0,s1,count_freq; - u64 stamp0, stamp1, ticks0, ticks1; - u64 total_cycles, cycles, hz, freq; - u64 total_ticks, ticks; - int tries,iPriority; - ulong maxCount; - - PM_set64_32(total_cycles,0); - PM_set64_32(total_ticks,0); - maxCount = accurate ? 600000 : 30000; - iPriority = SetMaxThreadPriority(); - 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); - } - RestoreThreadPriority(iPriority); - - /* Compute frequency in Hz */ - PM_mul64(hz,total_cycles,freq); - PM_div64(hz,hz,total_ticks); - return PM_64to32(hz); -} - -#endif /* __INTEL__ */ - -/**************************************************************************** -DESCRIPTION: -Returns the speed of the processor in MHz. - -HEADER: -ztimer.h - -PARAMETERS: -accurate - True of the speed should be measured accurately - -RETURNS: -Processor speed in MHz. - -REMARKS: -This function returns the speed of the CPU in MHz. Note that if the speed -cannot be determined, this function will return 0. - -If the accurate parameter is set to true, this function will spend longer -profiling the speed of the CPU, and will not round the CPU speed that is -reported. This is important for highly accurate timing using the Pentium -RDTSC instruction, but it does take a lot longer for the profiling to -produce accurate results. - -SEE ALSO: -CPU_getProcessorSpeedInHz, CPU_getProcessorType, CPU_haveMMX, -CPU_getProcessorName -****************************************************************************/ -ulong ZAPI CPU_getProcessorSpeed( - ibool accurate) -{ -#if defined(__INTEL__) - /* Number of cycles needed to execute a single BSF instruction on i386+ - * processors. - */ - ulong cpuSpeed; - uint i; - static ulong intel_cycles[] = { - 115,47,43, - }; - static ulong cyrix_cycles[] = { - 38,38,52,52, - }; - static ulong amd_cycles[] = { - 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, - }; - - if (CPU_haveRDTSC()) { - 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; - } - - /* 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]; - } - } - } - return cpuSpeed; -#else - return 0; -#endif -} - -/**************************************************************************** -DESCRIPTION: -Returns the speed of the processor in Hz. - -HEADER: -ztimer.h - -RETURNS: -Accurate processor speed in Hz. - -REMARKS: -This function returns the accurate speed of the CPU in Hz. Note that if the -speed cannot be determined, this function will return 0. - -This function is similar to the CPU_getProcessorSpeed function, except that -it attempts to accurately measure the CPU speed in Hz. This is used -internally in the Zen Timer libraries to provide accurate real world timing -information. This is important for highly accurate timing using the Pentium -RDTSC instruction, but it does take a lot longer for the profiling to -produce accurate results. - -SEE ALSO: -CPU_getProcessorSpeed, CPU_getProcessorType, CPU_haveMMX, -CPU_getProcessorName -****************************************************************************/ -ulong ZAPI CPU_getProcessorSpeedInHZ( - ibool accurate) -{ -#if defined(__INTEL__) - if (CPU_haveRDTSC()) { - return GetRDTSCCpuSpeed(accurate); - } - return CPU_getProcessorSpeed(false) * 1000000; -#else - return 0; -#endif -} - -/**************************************************************************** -DESCRIPTION: -Returns a string defining the speed and name of the processor. - -HEADER: -ztimer.h - -RETURNS: -Processor name string. - -REMARKS: -This function returns an English string describing the speed and name of the -CPU. - -SEE ALSO: -CPU_getProcessorType, CPU_haveMMX, CPU_getProcessorName -****************************************************************************/ -char * ZAPI CPU_getProcessorName(void) -{ -#if defined(__INTEL__) - static int cpu,speed = -1; - static char name[80]; - - if (speed == -1) { - 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"); - } - if (CPU_haveMMX()) - strcat(name," with MMX(R)"); - if (CPU_have3DNow()) - strcat(name,", 3DNow!(R)"); - if (CPU_haveSSE()) - strcat(name,", SSE(R)"); - return name; -#else - return "Unknown"; -#endif -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/debug.c b/board/MAI/bios_emulator/scitech/src/pm/debug.c deleted file mode 100644 index 751bf098fc..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/debug.c +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Main module containing debug checking features. -* -****************************************************************************/ - -#include "pmapi.h" -#ifdef __WIN32_VXD__ -#include "vxdfile.h" -#elif defined(__NT_DRIVER__) -#include "ntdriver.h" -#elif defined(__OS2_VDD__) -#include "vddfile.h" -#else -#include -#include -#include -#endif - -/*---------------------------- Global variables ---------------------------*/ - -/* {secret} */ -void (*_CHK_fail)(int fatal,const char *msg,const char *cond,const char *file,int line) = _CHK_defaultFail; -static char logFile[256] = ""; - -/*----------------------------- Implementation ----------------------------*/ - -#ifdef CHECKED -void _CHK_defaultFail( - int fatal, - const char *msg, - const char *cond, - const char *file, - int line) -{ - FILE *f; - char buf[256]; - - if (logFile[0] == 0) { - 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); -#else - fprintf(f,msg,cond,file,line); -#endif - fclose(f); - } - if (fatal) { - sprintf(buf,"Check failed: check '%s' for details", logFile); - PM_fatalError(buf); - } -} -#endif - -/**************************************************************************** -DESCRIPTION: -Sets the location of the debug log file. - -HEADER: -pmapi.h - -PARAMETERS: -logFilePath - Full file and path name to debug log file. - -REMARKS: -Sets the name and location of the debug log file. The debug log file is -created and written to when runtime checks, warnings and failure conditions -are logged to disk when code is compiled in CHECKED mode. By default the -log file is called 'scitech.log' and goes into the current SciTech Nucleus -path for the application. You can use this function to set the filename -and location of the debug log file to your own application specific -directory. -****************************************************************************/ -void PMAPI PM_setDebugLog( - const char *logFilePath) -{ - strcpy(logFile,logFilePath); -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/dos/_event.asm b/board/MAI/bios_emulator/scitech/src/pm/dos/_event.asm deleted file mode 100644 index 36dcaab67b..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/_event.asm +++ /dev/null @@ -1,194 +0,0 @@ -;**************************************************************************** -;* -;* SciTech Multi-platform Graphics Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: 80386 Assembler -;* Environment: IBM PC (MS DOS) -;* -;* Description: Assembly language support routines for the event module. -;* -;**************************************************************************** - - ideal - -include "scitech.mac" ; Memory model macros - -ifdef flatmodel - -header _event ; Set up memory model - -begdataseg _event - - cextern _EVT_biosPtr,DPTR - -ifdef USE_NASM -%define KB_HEAD WORD esi+01Ah ; Keyboard buffer head in BIOS data area -%define KB_TAIL WORD esi+01Ch ; Keyboard buffer tail in BIOS data area -%define KB_START WORD esi+080h ; Start of keyboard buffer in BIOS data area -%define KB_END WORD esi+082h ; End of keyboard buffer in BIOS data area -else -KB_HEAD EQU WORD esi+01Ah ; Keyboard buffer head in BIOS data area -KB_TAIL EQU WORD esi+01Ch ; Keyboard buffer tail in BIOS data area -KB_START EQU WORD esi+080h ; Start of keyboard buffer in BIOS data area -KB_END EQU WORD esi+082h ; End of keyboard buffer in BIOS data area -endif - -enddataseg _event - -begcodeseg _event ; Start of code segment - - cpublic _EVT_codeStart - -;---------------------------------------------------------------------------- -; int _EVT_getKeyCode(void) -;---------------------------------------------------------------------------- -; Returns the key code for the next available key by extracting it from -; the BIOS keyboard buffer. -;---------------------------------------------------------------------------- -cprocstart _EVT_getKeyCode - - enter_c - - mov esi,[_EVT_biosPtr] - xor ebx,ebx - xor eax,eax - mov bx,[KB_HEAD] - cmp bx,[KB_TAIL] - jz @@Done - xor eax,eax - mov ax,[esi+ebx] ; EAX := character from keyboard buffer - inc _bx - inc _bx - cmp bx,[KB_END] ; Hit the end of the keyboard buffer? - jl @@1 - mov bx,[KB_START] -@@1: mov [KB_HEAD],bx ; Update keyboard buffer head pointer - -@@Done: leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _EVT_pumpMessages(void) -;---------------------------------------------------------------------------- -; This function would normally do nothing, however due to strange bugs -; in the Windows 3.1 and OS/2 DOS boxes, we don't get any hardware keyboard -; interrupts unless we periodically call the BIOS keyboard functions. Hence -; this function gets called every time that we check for events, and works -; around this problem (in essence it tells the DOS VDM to pump the -; keyboard events to our program ;-). -; -; Note that this bug is not present under Win 9x DOS boxes. -;---------------------------------------------------------------------------- -cprocstart _EVT_pumpMessages - - mov ah,11h ; Function - Check keyboard status - int 16h ; Call BIOS - - mov ax, 0Bh ; Reset Move Mouse - int 33h - ret - -cprocend - -;---------------------------------------------------------------------------- -; int _EVT_disableInt(void); -;---------------------------------------------------------------------------- -; Return processor interrupt status and disable interrupts. -;---------------------------------------------------------------------------- -cprocstart _EVT_disableInt - - pushf ; Put flag word on stack - cli ; Disable interrupts! - pop eax ; deposit flag word in return register - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _EVT_restoreInt(int ps); -;---------------------------------------------------------------------------- -; Restore processor interrupt status. -;---------------------------------------------------------------------------- -cprocstart _EVT_restoreInt - - ARG ps:UINT - - push ebp - mov ebp,esp ; Set up stack frame - push [DWORD ps] - popf ; Restore processor status (and interrupts) - pop ebp - ret - -cprocend - -;---------------------------------------------------------------------------- -; int EVT_rdinx(int port,int index) -;---------------------------------------------------------------------------- -; Reads an indexed register value from an I/O port. -;---------------------------------------------------------------------------- -cprocstart EVT_rdinx - - ARG port:UINT, index:UINT - - push ebp - mov ebp,esp - mov edx,[port] - mov al,[BYTE index] - out dx,al - inc dx - in al,dx - movzx eax,al - pop ebp - ret - -cprocend - -;---------------------------------------------------------------------------- -; void EVT_wrinx(int port,int index,int value) -;---------------------------------------------------------------------------- -; Writes an indexed register value to an I/O port. -;---------------------------------------------------------------------------- -cprocstart EVT_wrinx - - ARG port:UINT, index:UINT, value:UINT - - push ebp - mov ebp,esp - mov edx,[port] - mov al,[BYTE index] - mov ah,[BYTE value] - out dx,ax - pop ebp - ret - -cprocend - - cpublic _EVT_codeEnd - -endcodeseg _event - -endif - - END ; End of module diff --git a/board/MAI/bios_emulator/scitech/src/pm/dos/_lztimer.asm b/board/MAI/bios_emulator/scitech/src/pm/dos/_lztimer.asm deleted file mode 100644 index a4a9c7916e..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/_lztimer.asm +++ /dev/null @@ -1,438 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: NASM or TASM Assembler -;* Environment: IBM PC (MS DOS) -;* -;* Description: Uses the 8253 timer and the BIOS time-of-day count to time -;* the performance of code that takes less than an hour to -;* execute. -;* -;* The routines in this package only works with interrupts -;* enabled, and in fact will explicitly turn interrupts on -;* in order to ensure we get accurate results from the timer. -;* -;* Externally 'C' callable routines: -;* -;* LZ_timerOn: Saves the BIOS time of day count and starts the -;* long period Zen Timer. -;* -;* LZ_timerLap: Latches the current count, and keeps the timer running -;* -;* LZ_timerOff: Stops the long-period Zen Timer and saves the timer -;* count and the BIOS time of day count. -;* -;* LZ_timerCount: Returns an unsigned long representing the timed count -;* in microseconds. If more than an hour passed during -;* the timing interval, LZ_timerCount will return the -;* value 0xFFFFFFFF (an invalid count). -;* -;* Note: If either more than an hour passes between calls to LZ_timerOn -;* and LZ_timerOff, an error is reported. For timing code that takes -;* more than a few minutes to execute, use the low resolution -;* Ultra Long Period Zen Timer code, which should be accurate -;* enough for most purposes. -;* -;* Note: Each block of code being timed should ideally be run several -;* times, with at least two similar readings required to -;* establish a true measurement, in order to eliminate any -;* variability caused by interrupts. -;* -;* Note: Interrupts must not be disabled for more than 54 ms at a -;* stretch during the timing interval. Because interrupts are -;* enabled, key, mice, and other devices that generate interrupts -;* should not be used during the timing interval. -;* -;* Note: Any extra code running off the timer interrupt (such as -;* some memory resident utilities) will increase the time -;* measured by the Zen Timer. -;* -;* Note: These routines can introduce inaccuracies of up to a few -;* tenths of a second into the system clock count for each -;* code section being timed. Consequently, it's a good idea to -;* reboot at the conclusion of timing sessions. (The -;* battery-backed clock, if any, is not affected by the Zen -;* timer.) -;* -;* All registers and all flags are preserved by all routines, except -;* interrupts which are always turned on -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" - -;**************************************************************************** -; -; Equates used by long period Zen Timer -; -;**************************************************************************** - -; Base address of 8253 timer chip - -BASE_8253 equ 40h - -; The address of the timer 0 count registers in the 8253 - -TIMER_0_8253 equ BASE_8253 + 0 - -; The address of the mode register in the 8253 - -MODE_8253 equ BASE_8253 + 3 - -; The address of the BIOS timer count variable in the BIOS data area. - -TIMER_COUNT equ 6Ch - -; Macro to delay briefly to ensure that enough time has elapsed between -; successive I/O accesses so that the device being accessed can respond -; to both accesses even on a very fast PC. - -ifdef USE_NASM -%macro DELAY 0 - jmp short $+2 - jmp short $+2 - jmp short $+2 -%endmacro -else -macro DELAY - jmp short $+2 - jmp short $+2 - jmp short $+2 -endm -endif - -header _lztimer - -begdataseg _lztimer - - cextern _ZTimerBIOSPtr,DPTR - -StartBIOSCount dd 0 ; Starting BIOS count dword -EndBIOSCount dd 0 ; Ending BIOS count dword -EndTimedCount dw 0 ; Timer 0 count at the end of timing period - -enddataseg _lztimer - -begcodeseg _lztimer ; Start of code segment - -;---------------------------------------------------------------------------- -; void LZ_timerOn(void); -;---------------------------------------------------------------------------- -; Starts the Long period Zen timer counting. -;---------------------------------------------------------------------------- -cprocstart LZ_timerOn - -; Set the timer 0 of the 8253 to mode 2 (divide-by-N), to cause -; linear counting rather than count-by-two counting. Also stops -; timer 0 until the timer count is loaded, except on PS/2 computers. - - mov al,00110100b ; mode 2 - out MODE_8253,al - -; Set the timer count to 0, so we know we won't get another timer -; interrupt right away. Note: this introduces an inaccuracy of up to 54 ms -; in the system clock count each time it is executed. - - DELAY - sub al,al - out TIMER_0_8253,al ; lsb - DELAY - out TIMER_0_8253,al ; msb - -; Store the timing start BIOS count - - use_es -ifdef flatmodel - mov ebx,[_ZTimerBIOSPtr] -else - les bx,[_ZTimerBIOSPtr] -endif - cli ; No interrupts while we grab the count - mov eax,[_ES _bx+TIMER_COUNT] - sti - mov [StartBIOSCount],eax - unuse_es - -; Set the timer count to 0 again to start the timing interval. - - mov al,00110100b ; set up to load initial - out MODE_8253,al ; timer count - DELAY - sub al,al - out TIMER_0_8253,al ; load count lsb - DELAY - out TIMER_0_8253,al ; load count msb - - ret - -cprocend - -;---------------------------------------------------------------------------- -; void LZ_timerOff(void); -;---------------------------------------------------------------------------- -; Stops the long period Zen timer and saves count. -;---------------------------------------------------------------------------- -cprocstart LZ_timerOff - -; Latch the timer count. - - mov al,00000000b ; latch timer 0 - out MODE_8253,al - cli ; Stop the BIOS count - -; Read the BIOS count. (Since interrupts are disabled, the BIOS -; count won't change). - - use_es -ifdef flatmodel - mov ebx,[_ZTimerBIOSPtr] -else - les bx,[_ZTimerBIOSPtr] -endif - mov eax,[_ES _bx+TIMER_COUNT] - mov [EndBIOSCount],eax - unuse_es - -; Read out the count we latched earlier. - - in al,TIMER_0_8253 ; least significant byte - DELAY - mov ah,al - in al,TIMER_0_8253 ; most significant byte - xchg ah,al - neg ax ; Convert from countdown remaining - ; to elapsed count - mov [EndTimedCount],ax - sti ; Let the BIOS count continue - - ret - -cprocend - -;---------------------------------------------------------------------------- -; unsigned long LZ_timerLap(void) -;---------------------------------------------------------------------------- -; Latches the current count and converts it to a microsecond timing value, -; but leaves the timer still running. We dont check for and overflow, -; where the time has gone over an hour in this routine, since we want it -; to execute as fast as possible. -;---------------------------------------------------------------------------- -cprocstart LZ_timerLap - - push ebx ; Save EBX for 32 bit code - -; Latch the timer count. - - mov al,00000000b ; latch timer 0 - out MODE_8253,al - cli ; Stop the BIOS count - -; Read the BIOS count. (Since interrupts are disabled, the BIOS -; count wont change). - - use_es -ifdef flatmodel - mov ebx,[_ZTimerBIOSPtr] -else - les bx,[_ZTimerBIOSPtr] -endif - mov eax,[_ES _bx+TIMER_COUNT] - mov [EndBIOSCount],eax - unuse_es - -; Read out the count we latched earlier. - - in al,TIMER_0_8253 ; least significant byte - DELAY - mov ah,al - in al,TIMER_0_8253 ; most significant byte - xchg ah,al - neg ax ; Convert from countdown remaining - ; to elapsed count - mov [EndTimedCount],ax - sti ; Let the BIOS count continue - -; See if a midnight boundary has passed and adjust the finishing BIOS -; count by the number of ticks in 24 hours. We wont be able to detect -; more than 24 hours, but at least we can time across a midnight -; boundary - - mov eax,[EndBIOSCount] ; Is end < start? - cmp eax,[StartBIOSCount] - jae @@CalcBIOSTime ; No, calculate the time taken - -; Adjust the finishing time by adding the number of ticks in 24 hours -; (1573040). - - add [DWORD EndBIOSCount],1800B0h - -; Convert the BIOS time to microseconds - -@@CalcBIOSTime: - mov ax,[WORD EndBIOSCount] - sub ax,[WORD StartBIOSCount] - mov dx,54925 ; Number of microseconds each - ; BIOS count represents. - mul dx - mov bx,ax ; set aside BIOS count in - mov cx,dx ; microseconds - -; Convert timer count to microseconds - - push _si - mov ax,[EndTimedCount] - mov si,8381 - mul si - mov si,10000 - div si ; * 0.8381 = * 8381 / 10000 - pop _si - -; Add the timer and BIOS counts together to get an overall time in -; microseconds. - - add ax,bx - adc cx,0 -ifdef flatmodel - shl ecx,16 - mov cx,ax - mov eax,ecx ; EAX := timer count -else - mov dx,cx -endif - pop ebx ; Restore EBX for 32 bit code - ret - -cprocend - -;---------------------------------------------------------------------------- -; unsigned long LZ_timerCount(void); -;---------------------------------------------------------------------------- -; Returns an unsigned long representing the net time in microseconds. -; -; If an hour has passed while timing, we return 0xFFFFFFFF as the count -; (which is not a possible count in itself). -;---------------------------------------------------------------------------- -cprocstart LZ_timerCount - - push ebx ; Save EBX for 32 bit code - -; See if a midnight boundary has passed and adjust the finishing BIOS -; count by the number of ticks in 24 hours. We wont be able to detect -; more than 24 hours, but at least we can time across a midnight -; boundary - - mov eax,[EndBIOSCount] ; Is end < start? - cmp eax,[StartBIOSCount] - jae @@CheckForHour ; No, check for hour passing - -; Adjust the finishing time by adding the number of ticks in 24 hours -; (1573040). - - add [DWORD EndBIOSCount],1800B0h - -; See if more than an hour passed during timing. If so, notify the user. - -@@CheckForHour: - mov ax,[WORD StartBIOSCount+2] - cmp ax,[WORD EndBIOSCount+2] - jz @@CalcBIOSTime ; Hour count didn't change, so - ; everything is fine - - inc ax - cmp ax,[WORD EndBIOSCount+2] - jnz @@TestTooLong ; Two hour boundaries passed, so the - ; results are no good - mov ax,[WORD EndBIOSCount] - cmp ax,[WORD StartBIOSCount] - jb @@CalcBIOSTime ; a single hour boundary passed. That's - ; OK, so long as the total time wasn't - ; more than an hour. - -; Over an hour elapsed passed during timing, which renders -; the results invalid. Notify the user. This misses the case where a -; multiple of 24 hours has passed, but we'll rely on the perspicacity of -; the user to detect that case :-). - -@@TestTooLong: -ifdef flatmodel - mov eax,0FFFFFFFFh -else - mov ax,0FFFFh - mov dx,0FFFFh -endif - jmp short @@Done - -; Convert the BIOS time to microseconds - -@@CalcBIOSTime: - mov ax,[WORD EndBIOSCount] - sub ax,[WORD StartBIOSCount] - mov dx,54925 ; Number of microseconds each - ; BIOS count represents. - mul dx - mov bx,ax ; set aside BIOS count in - mov cx,dx ; microseconds - -; Convert timer count to microseconds - - push _si - mov ax,[EndTimedCount] - mov si,8381 - mul si - mov si,10000 - div si ; * 0.8381 = * 8381 / 10000 - pop _si - -; Add the timer and BIOS counts together to get an overall time in -; microseconds. - - add ax,bx - adc cx,0 -ifdef flatmodel - shl ecx,16 - mov cx,ax - mov eax,ecx ; EAX := timer count -else - mov dx,cx -endif - -@@Done: pop ebx ; Restore EBX for 32 bit code - ret - -cprocend - -cprocstart LZ_disable - cli - ret -cprocend - -cprocstart LZ_enable - sti - ret -cprocend - -endcodeseg _lztimer - - END diff --git a/board/MAI/bios_emulator/scitech/src/pm/dos/_pm.asm b/board/MAI/bios_emulator/scitech/src/pm/dos/_pm.asm deleted file mode 100644 index 42b5cf3692..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/_pm.asm +++ /dev/null @@ -1,656 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: 80386 Assembler, TASM 4.0 or NASM -;* Environment: IBM PC Real mode and 16/32 bit protected mode -;* -;* Description: Low level assembly support for the PM library specific to -;* MSDOS. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -header _pmdos ; Set up memory model - -begdataseg _pmdos - -ifndef flatmodel - -struc rmregs_s -ax dw ? -ax_high dw ? -bx dw ? -bx_high dw ? -cx dw ? -cx_high dw ? -dx dw ? -dx_high dw ? -si dw ? -si_high dw ? -di dw ? -di_high dw ? -cflag dw ? -cflag_high dw ? -ends rmregs_s -RMREGS = (rmregs_s PTR es:bx) - -struc rmsregs_s -es dw ? -cs dw ? -ss dw ? -ds dw ? -ends rmsregs_s -RMSREGS = (rmsregs_s PTR es:bx) - -endif ; !flatmodel - -ifdef flatmodel - cextern _PM_savedDS,USHORT - cextern _PM_VXD_off,UINT - cextern _PM_VXD_sel,UINT -ifdef DOS4GW - cextern _PM_haveCauseWay,UINT -endif -endif -intel_id db "GenuineIntel" ; Intel vendor ID - -PMHELP_GETPDB EQU 0026h -PMHELP_FLUSHTLB EQU 0027h - -enddataseg _pmdos - -P586 - -begcodeseg _pmdos ; Start of code segment - -ifndef flatmodel - -;---------------------------------------------------------------------------- -; void PM_callRealMode(unsigned s,unsigned o, RMREGS *regs, -; RMSREGS *sregs) -;---------------------------------------------------------------------------- -; Calls a real mode procedure, loading the appropriate registers values -; from the passed in structures. Only the DS and ES register are loaded -; from the SREGS structure. -;---------------------------------------------------------------------------- -cprocstart PM_callRealMode - - ARG s:WORD, o:WORD, regs:DWORD, sregs:DWORD - - LOCAL addr:DWORD, bxVal:WORD, esVal:WORD, flags:WORD = LocalSize - - enter_c - push ds - push es - - mov ax,[o] ; Build the address to call in 'addr' - mov [WORD addr],ax - mov ax,[s] - mov [WORD addr+2],ax - - les bx,[sregs] - mov ax,[RMSREGS.ds] - mov ds,ax ; DS := passed in value - mov ax,[RMSREGS.es] - mov [esVal],ax - les bx,[regs] - mov ax,[RMREGS.bx] - mov [bxVal],ax - mov ax,[RMREGS.ax] ; AX := passed in value - mov cx,[RMREGS.cx] ; CX := passed in value - mov dx,[RMREGS.dx] ; DX := passed in value - mov si,[RMREGS.si] ; SI := passed in value - mov di,[RMREGS.di] ; DI := passed in value - push bp - push [esVal] - pop es ; ES := passed in value - mov bx,[bxVal] ; BX := passed in value - - call [addr] ; Call the specified routine - - pushf ; Save flags for later - pop [flags] - - pop bp - push es - pop [esVal] - push bx - pop [bxVal] - les bx,[sregs] - push ds - pop [RMSREGS.ds] ; Save value of DS - push [esVal] - pop [RMSREGS.es] ; Save value of ES - les bx,[regs] - mov [RMREGS.ax],ax ; Save value of AX - mov [RMREGS.cx],cx ; Save value of CX - mov [RMREGS.dx],dx ; Save value of DX - mov [RMREGS.si],si ; Save value of SI - mov [RMREGS.di],di ; Save value of DI - mov ax,[flags] ; Return flags - and ax,1h ; Isolate carry flag - mov [RMREGS.cflag],ax ; Save carry flag status - mov ax,[bxVal] - mov [RMREGS.bx],ax ; Save value of BX - - pop es - pop ds - leave_c - ret - -cprocend - -endif - -;---------------------------------------------------------------------------- -; void PM_segread(PMSREGS *sregs) -;---------------------------------------------------------------------------- -; Read the current value of all segment registers -;---------------------------------------------------------------------------- -cprocstartdll16 PM_segread - - ARG sregs:DPTR - - enter_c - - mov ax,es - _les _si,[sregs] - mov [_ES _si],ax - mov [_ES _si+2],cs - mov [_ES _si+4],ss - mov [_ES _si+6],ds - mov [_ES _si+8],fs - mov [_ES _si+10],gs - - leave_c - ret - -cprocend - -; Create a table of the 256 different interrupt calls that we can jump -; into - -ifdef USE_NASM - -%assign intno 0 - -intTable: -%rep 256 - db 0CDh - db intno -%assign intno intno + 1 - ret - nop -%endrep - -else - -intno = 0 - -intTable: - REPT 256 - db 0CDh - db intno -intno = intno + 1 - ret - nop - ENDM - -endif - -;---------------------------------------------------------------------------- -; _PM_genInt - Generate the appropriate interrupt -;---------------------------------------------------------------------------- -cprocnear _PM_genInt - - push _ax ; Save _ax - push _bx ; Save _bx -ifdef flatmodel - mov ebx,[UINT esp+12] ; EBX := interrupt number -else - mov bx,sp ; Make sure ESP is zeroed - mov bx,[UINT ss:bx+6] ; BX := interrupt number -endif - mov _ax,offset intTable ; Point to interrupt generation table - shl _bx,2 ; _BX := index into table - add _ax,_bx ; _AX := pointer to interrupt code -ifdef flatmodel - xchg eax,[esp+4] ; Restore eax, and set for int -else - mov bx,sp - xchg ax,[ss:bx+2] ; Restore ax, and set for int -endif - pop _bx ; restore _bx - ret - -cprocend - -;---------------------------------------------------------------------------- -; int PM_int386x(int intno, PMREGS *in, PMREGS *out,PMSREGS *sregs) -;---------------------------------------------------------------------------- -; Issues a software interrupt in protected mode. This routine has been -; written to allow user programs to load CS and DS with different values -; other than the default. -;---------------------------------------------------------------------------- -cprocstartdll16 PM_int386x - - ARG intno:UINT, inptr:DPTR, outptr:DPTR, sregs:DPTR - - LOCAL flags:UINT, sv_ds:UINT, sv_esi:ULONG = LocalSize - - enter_c - push ds - push es ; Save segment registers - push fs - push gs - - _lds _si,[sregs] ; DS:_SI -> Load segment registers - mov es,[_si] - mov bx,[_si+6] - mov [sv_ds],_bx ; Save value of user DS on stack - mov fs,[_si+8] - mov gs,[_si+10] - - _lds _si,[inptr] ; Load CPU registers - mov eax,[_si] - mov ebx,[_si+4] - mov ecx,[_si+8] - mov edx,[_si+12] - mov edi,[_si+20] - mov esi,[_si+16] - - push ds ; Save value of DS - push _bp ; Some interrupts trash this! - clc ; Generate the interrupt - push [UINT intno] - mov ds,[WORD sv_ds] ; Set value of user's DS selector - call _PM_genInt - pop _bp ; Pop intno from stack (flags unchanged) - pop _bp ; Restore value of stack frame pointer - pop ds ; Restore value of DS - - pushf ; Save flags for later - pop [UINT flags] - push esi ; Save ESI for later - pop [DWORD sv_esi] - push ds ; Save DS for later - pop [UINT sv_ds] - - _lds _si,[outptr] ; Save CPU registers - mov [_si],eax - mov [_si+4],ebx - mov [_si+8],ecx - mov [_si+12],edx - push [DWORD sv_esi] - pop [DWORD _si+16] - mov [_si+20],edi - - mov _bx,[flags] ; Return flags - and ebx,1h ; Isolate carry flag - mov [_si+24],ebx ; Save carry flag status - - _lds _si,[sregs] ; Save segment registers - mov [_si],es - mov _bx,[sv_ds] - mov [_si+6],bx ; Get returned DS from stack - mov [_si+8],fs - mov [_si+10],gs - - pop gs ; Restore segment registers - pop fs - pop es - pop ds - leave_c - ret - -cprocend - -ifndef flatmodel -_PM_savedDS dw _DATA ; Saved value of DS -endif - -;---------------------------------------------------------------------------- -; void PM_saveDS(void) -;---------------------------------------------------------------------------- -; Save the value of DS into a section of the code segment, so that we can -; quickly load this value at a later date in the PM_loadDS() routine from -; inside interrupt handlers etc. The method to do this is different -; depending on the DOS extender being used. -;---------------------------------------------------------------------------- -cprocstartdll16 PM_saveDS - -ifdef flatmodel - mov [_PM_savedDS],ds ; Store away in data segment -endif - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_loadDS(void) -;---------------------------------------------------------------------------- -; Routine to load the DS register with the default value for the current -; DOS extender. Only the DS register is loaded, not the ES register, so -; if you wish to call C code, you will need to also load the ES register -; in 32 bit protected mode. -;---------------------------------------------------------------------------- -cprocstartdll16 PM_loadDS - - mov ds,[cs:_PM_savedDS] ; We can access the proper DS through CS - ret - -cprocend - -ifdef flatmodel - -;---------------------------------------------------------------------------- -; ibool DPMI_allocateCallback(void (*pmcode)(), void *rmregs, long *RMCB) -;---------------------------------------------------------------------------- -cprocstart _DPMI_allocateCallback - - ARG pmcode:CPTR, rmregs:DPTR, RMCB:DPTR - - enter_c - push ds - push es - - push cs - pop ds - mov esi,[pmcode] ; DS:ESI -> protected mode code to call - mov edi,[rmregs] ; ES:EDI -> real mode register buffer - mov ax,303h ; AX := allocate realmode callback function - int 31h - mov eax,0 ; Return failure! - jc @@Fail - - mov eax,[RMCB] - shl ecx,16 - mov cx,dx - mov [es:eax],ecx ; Return real mode address - mov eax,1 ; Return success! - -@@Fail: pop es - pop ds - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; void DPMI_freeCallback(long RMCB) -;---------------------------------------------------------------------------- -cprocstart _DPMI_freeCallback - - ARG RMCB:ULONG - - enter_c - - mov cx,[WORD RMCB+2] - mov dx,[WORD RMCB] ; CX:DX := real mode callback - mov ax,304h - int 31h - - leave_c - ret - -cprocend - -endif - -; Macro to delay briefly to ensure that enough time has elapsed between -; successive I/O accesses so that the device being accessed can respond -; to both accesses even on a very fast PC. - -ifdef USE_NASM -%macro DELAY 0 - jmp short $+2 - jmp short $+2 - jmp short $+2 -%endmacro -%macro IODELAYN 1 -%rep %1 - DELAY -%endrep -%endmacro -else -macro DELAY - jmp short $+2 - jmp short $+2 - jmp short $+2 -endm -macro IODELAYN N - rept N - DELAY - endm -endm -endif - -;---------------------------------------------------------------------------- -; uchar _PM_readCMOS(int index) -;---------------------------------------------------------------------------- -; Read the value of a specific CMOS register. We do this with both -; normal interrupts and NMI disabled. -;---------------------------------------------------------------------------- -cprocstart _PM_readCMOS - - ARG index:UINT - - push _bp - mov _bp,_sp - pushfd - mov al,[BYTE index] - or al,80h ; Add disable NMI flag - cli - out 70h,al - IODELAYN 5 - in al,71h - mov ah,al - xor al,al - IODELAYN 5 - out 70h,al ; Re-enable NMI - sti - mov al,ah ; Return value in AL - popfd - pop _bp - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _PM_writeCMOS(int index,uchar value) -;---------------------------------------------------------------------------- -; Read the value of a specific CMOS register. We do this with both -; normal interrupts and NMI disabled. -;---------------------------------------------------------------------------- -cprocstart _PM_writeCMOS - - ARG index:UINT, value:UCHAR - - push _bp - mov _bp,_sp - pushfd - mov al,[BYTE index] - or al,80h ; Add disable NMI flag - cli - out 70h,al - IODELAYN 5 - mov al,[value] - out 71h,al - xor al,al - IODELAYN 5 - out 70h,al ; Re-enable NMI - sti - popfd - pop _bp - ret - -cprocend - -ifdef flatmodel - -;---------------------------------------------------------------------------- -; int _PM_pagingEnabled(void) -;---------------------------------------------------------------------------- -; Returns 1 if paging is enabled, 0 if not or -1 if not at ring 0 -;---------------------------------------------------------------------------- -cprocstart _PM_pagingEnabled - - mov eax,-1 -ifdef DOS4GW - mov cx,cs - and ecx,3 - jz @@Ring0 - cmp [UINT _PM_haveCauseWay],0 - jnz @@Ring0 - jmp @@Exit - -@@Ring0: - mov eax,cr0 ; Load CR0 - shr eax,31 ; Isolate paging enabled bit -endif -@@Exit: ret - -cprocend - -;---------------------------------------------------------------------------- -; _PM_getPDB - Return the Page Table Directory Base address -;---------------------------------------------------------------------------- -cprocstart _PM_getPDB - -ifdef DOS4GW - mov ax,cs - and eax,3 - jz @@Ring0 - cmp [UINT _PM_haveCauseWay],0 - jnz @@Ring0 -endif - -; Call VxD if running at ring 3 in a DOS box - - cmp [WORD _PM_VXD_sel],0 - jz @@Fail - mov eax,PMHELP_GETPDB -ifdef USE_NASM - call far dword [_PM_VXD_off] -else - call [FCPTR _PM_VXD_off] -endif - ret - -@@Ring0: -ifdef DOS4GW - mov eax,cr3 - and eax,0FFFFF000h - ret -endif -@@Fail: xor eax,eax - ret - -cprocend - -;---------------------------------------------------------------------------- -; PM_flushTLB - Flush the Translation Lookaside buffer -;---------------------------------------------------------------------------- -cprocstart PM_flushTLB - - mov ax,cs - and eax,3 - jz @@Ring0 -ifdef DOS4GW - cmp [UINT _PM_haveCauseWay],0 - jnz @@Ring0 -endif - -; Call VxD if running at ring 3 in a DOS box - - cmp [WORD _PM_VXD_sel],0 - jz @@Fail - mov eax,PMHELP_FLUSHTLB -ifdef USE_NASM - call far dword [_PM_VXD_off] -else - call [FCPTR _PM_VXD_off] -endif - ret - -@@Ring0: -ifdef DOS4GW - wbinvd ; Flush the CPU cache - mov eax,cr3 - mov cr3,eax ; Flush the TLB -endif -@@Fail: ret - -cprocend - -endif - -;---------------------------------------------------------------------------- -; void _PM_VxDCall(VXD_regs far *r,uint off,uint sel); -;---------------------------------------------------------------------------- -cprocstart _PM_VxDCall - - ARG r:DPTR, off:UINT, sel:UINT - - enter_c - -; Load all registers from the registers structure - - mov ebx,[r] - mov eax,[ebx+0] - mov ecx,[ebx+8] - mov edx,[ebx+12] - mov esi,[ebx+16] - mov edi,[ebx+20] - mov ebx,[ebx+4] ; Trashes BX structure pointer! - -; Call the VxD entry point (on stack) - -ifdef USE_NASM - call far dword [off] -else - call [FCPTR off] -endif - -; Save all registers back in the structure - - push ebx ; Push EBX onto stack for later - mov ebx,[r] - mov [ebx+0],eax - mov [ebx+8],ecx - mov [ebx+12],edx - mov [ebx+16],esi - mov [ebx+20],edi - pop [DWORD ebx+4] ; Save value of EBX from stack - - leave_c - ret - -cprocend - -endcodeseg _pmdos - - END ; End of module diff --git a/board/MAI/bios_emulator/scitech/src/pm/dos/_pmdos.asm b/board/MAI/bios_emulator/scitech/src/pm/dos/_pmdos.asm deleted file mode 100644 index 5c741f346c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/_pmdos.asm +++ /dev/null @@ -1,1105 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: 80386 Assembler, TASM 4.0 or NASM -;* Environment: IBM PC Real mode and 16/32 bit protected mode -;* -;* Description: Low level assembly support for the PM library specific to -;* MSDOS interrupt handling. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -header _pmdos ; Set up memory model - -; Define the size of our local stacks. For real mode code they cant be -; that big, but for 32 bit protected mode code we can make them nice and -; large so that complex C functions can be used. - -ifdef flatmodel -MOUSE_STACK EQU 4096 -TIMER_STACK EQU 4096 -KEY_STACK EQU 1024 -INT10_STACK EQU 1024 -IRQ_STACK EQU 1024 -else -MOUSE_STACK EQU 1024 -TIMER_STACK EQU 512 -KEY_STACK EQU 256 -INT10_STACK EQU 256 -IRQ_STACK EQU 256 -endif - -ifdef USE_NASM - -; Macro to load DS and ES registers with correct value. - -%imacro LOAD_DS 0 -%ifdef flatmodel - mov ds,[cs:_PM_savedDS] - mov es,[cs:_PM_savedDS] -%else - push ax - mov ax,_DATA - mov ds,ax - pop ax -%endif -%endmacro - -; Note that interrupts we disable interrupts during the following stack -; %imacro for correct operation, but we do not enable them again. Normally -; these %imacros are used within interrupt handlers so interrupts should -; already be off. We turn them back on explicitly later if the user code -; needs them to be back on. - -; Macro to switch to a new local stack. - -%imacro NEWSTK 1 - cli - mov [seg_%1],ss - mov [ptr_%1],_sp - mov [TempSeg],ds - mov ss,[TempSeg] - mov _sp,offset %1 -%endmacro - -; %imacro to switch back to the old stack. - -%imacro RESTSTK 1 - cli - mov ss,[seg_%1] - mov _sp,[ptr_%1] -%endmacro - -; %imacro to swap the current stack with the one saved away. - -%imacro SWAPSTK 1 - cli - mov ax,ss - xchg ax,[seg_%1] - mov ss,ax - xchg _sp,[ptr_%1] -%endmacro - -else - -; Macro to load DS and ES registers with correct value. - -MACRO LOAD_DS -ifdef flatmodel - mov ds,[cs:_PM_savedDS] - mov es,[cs:_PM_savedDS] -else - push ax - mov ax,_DATA - mov ds,ax - pop ax -endif -ENDM - -; Note that interrupts we disable interrupts during the following stack -; macro for correct operation, but we do not enable them again. Normally -; these macros are used within interrupt handlers so interrupts should -; already be off. We turn them back on explicitly later if the user code -; needs them to be back on. - -; Macro to switch to a new local stack. - -MACRO NEWSTK stkname - cli - mov [seg_&stkname&],ss - mov [ptr_&stkname&],_sp - mov [TempSeg],ds - mov ss,[TempSeg] - mov _sp,offset stkname -ENDM - -; Macro to switch back to the old stack. - -MACRO RESTSTK stkname - cli - mov ss,[seg_&stkname&] - mov _sp,[ptr_&stkname&] -ENDM - -; Macro to swap the current stack with the one saved away. - -MACRO SWAPSTK stkname - cli - mov ax,ss - xchg ax,[seg_&stkname&] - mov ss,ax - xchg _sp,[ptr_&stkname&] -ENDM - -endif - -begdataseg _pmdos - -ifdef flatmodel - cextern _PM_savedDS,USHORT -endif - cextern _PM_critHandler,CPTR - cextern _PM_breakHandler,CPTR - cextern _PM_timerHandler,CPTR - cextern _PM_rtcHandler,CPTR - cextern _PM_keyHandler,CPTR - cextern _PM_key15Handler,CPTR - cextern _PM_mouseHandler,CPTR - cextern _PM_int10Handler,CPTR - - cextern _PM_ctrlCPtr,DPTR - cextern _PM_ctrlBPtr,DPTR - cextern _PM_critPtr,DPTR - - cextern _PM_prevTimer,FCPTR - cextern _PM_prevRTC,FCPTR - cextern _PM_prevKey,FCPTR - cextern _PM_prevKey15,FCPTR - cextern _PM_prevBreak,FCPTR - cextern _PM_prevCtrlC,FCPTR - cextern _PM_prevCritical,FCPTR - cextern _PM_prevRealTimer,ULONG - cextern _PM_prevRealRTC,ULONG - cextern _PM_prevRealKey,ULONG - cextern _PM_prevRealKey15,ULONG - cextern _PM_prevRealInt10,ULONG - -cpublic _PM_pmdosDataStart - -; Allocate space for all of the local stacks that we need. These stacks -; are not very large, but should be large enough for most purposes -; (generally you want to handle these interrupts quickly, simply storing -; the information for later and then returning). If you need bigger -; stacks then change the appropriate value in here. - - ALIGN 4 - dclb MOUSE_STACK ; Space for local stack (small) -MsStack: ; Stack starts at end! -ptr_MsStack DUINT 0 ; Place to store old stack offset -seg_MsStack dw 0 ; Place to store old stack segment - - ALIGN 4 - dclb INT10_STACK ; Space for local stack (small) -Int10Stack: ; Stack starts at end! -ptr_Int10Stack DUINT 0 ; Place to store old stack offset -seg_Int10Stack dw 0 ; Place to store old stack segment - - ALIGN 4 - dclb TIMER_STACK ; Space for local stack (small) -TmStack: ; Stack starts at end! -ptr_TmStack DUINT 0 ; Place to store old stack offset -seg_TmStack dw 0 ; Place to store old stack segment - - ALIGN 4 - dclb TIMER_STACK ; Space for local stack (small) -RtcStack: ; Stack starts at end! -ptr_RtcStack DUINT 0 ; Place to store old stack offset -seg_RtcStack dw 0 ; Place to store old stack segment -RtcInside dw 0 ; Are we still handling current interrupt - - ALIGN 4 - dclb KEY_STACK ; Space for local stack (small) -KyStack: ; Stack starts at end! -ptr_KyStack DUINT 0 ; Place to store old stack offset -seg_KyStack dw 0 ; Place to store old stack segment -KyInside dw 0 ; Are we still handling current interrupt - - ALIGN 4 - dclb KEY_STACK ; Space for local stack (small) -Ky15Stack: ; Stack starts at end! -ptr_Ky15Stack DUINT 0 ; Place to store old stack offset -seg_Ky15Stack dw 0 ; Place to store old stack segment - -TempSeg dw 0 ; Place to store stack segment - -cpublic _PM_pmdosDataEnd - -enddataseg _pmdos - -begcodeseg _pmdos ; Start of code segment - -cpublic _PM_pmdosCodeStart - -;---------------------------------------------------------------------------- -; PM_mouseISR - Mouse interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; Interrupt subroutine called by the mouse driver upon interrupts, to -; dispatch control to high level C based subroutines. Interrupts are on -; when we call the user code. -; -; It is _extremely_ important to save the state of the extended registers -; as these may well be trashed by the routines called from here and not -; restored correctly by the mouse interface module. -; -; NOTE: This routine switches to a local stack before calling any C code, -; and hence is _not_ re-entrant. For mouse handlers this is not a -; problem, as the mouse driver arbitrates calls to the user mouse -; handler for us. -; -; Entry: AX - Condition mask giving reason for call -; BX - Mouse button state -; CX - Horizontal cursor coordinate -; DX - Vertical cursor coordinate -; SI - Horizontal mickey value -; DI - Vertical mickey value -; -;---------------------------------------------------------------------------- -ifdef DJGPP -cprocstart _PM_mouseISR -else -cprocfar _PM_mouseISR -endif - - push ds ; Save value of DS - push es - pushad ; Save _all_ extended registers - cld ; Clear direction flag - - LOAD_DS ; Load DS register - NEWSTK MsStack ; Switch to local stack - -; Call the installed high level C code routine - - clrhi dx ; Clear out high order values - clrhi cx - clrhi bx - clrhi ax - sgnhi si - sgnhi di - - push _di - push _si - push _dx - push _cx - push _bx - push _ax - sti ; Enable interrupts - call [CPTR _PM_mouseHandler] - _add sp,12,24 - - RESTSTK MsStack ; Restore previous stack - - popad ; Restore all extended registers - pop es - pop ds - ret ; We are done!! - -cprocend - -;---------------------------------------------------------------------------- -; PM_timerISR - Timer interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; Hardware interrupt handler for the timer interrupt, to dispatch control -; to high level C based subroutines. We save the state of all registers -; in this routine, and switch to a local stack. Interrupts are *off* -; when we call the user code. -; -; NOTE: This routine switches to a local stack before calling any C code, -; and hence is _not_ re-entrant. Make sure your C code executes as -; quickly as possible, since a timer overrun will simply hang the -; system. -;---------------------------------------------------------------------------- -cprocfar _PM_timerISR - - push ds ; Save value of DS - push es - pushad ; Save _all_ extended registers - cld ; Clear direction flag - - LOAD_DS ; Load DS register - - NEWSTK TmStack ; Switch to local stack - call [CPTR _PM_timerHandler] - RESTSTK TmStack ; Restore previous stack - - popad ; Restore all extended registers - pop es - pop ds - iret ; Return from interrupt - -cprocend - -;---------------------------------------------------------------------------- -; PM_chainPrevTimer - Chain to previous timer interrupt and return -;---------------------------------------------------------------------------- -; Chains to the previous timer interrupt routine and returns control -; back to the high level interrupt handler. -;---------------------------------------------------------------------------- -cprocstart PM_chainPrevTimer - -ifdef TNT - push eax - push ebx - push ecx - pushfd ; Push flags on stack to simulate interrupt - mov ax,250Eh ; Call real mode procedure function - mov ebx,[_PM_prevRealTimer] - mov ecx,1 ; Copy real mode flags to real mode stack - int 21h ; Call the real mode code - popfd - pop ecx - pop ebx - pop eax - ret -else - SWAPSTK TmStack ; Swap back to previous stack - pushf ; Save state of interrupt flag - pushf ; Push flags on stack to simulate interrupt -ifdef USE_NASM - call far dword [_PM_prevTimer] -else - call [_PM_prevTimer] -endif - popf ; Restore state of interrupt flag - SWAPSTK TmStack ; Swap back to C stack again - ret -endif - -cprocend - -; Macro to delay briefly to ensure that enough time has elapsed between -; successive I/O accesses so that the device being accessed can respond -; to both accesses even on a very fast PC. - -ifdef USE_NASM -%macro DELAY 0 - jmp short $+2 - jmp short $+2 - jmp short $+2 -%endmacro -%macro IODELAYN 1 -%rep %1 - DELAY -%endrep -%endmacro -else -macro DELAY - jmp short $+2 - jmp short $+2 - jmp short $+2 -endm -macro IODELAYN N - rept N - DELAY - endm -endm -endif - -;---------------------------------------------------------------------------- -; PM_rtcISR - Real time clock interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; Hardware interrupt handler for the timer interrupt, to dispatch control -; to high level C based subroutines. We save the state of all registers -; in this routine, and switch to a local stack. Interrupts are *off* -; when we call the user code. -; -; NOTE: This routine switches to a local stack before calling any C code, -; and hence is _not_ re-entrant. Make sure your C code executes as -; quickly as possible, since a timer overrun will simply hang the -; system. -;---------------------------------------------------------------------------- -cprocfar _PM_rtcISR - - push ds ; Save value of DS - push es - pushad ; Save _all_ extended registers - cld ; Clear direction flag - -; Clear priority interrupt controller and re-enable interrupts so we -; dont lock things up for long. - - mov al,20h - out 0A0h,al - out 020h,al - -; Clear real-time clock timeout - - in al,70h ; Read CMOS index register - push _ax ; and save for later - IODELAYN 3 - mov al,0Ch - out 70h,al - IODELAYN 5 - in al,71h - -; Call the C interrupt handler function - - LOAD_DS ; Load DS register - cmp [BYTE RtcInside],1 ; Check for mutual exclusion - je @@Exit - mov [BYTE RtcInside],1 - NEWSTK RtcStack ; Switch to local stack - sti ; Re-enable interrupts - call [CPTR _PM_rtcHandler] - RESTSTK RtcStack ; Restore previous stack - mov [BYTE RtcInside],0 - -@@Exit: pop _ax - out 70h,al ; Restore CMOS index register - popad ; Restore all extended registers - pop es - pop ds - iret ; Return from interrupt - -cprocend - -ifdef flatmodel -;---------------------------------------------------------------------------- -; PM_irqISRTemplate - Hardware interrupt handler IRQ template -;---------------------------------------------------------------------------- -; Hardware interrupt handler for any interrupt, to dispatch control -; to high level C based subroutines. We save the state of all registers -; in this routine, and switch to a local stack. Interrupts are *off* -; when we call the user code. -; -; NOTE: This routine switches to a local stack before calling any C code, -; and hence is _not_ re-entrant. Make sure your C code executes as -; quickly as possible. -;---------------------------------------------------------------------------- -cprocfar _PM_irqISRTemplate - - push ebx - mov ebx,0 ; Relocation adjustment factor - jmp __IRQEntry - -; Global variables stored in the IRQ thunk code segment - -_CHandler dd 0 ; Pointer to C interrupt handler -_PrevIRQ dd 0 ; Previous IRQ handler - dd 0 -_IRQ dd 0 ; IRQ we are hooked for -ptr_IRQStack DUINT 0 ; Place to store old stack offset -seg_IRQStack dw 0 ; Place to store old stack segment -_Inside db 0 ; Mutual exclusion flag - ALIGN 4 - dclb IRQ_STACK ; Space for local stack -_IRQStack: ; Stack starts at end! - -; Check for and reject spurious IRQ 7 signals - -__IRQEntry: - cmp [BYTE cs:ebx+_IRQ],7 ; Spurious IRQs occur only on IRQ 7 - jmp @@ValidIRQ - push eax - mov al,1011b ; OCW3: read ISR - out 20h,al ; (Intel Peripheral Components, 1991, - in al,20h ; p. 3-188) - shl al,1 ; Set C = bit 7 (IRQ 7) of ISR register - pop eax - jc @@ValidIRQ - iret ; Return from interrupt - -; Save all registers for duration of IRQ handler - -@@ValidIRQ: - push ds ; Save value of DS - push es - pushad ; Save _all_ extended registers - cld ; Clear direction flag - LOAD_DS ; Load DS register - -; Send an EOI to the PIC - - mov al,20h ; Send EOI to PIC - cmp [BYTE ebx+_IRQ],8 ; Clear PIC1 first if IRQ >= 8 - jb @@1 - out 0A0h,al -@@1: out 20h,al - -; Check for mutual exclusion - - cmp [BYTE ebx+_Inside],1 - je @@ChainOldHandler - mov [BYTE ebx+_Inside],1 - -; Call the C interrupt handler function - - mov [ebx+seg_IRQStack],ss ; Switch to local stack - mov [ebx+ptr_IRQStack],esp - mov [TempSeg],ds - mov ss,[TempSeg] - lea esp,[ebx+_IRQStack] - sti ; Re-enable interrupts - push ebx - call [DWORD ebx+_CHandler] - pop ebx - cli - mov ss,[ebx+seg_IRQStack] ; Restore previous stack - mov esp,[ebx+ptr_IRQStack] - or eax,eax - jz @@ChainOldHandler ; Chain if not handled for shared IRQ - -@@Exit: mov [BYTE ebx+_Inside],0 - popad ; Restore all extended registers - pop es - pop ds - pop ebx - iret ; Return from interrupt - -@@ChainOldHandler: - cmp [DWORD ebx+_PrevIRQ],0 - jz @@Exit - mov [BYTE ebx+_Inside],0 - mov eax,[DWORD ebx+_PrevIRQ] - mov ebx,[DWORD ebx+_PrevIRQ+4] - mov [DWORD _PrevIRQ],eax - mov [DWORD _PrevIRQ+4],ebx - popad ; Restore all extended registers - pop es - pop ds - pop ebx - jmp [cs:_PrevIRQ] ; Chain to previous IRQ handler - -cprocend -cpublic _PM_irqISRTemplateEnd -endif - -;---------------------------------------------------------------------------- -; PM_keyISR - keyboard interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; Hardware interrupt handler for the keyboard interrupt, to dispatch control -; to high level C based subroutines. We save the state of all registers -; in this routine, and switch to a local stack. Interrupts are *off* -; when we call the user code. -; -; NOTE: This routine switches to a local stack before calling any C code, -; and hence is _not_ re-entrant. However we ensure within this routine -; mutual exclusion to the keyboard handling routine. -;---------------------------------------------------------------------------- -cprocfar _PM_keyISR - - push ds ; Save value of DS - push es - pushad ; Save _all_ extended registers - cld ; Clear direction flag - - LOAD_DS ; Load DS register - - cmp [BYTE KyInside],1 ; Check for mutual exclusion - je @@Reissued - - mov [BYTE KyInside],1 - NEWSTK KyStack ; Switch to local stack - call [CPTR _PM_keyHandler] ; Call C code - RESTSTK KyStack ; Restore previous stack - mov [BYTE KyInside],0 - -@@Exit: popad ; Restore all extended registers - pop es - pop ds - iret ; Return from interrupt - -; When the BIOS keyboard handler needs to change the SHIFT status lights -; on the keyboard, in the process of doing this the keyboard controller -; re-issues another interrupt, while the current handler is still executing. -; If we recieve another interrupt while still handling the current one, -; then simply chain directly to the previous handler. -; -; Note that for most DOS extenders, the real mode interrupt handler that we -; install takes care of this for us. - -@@Reissued: -ifdef TNT - push eax - push ebx - push ecx - pushfd ; Push flags on stack to simulate interrupt - mov ax,250Eh ; Call real mode procedure function - mov ebx,[_PM_prevRealKey] - mov ecx,1 ; Copy real mode flags to real mode stack - int 21h ; Call the real mode code - popfd - pop ecx - pop ebx - pop eax -else - pushf -ifdef USE_NASM - call far dword [_PM_prevKey] -else - call [_PM_prevKey] -endif -endif - jmp @@Exit - -cprocend - -;---------------------------------------------------------------------------- -; PM_chainPrevkey - Chain to previous key interrupt and return -;---------------------------------------------------------------------------- -; Chains to the previous key interrupt routine and returns control -; back to the high level interrupt handler. -;---------------------------------------------------------------------------- -cprocstart PM_chainPrevKey - -ifdef TNT - push eax - push ebx - push ecx - pushfd ; Push flags on stack to simulate interrupt - mov ax,250Eh ; Call real mode procedure function - mov ebx,[_PM_prevRealKey] - mov ecx,1 ; Copy real mode flags to real mode stack - int 21h ; Call the real mode code - popfd - pop ecx - pop ebx - pop eax - ret -else - -; YIKES! For some strange reason, when execution returns from the -; previous keyboard handler, interrupts are re-enabled!! Since we expect -; interrupts to remain off during the duration of our handler, this can -; cause havoc. However our stack macros always turn off interrupts, so they -; will be off when we exit this routine. Obviously there is a tiny weeny -; window when interrupts will be enabled, but there is nothing we can -; do about this. - - SWAPSTK KyStack ; Swap back to previous stack - pushf ; Push flags on stack to simulate interrupt -ifdef USE_NASM - call far dword [_PM_prevKey] -else - call [_PM_prevKey] -endif - SWAPSTK KyStack ; Swap back to C stack again - ret -endif - -cprocend - -;---------------------------------------------------------------------------- -; PM_key15ISR - Int 15h keyboard interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; This routine gets called if we have been called to handle the Int 15h -; keyboard interrupt callout from real mode. -; -; Entry: AX - Hardware scan code to process -; Exit: AX - Hardware scan code to process (0 to ignore) -;---------------------------------------------------------------------------- -cprocfar _PM_key15ISR - - push ds - push es - LOAD_DS - cmp ah,4Fh - jnz @@NotOurs ; Quit if not keyboard callout - - pushad - cld ; Clear direction flag - xor ah,ah ; AX := scan code - NEWSTK Ky15Stack ; Switch to local stack - push _ax - call [CPTR _PM_key15Handler] ; Call C code - _add sp,2,4 - RESTSTK Ky15Stack ; Restore previous stack - test ax,ax - jz @@1 - stc ; Set carry to process as normal - jmp @@2 -@@1: clc ; Clear carry to ignore scan code -@@2: popad - jmp @@Exit ; We are done - -@@NotOurs: -ifdef TNT - push eax - push ebx - push ecx - pushfd ; Push flags on stack to simulate interrupt - mov ax,250Eh ; Call real mode procedure function - mov ebx,[_PM_prevRealKey15] - mov ecx,1 ; Copy real mode flags to real mode stack - int 21h ; Call the real mode code - popfd - pop ecx - pop ebx - pop eax -else - pushf -ifdef USE_NASM - call far dword [_PM_prevKey15] -else - call [_PM_prevKey15] -endif -endif -@@Exit: pop es - pop ds -ifdef flatmodel - retf 4 -else - retf 2 -endif - -cprocend - -;---------------------------------------------------------------------------- -; PM_breakISR - Control Break interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; Hardware interrupt handler for the Ctrl-Break interrupt. We simply set -; the Ctrl-Break flag to a 1 and leave (note that this is accessed through -; a far pointer, as it may well be located in conventional memory). -;---------------------------------------------------------------------------- -cprocfar _PM_breakISR - - sti - push ds ; Save value of DS - push es - push _bx - - LOAD_DS ; Load DS register -ifdef flatmodel - mov ebx,[_PM_ctrlBPtr] -else - les bx,[_PM_ctrlBPtr] -endif - mov [UINT _ES _bx],1 - -; Run alternate break handler code if installed - - cmp [CPTR _PM_breakHandler],0 - je @@Exit - - pushad - mov _ax,1 - push _ax - call [CPTR _PM_breakHandler] ; Call C code - pop _ax - popad - -@@Exit: pop _bx - pop es - pop ds - iret ; Return from interrupt - -cprocend - -;---------------------------------------------------------------------------- -; int PM_ctrlBreakHit(int clearFlag) -;---------------------------------------------------------------------------- -; Returns the current state of the Ctrl-Break flag and possibly clears it. -;---------------------------------------------------------------------------- -cprocstart PM_ctrlBreakHit - - ARG clearFlag:UINT - - enter_c - pushf ; Save interrupt status - push es -ifdef flatmodel - mov ebx,[_PM_ctrlBPtr] -else - les bx,[_PM_ctrlBPtr] -endif - cli ; No interrupts thanks! - mov _ax,[_ES _bx] - test [BYTE clearFlag],1 - jz @@Done - mov [UINT _ES _bx],0 - -@@Done: pop es - popf ; Restore interrupt status - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; PM_ctrlCISR - Control Break interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; Hardware interrupt handler for the Ctrl-C interrupt. We simply set -; the Ctrl-C flag to a 1 and leave (note that this is accessed through -; a far pointer, as it may well be located in conventional memory). -;---------------------------------------------------------------------------- -cprocfar _PM_ctrlCISR - - sti - push ds ; Save value of DS - push es - push _bx - - LOAD_DS ; Load DS register -ifdef flatmodel - mov ebx,[_PM_ctrlCPtr] -else - les bx,[_PM_ctrlCPtr] -endif - mov [UINT _ES _bx],1 - -; Run alternate break handler code if installed - - cmp [CPTR _PM_breakHandler],0 - je @@Exit - - pushad - mov _ax,0 - push _ax - call [CPTR _PM_breakHandler] ; Call C code - pop _ax - popad - -@@Exit: pop _bx - pop es - pop ds - iret ; Return from interrupt - iretd - -cprocend - -;---------------------------------------------------------------------------- -; int PM_ctrlCHit(int clearFlag) -;---------------------------------------------------------------------------- -; Returns the current state of the Ctrl-C flag and possibly clears it. -;---------------------------------------------------------------------------- -cprocstart PM_ctrlCHit - - ARG clearFlag:UINT - - enter_c - pushf ; Save interrupt status - push es -ifdef flatmodel - mov ebx,[_PM_ctrlCPtr] -else - les bx,[_PM_ctrlCPtr] -endif - cli ; No interrupts thanks! - mov _ax,[_ES _bx] - test [BYTE clearFlag],1 - jz @@Done - mov [UINT _ES _bx],0 - -@@Done: - pop es - popf ; Restore interrupt status - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; PM_criticalISR - Control Error handler interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; Interrupt handler for the MSDOS Critical Error interrupt, to dispatch -; control to high level C based subroutines. We save the state of all -; registers in this routine, and switch to a local stack. We also pass -; the values of the AX and DI registers to the as pointers, so that the -; values can be modified before returning to MSDOS. -;---------------------------------------------------------------------------- -cprocfar _PM_criticalISR - - sti - push ds ; Save value of DS - push es - push _bx ; Save register values changed - cld ; Clear direction flag - - LOAD_DS ; Load DS register -ifdef flatmodel - mov ebx,[_PM_critPtr] -else - les bx,[_PM_critPtr] -endif - mov [_ES _bx],ax - mov [_ES _bx+2],di - -; Run alternate critical handler code if installed - - cmp [CPTR _PM_critHandler],0 - je @@NoAltHandler - - pushad - push _di - push _ax - call [CPTR _PM_critHandler] ; Call C code - _add sp,4,8 - popad - - pop _bx - pop es - pop ds - iret ; Return from interrupt - -@@NoAltHandler: - mov ax,3 ; Tell MSDOS to fail the operation - pop _bx - pop es - pop ds - iret ; Return from interrupt - -cprocend - -;---------------------------------------------------------------------------- -; int PM_criticalError(int *axVal,int *diVal,int clearFlag) -;---------------------------------------------------------------------------- -; Returns the current state of the critical error flags, and the values that -; MSDOS passed in the AX and DI registers to our handler. -;---------------------------------------------------------------------------- -cprocstart PM_criticalError - - ARG axVal:DPTR, diVal:DPTR, clearFlag:UINT - - enter_c - pushf ; Save interrupt status - push es -ifdef flatmodel - mov ebx,[_PM_critPtr] -else - les bx,[_PM_critPtr] -endif - cli ; No interrupts thanks! - xor _ax,_ax - xor _di,_di - mov ax,[_ES _bx] - mov di,[_ES _bx+2] - test [BYTE clearFlag],1 - jz @@NoClear - mov [ULONG _ES _bx],0 -@@NoClear: - _les _bx,[axVal] - mov [_ES _bx],_ax - _les _bx,[diVal] - mov [_ES _bx],_di - pop es - popf ; Restore interrupt status - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_setMouseHandler(int mask, PM_mouseHandler mh) -;---------------------------------------------------------------------------- -cprocstart _PM_setMouseHandler - - ARG mouseMask:UINT - - enter_c - push es - - mov ax,0Ch ; AX := Function 12 - install interrupt sub - mov _cx,[mouseMask] ; CX := mouse mask - mov _dx,offset _PM_mouseISR - push cs - pop es ; ES:_DX -> mouse handler - int 33h ; Call mouse driver - - pop es - leave_c - ret - -cprocend - -ifdef flatmodel - -;---------------------------------------------------------------------------- -; void PM_mousePMCB(void) -;---------------------------------------------------------------------------- -; Mouse realmode callback routine. Upon entry to this routine, we recieve -; the following from the DPMI server: -; -; Entry: DS:_SI -> Real mode stack at time of call -; ES:_DI -> Real mode register data structure -; SS:_SP -> Locked protected mode stack to use -;---------------------------------------------------------------------------- -cprocfar _PM_mousePMCB - - pushad - mov eax,[es:_di+1Ch] ; Load register values from real mode - mov ebx,[es:_di+10h] - mov ecx,[es:_di+18h] - mov edx,[es:_di+14h] - mov esi,[es:_di+04h] - mov edi,[es:_di] - call _PM_mouseISR ; Call the mouse handler - popad - - mov ax,[ds:_si] - mov [es:_di+2Ah],ax ; Plug in return IP address - mov ax,[ds:_si+2] - mov [es:_di+2Ch],ax ; Plug in return CS value - add [WORD es:_di+2Eh],4 ; Remove return address from stack - iret ; Go back to real mode! - -cprocend - -;---------------------------------------------------------------------------- -; void PM_int10PMCB(void) -;---------------------------------------------------------------------------- -; int10 realmode callback routine. Upon entry to this routine, we recieve -; the following from the DPMI server: -; -; Entry: DS:ESI -> Real mode stack at time of call -; ES:EDI -> Real mode register data structure -; SS:ESP -> Locked protected mode stack to use -;---------------------------------------------------------------------------- -cprocfar _PM_int10PMCB - - pushad - push ds - push es - push fs - - pushfd - pop eax - mov [es:edi+20h],ax ; Save return flag status - mov ax,[ds:esi] - mov [es:edi+2Ah],ax ; Plug in return IP address - mov ax,[ds:esi+2] - mov [es:edi+2Ch],ax ; Plug in return CS value - add [WORD es:edi+2Eh],4 ; Remove return address from stack - -; Call the install int10 handler in protected mode. This function gets called -; with DS set to the current data selector, and ES:EDI pointing the the -; real mode DPMI register structure at the time of the interrupt. The -; handle must be written in assembler to be able to extract the real mode -; register values from the structure - - push es - pop fs ; FS:EDI -> real mode registers - LOAD_DS - NEWSTK Int10Stack ; Switch to local stack - - call [_PM_int10Handler] - - RESTSTK Int10Stack ; Restore previous stack - pop fs - pop es - pop ds - popad - iret ; Go back to real mode! - -cprocend - -endif - -cpublic _PM_pmdosCodeEnd - -endcodeseg _pmdos - - END ; End of module diff --git a/board/MAI/bios_emulator/scitech/src/pm/dos/_vflat.asm b/board/MAI/bios_emulator/scitech/src/pm/dos/_vflat.asm deleted file mode 100644 index 34985a9d8b..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/_vflat.asm +++ /dev/null @@ -1,652 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Based on original code Copyright 1994 Otto Chrons -;* -;* Language: 80386 Assembler, TASM 4.0 or later -;* Environment: IBM PC 32 bit protected mode -;* -;* Description: Low level page fault handler for virtual linear framebuffers. -;* -;**************************************************************************** - - IDEAL - JUMPS - -include "scitech.mac" ; Memory model macros - -header _vflat ; Set up memory model - -VFLAT_START EQU 0F0000000h -VFLAT_END EQU 0F03FFFFFh -PAGE_PRESENT EQU 1 -PAGE_NOTPRESENT EQU 0 -PAGE_READ EQU 0 -PAGE_WRITE EQU 2 - -ifdef DOS4GW - -;---------------------------------------------------------------------------- -; DOS4G/W flat linear framebuffer emulation. -;---------------------------------------------------------------------------- - -begdataseg _vflat - -; Near pointers to the page directory base and our page tables. All of -; this memory is always located in the first Mb of DOS memory. - -PDBR dd 0 ; Page directory base register (CR3) -accessPageAddr dd 0 -accessPageTable dd 0 - -; CauseWay page directory & 1st page table linear addresses. - -CauseWayDIRLinear dd 0 -CauseWay1stLinear dd 0 - -; Place to store a copy of the original Page Table Directory before we -; intialised our virtual buffer code. - -pageDirectory: resd 1024 ; Saved page table directory - -ValidCS dw 0 ; Valid CS for page faults -Ring0CS dw 0 ; Our ring 0 code selector -LastPage dd 0 ; Last page we mapped in -BankFuncBuf: resb 101 ; Place to store bank switch code -BankFuncPtr dd offset BankFuncBuf - -INT14Gate: -INT14Offset dd 0 ; eip of original vector -INT14Selector dw 0 ; cs of original vector - - cextern _PM_savedDS,USHORT - cextern VF_haveCauseWay,BOOL - -enddataseg _vflat - -begcodeseg _vflat ; Start of code segment - - cextern VF_malloc,FPTR - -;---------------------------------------------------------------------------- -; PF_handler64k - Page fault handler for 64k banks -;---------------------------------------------------------------------------- -; The handler below is a 32 bit ring 0 page fault handler. It receives -; control immediately after any page fault or after an IRQ6 (hardware -; interrupt). This provides the fastest possible handling of page faults -; since it jump directly here. If this is a page fault, the number -; immediately on the stack will be an error code, at offset 4 will be -; the eip of the faulting instruction, at offset 8 will be the cs of the -; faulting instruction. If it is a hardware interrupt, it will not have -; the error code and the eflags will be at offset 8. -;---------------------------------------------------------------------------- -cprocfar PF_handler64k - -; Check if this is a processor exeception or a page fault - - push eax - mov ax,[cs:ValidCS] ; Use CS override to access data - cmp [ss:esp+12],ax ; Is this a page fault? - jne @@ToOldHandler ; Nope, jump to the previous handler - -; Get address of page fault and check if within our handlers range - - mov eax,cr2 ; EBX has page fault linear address - cmp eax,VFLAT_START ; Is the fault less than ours? - jb @@ToOldHandler ; Yep, go to previous handler - cmp eax,VFLAT_END ; Is the fault more than ours? - jae @@ToOldHandler ; Yep, go to previous handler - -; This is our page fault, so we need to handle it - - pushad - push ds - push es - mov ebx,eax ; EBX := page fault address - and ebx,invert 0FFFFh ; Mask to 64k bank boundary - mov ds,[cs:_PM_savedDS]; Load segment registers - mov es,[cs:_PM_savedDS] - -; Map in the page table for our virtual framebuffer area for modification - - mov edi,[PDBR] ; EDI points to page directory - mov edx,ebx ; EDX = linear address - shr edx,22 ; EDX = offset to page directory - mov edx,[edx*4+edi] ; EDX = physical page table address - mov eax,edx - mov edx,[accessPageTable] - or eax,7 - mov [edx],eax - mov eax,cr3 - mov cr3,eax ; Update page table cache - -; Mark all pages valid for the new page fault area - - mov esi,ebx ; ESI := linear address for page - shr esi,10 - and esi,0FFFh ; Offset into page table - add esi,[accessPageAddr] -ifdef USE_NASM -%assign off 0 -%rep 16 - or [DWORD esi+off],0000000001h ; Enable pages -%assign off off+4 -%endrep -else -off = 0 -REPT 16 - or [DWORD esi+off],0000000001h ; Enable pages -off = off+4 -ENDM -endif - -; Mark all pages invalid for the previously mapped area - - xchg esi,[LastPage] ; Save last page for next page fault - test esi,esi - jz @@DoneMapping ; Dont update if first time round -ifdef USE_NASM -%assign off 0 -%rep 16 - or [DWORD esi+off],0FFFFFFFEh ; Disable pages -%assign off off+4 -%endrep -else -off = 0 -REPT 16 - and [DWORD esi+off],0FFFFFFFEh ; Disable pages -off = off+4 -ENDM -endif - -@@DoneMapping: - mov eax,cr3 - mov cr3,eax ; Flush the TLB - -; Now program the new SuperVGA starting bank address - - mov eax,ebx ; EAX := page fault address - shr eax,16 - and eax,0FFh ; Mask to 0-255 - call [BankFuncPtr] ; Call the bank switch function - - pop es - pop ds - popad - pop eax - add esp,4 ; Pop the error code from stack - iretd ; Return to faulting instruction - -@@ToOldHandler: - pop eax -ifdef USE_NASM - jmp far dword [cs:INT14Gate]; Chain to previous handler -else - jmp [FWORD cs:INT14Gate]; Chain to previous handler -endif - -cprocend - -;---------------------------------------------------------------------------- -; PF_handler4k - Page fault handler for 4k banks -;---------------------------------------------------------------------------- -; The handler below is a 32 bit ring 0 page fault handler. It receives -; control immediately after any page fault or after an IRQ6 (hardware -; interrupt). This provides the fastest possible handling of page faults -; since it jump directly here. If this is a page fault, the number -; immediately on the stack will be an error code, at offset 4 will be -; the eip of the faulting instruction, at offset 8 will be the cs of the -; faulting instruction. If it is a hardware interrupt, it will not have -; the error code and the eflags will be at offset 8. -;---------------------------------------------------------------------------- -cprocfar PF_handler4k - -; Fill in when we have tested all the 64Kb code - -ifdef USE_NASM - jmp far dword [cs:INT14Gate]; Chain to previous handler -else - jmp [FWORD cs:INT14Gate]; Chain to previous handler -endif - -cprocend - -;---------------------------------------------------------------------------- -; void InstallFaultHandler(void *baseAddr,int bankSize) -;---------------------------------------------------------------------------- -; Installes the page fault handler directly int the interrupt descriptor -; table for maximum performance. This of course requires ring 0 access, -; but none of this stuff will run without ring 0! -;---------------------------------------------------------------------------- -cprocstart InstallFaultHandler - - ARG baseAddr:ULONG, bankSize:UINT - - enter_c - - mov [DWORD LastPage],0 ; No pages have been mapped - mov ax,cs - mov [ValidCS],ax ; Save CS value for page faults - -; Put address of our page fault handler into the IDT directly - - sub esp,6 ; Allocate space on stack -ifdef USE_NASM - sidt [ss:esp] ; Store pointer to IDT -else - sidt [FWORD ss:esp] ; Store pointer to IDT -endif - pop ax ; add esp,2 - pop eax ; Absolute address of IDT - add eax,14*8 ; Point to Int #14 - -; Note that Interrupt gates do not have the high and low word of the -; offset in adjacent words in memory, there are 4 bytes separating them. - - mov ecx,[eax] ; Get cs and low 16 bits of offset - mov edx,[eax+6] ; Get high 16 bits of offset in dx - shl edx,16 - mov dx,cx ; edx has offset - mov [INT14Offset],edx ; Save offset - shr ecx,16 - mov [INT14Selector],cx ; Save original cs - mov [eax+2],cs ; Install new cs - mov edx,offset PF_handler64k - cmp [UINT bankSize],4 - jne @@1 - mov edx,offset PF_handler4k -@@1: mov [eax],dx ; Install low word of offset - shr edx,16 - mov [eax+6],dx ; Install high word of offset - - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; void RemoveFaultHandler(void) -;---------------------------------------------------------------------------- -; Closes down the virtual framebuffer services and restores the previous -; page fault handler. -;---------------------------------------------------------------------------- -cprocstart RemoveFaultHandler - - enter_c - -; Remove page fault handler from IDT - - sub esp,6 ; Allocate space on stack -ifdef USE_NASM - sidt [ss:esp] ; Store pointer to IDT -else - sidt [FWORD ss:esp] ; Store pointer to IDT -endif - - pop ax ; add esp,2 - pop eax ; Absolute address of IDT - add eax,14*8 ; Point to Int #14 - mov cx,[INT14Selector] - mov [eax+2],cx ; Restore original CS - mov edx,[INT14Offset] - mov [eax],dx ; Install low word of offset - shr edx,16 - mov [eax+6],dx ; Install high word of offset - - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; void InstallBankFunc(int codeLen,void *bankFunc) -;---------------------------------------------------------------------------- -; Installs the bank switch function by relocating it into our data segment -; and making it into a callable function. We do it this way to make the -; code identical to the way that the VflatD devices work under Windows. -;---------------------------------------------------------------------------- -cprocstart InstallBankFunc - - ARG codeLen:UINT, bankFunc:DPTR - - enter_c - - mov esi,[bankFunc] ; Copy the code into buffer - mov edi,offset BankFuncBuf - mov ecx,[codeLen] - rep movsb - mov [BYTE edi],0C3h ; Terminate the function with a near ret - - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; int InitPaging(void) -;---------------------------------------------------------------------------- -; Initializes paging system. If paging is not enabled, builds a page table -; directory and page tables for physical memory -; -; Exit: 0 - Successful -; -1 - Couldn't initialize paging mechanism -;---------------------------------------------------------------------------- -cprocstart InitPaging - - push ebx - push ecx - push edx - push esi - push edi - -; Are we running under CauseWay? - - mov ax,0FFF9h - int 31h - jc @@NotCauseway - cmp ecx,"CAUS" - jnz @@NotCauseway - cmp edx,"EWAY" - jnz @@NotCauseway - - mov [BOOL VF_haveCauseWay],1 - mov [CauseWayDIRLinear],esi - mov [CauseWay1stLinear],edi - -; Check for DPMI - - mov ax,0ff00h - push es - int 31h - pop es - shr edi,2 - and edi,3 - cmp edi,2 - jz @@ErrExit ; Not supported under DPMI - - mov eax,[CauseWayDIRLinear] - jmp @@CopyCR3 - -@@NotCauseway: - mov ax,cs - test ax,3 ; Which ring are we running - jnz @@ErrExit ; Needs zero ring to access - ; page tables (CR3) - mov eax,cr0 ; Load CR0 - test eax,80000000h ; Is paging enabled? - jz @@ErrExit ; No, we must have paging! - - mov eax,cr3 ; Load directory address - and eax,0FFFFF000h - -@@CopyCR3: - mov [PDBR],eax ; Save it - mov esi,eax - mov edi,offset pageDirectory - mov ecx,1024 - cld - rep movsd ; Copy the original page table directory - cmp [DWORD accessPageAddr],0; Check if we have allocated page - jne @@HaveRealMem ; table already (we cant free it) - - mov eax,0100h ; DPMI DOS allocate - mov ebx,8192/16 - int 31h ; Allocate 8192 bytes - and eax,0FFFFh - shl eax,4 ; EAX points to newly allocated memory - add eax,4095 - and eax,0FFFFF000h ; Page align - mov [accessPageAddr],eax - -@@HaveRealMem: - mov eax,[accessPageAddr] ; EAX -> page table in 1st Mb - shr eax,12 - and eax,3FFh ; Page table offset - shl eax,2 - cmp [BOOL VF_haveCauseWay],0 - jz @@NotCW0 - mov ebx,[CauseWay1stLinear] - jmp @@Put1st - -@@NotCW0: - mov ebx,[PDBR] - mov ebx,[ebx] - and ebx,0FFFFF000h ; Page table for 1st megabyte - -@@Put1st: - add eax,ebx - mov [accessPageTable],eax - sub eax,eax ; No error - jmp @@Exit - -@@ErrExit: - mov eax,-1 - -@@Exit: pop edi - pop esi - pop edx - pop ecx - pop ebx - ret - -cprocend - -;---------------------------------------------------------------------------- -; void ClosePaging(void) -;---------------------------------------------------------------------------- -; Closes the paging system -;---------------------------------------------------------------------------- -cprocstart ClosePaging - - push eax - push ecx - push edx - push esi - push edi - - mov eax,[accessPageAddr] - call AccessPage ; Restore AccessPage mapping - mov edi,[PDBR] - mov esi,offset pageDirectory - mov ecx,1024 - cld - rep movsd ; Restore the original page table directory - -@@Exit: pop edi - pop esi - pop edx - pop ecx - pop eax - ret - -cprocend - -;---------------------------------------------------------------------------- -; long AccessPage(long phys) -;---------------------------------------------------------------------------- -; Maps a known page to given physical memory -; Entry: EAX - Physical memory -; Exit: EAX - Linear memory address of mapped phys mem -;---------------------------------------------------------------------------- -cprocstatic AccessPage - - push edx - mov edx,[accessPageTable] - or eax,7 - mov [edx],eax - mov eax,cr3 - mov cr3,eax ; Update page table cache - mov eax,[accessPageAddr] - pop edx - ret - -cprocend - -;---------------------------------------------------------------------------- -; long GetPhysicalAddress(long linear) -;---------------------------------------------------------------------------- -; Returns the physical address of linear address -; Entry: EAX - Linear address to convert -; Exit: EAX - Physical address -;---------------------------------------------------------------------------- -cprocstatic GetPhysicalAddress - - push ebx - push edx - mov edx,eax - shr edx,22 ; EDX is the directory offset - mov ebx,[PDBR] - mov edx,[edx*4+ebx] ; Load page table address - push eax - mov eax,edx - call AccessPage ; Access the page table - mov edx,eax - pop eax - shr eax,12 - and eax,03FFh ; EAX offset into page table - mov eax,[edx+eax*4] ; Load physical address - and eax,0FFFFF000h - pop edx - pop ebx - ret - -cprocend - -;---------------------------------------------------------------------------- -; void CreatePageTable(long pageDEntry) -;---------------------------------------------------------------------------- -; Creates a page table for specific address (4MB) -; Entry: EAX - Page directory entry (top 10-bits of address) -;---------------------------------------------------------------------------- -cprocstatic CreatePageTable - - push ebx - push ecx - push edx - push edi - mov ebx,eax ; Save address - mov eax,8192 - push eax - call VF_malloc ; Allocate page table directory - add esp,4 - add eax,0FFFh - and eax,0FFFFF000h ; Page align (4KB) - mov edi,eax ; Save page table linear address - sub eax,eax ; Fill with zero - mov ecx,1024 - cld - rep stosd ; Clear page table - sub edi,4096 - mov eax,edi - call GetPhysicalAddress - mov edx,[PDBR] - or eax,7 ; Present/write/user bit - mov [edx+ebx*4],eax ; Save physical address into page directory - mov eax,cr3 - mov cr3,eax ; Update page table cache - pop edi - pop edx - pop ecx - pop ebx - ret - -cprocend - -;---------------------------------------------------------------------------- -; void MapPhysical2Linear(ulong pAddr, ulong lAddr, int pages, int flags); -;---------------------------------------------------------------------------- -; Maps physical memory into linear memory -; Entry: pAddr - Physical address -; lAddr - Linear address -; pages - Number of 4K pages to map -; flags - Page flags -; bit 0 = present -; bit 1 = Read(0)/Write(1) -;---------------------------------------------------------------------------- -cprocstart MapPhysical2Linear - - ARG pAddr:ULONG, lAddr:ULONG, pages:UINT, pflags:UINT - - enter_c - - and [ULONG pAddr],0FFFFF000h; Page boundary - and [ULONG lAddr],0FFFFF000h; Page boundary - mov ecx,[pflags] - and ecx,11b ; Just two bits - or ecx,100b ; Supervisor bit - mov [pflags],ecx - - mov edx,[lAddr] - shr edx,22 ; EDX = Directory - mov esi,[PDBR] - mov edi,[pages] ; EDI page count - mov ebx,[lAddr] - -@@CreateLoop: - mov ecx,[esi+edx*4] ; Load page table address - test ecx,1 ; Is it present? - jnz @@TableOK - mov eax,edx - call CreatePageTable ; Create a page table -@@TableOK: - mov eax,ebx - shr eax,12 - and eax,3FFh - sub eax,1024 - neg eax ; EAX = page count in this table - inc edx ; Next table - mov ebx,0 ; Next time we'll map 1K pages - sub edi,eax ; Subtract mapped pages from page count - jns @@CreateLoop ; Create more tables if necessary - - mov ecx,[pages] ; ECX = Page count - mov esi,[lAddr] - shr esi,12 ; Offset part isn't needed - mov edi,[pAddr] -@@MappingLoop: - mov eax,esi - shr eax,10 ; EAX = offset to page directory - mov ebx,[PDBR] - mov eax,[eax*4+ebx] ; EAX = page table address - call AccessPage - mov ebx,esi - and ebx,3FFh ; EBX = offset to page table - mov edx,edi - add edi,4096 ; Next physical address - inc esi ; Next linear page - or edx,[pflags] ; Update flags... - mov [eax+ebx*4],edx ; Store page table entry - loop @@MappingLoop - mov eax,cr3 - mov cr3,eax ; Update page table cache - - leave_c - ret - -cprocend - -endcodeseg _vflat - -endif - - END ; End of module diff --git a/board/MAI/bios_emulator/scitech/src/pm/dos/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/dos/cpuinfo.c deleted file mode 100644 index ee117c78e9..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/cpuinfo.c +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: DOS -* -* Description: MSDOS specific code for the CPU detection module. -* -****************************************************************************/ - -/*----------------------------- Implementation ----------------------------*/ - -/* External timing function */ - -void __ZTimerInit(void); - -/**************************************************************************** -REMARKS: -Do nothing for DOS because we don't have thread priorities. -****************************************************************************/ -#define SetMaxThreadPriority() 0 - -/**************************************************************************** -REMARKS: -Do nothing for DOS because we don't have thread priorities. -****************************************************************************/ -#define RestoreThreadPriority(i) (void)(i) - -/**************************************************************************** -REMARKS: -Initialise the counter and return the frequency of the counter. -****************************************************************************/ -static void GetCounterFrequency( - CPU_largeInteger *freq) -{ - ulong resolution; - - __ZTimerInit(); - ULZTimerResolution(&resolution); - freq->low = (ulong)(10000000000.0 / resolution); - freq->high = 0; -} - -/**************************************************************************** -REMARKS: -Read the counter and return the counter value. -****************************************************************************/ -#define GetCounter(t) \ -{ \ - (t)->low = ULZReadTime() * 10000L; \ - (t)->high = 0; \ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/dos/event.c b/board/MAI/bios_emulator/scitech/src/pm/dos/event.c deleted file mode 100644 index a969d111b4..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/event.c +++ /dev/null @@ -1,494 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit DOS -* -* Description: 32-bit DOS implementation for the SciTech cross platform -* event library. -* -****************************************************************************/ - -/*--------------------------- Global variables ----------------------------*/ - -ibool _VARAPI _EVT_useEvents = true; /* True to use event handling */ -ibool _VARAPI _EVT_installed = 0; /* Event handers installed? */ -uchar _VARAPI *_EVT_biosPtr = NULL; /* Pointer to the BIOS data area */ -static ibool haveMouse = false; /* True if we have a mouse */ - -/*---------------------------- Implementation -----------------------------*/ - -/* External assembler functions */ - -void EVTAPI _EVT_pollJoystick(void); -uint EVTAPI _EVT_disableInt(void); -uint EVTAPI _EVT_restoreInt(uint flags); -void EVTAPI _EVT_codeStart(void); -void EVTAPI _EVT_codeEnd(void); -void EVTAPI _EVT_cCodeStart(void); -void EVTAPI _EVT_cCodeEnd(void); -int EVTAPI _EVT_getKeyCode(void); -void EVTAPI _EVT_pumpMessages(void); -int EVTAPI EVT_rdinx(int port,int index); -void EVTAPI EVT_wrinx(int port,int index,int value); - -#ifdef NO_KEYBOARD_INTERRUPT -/**************************************************************************** -REMARKS: -This function is used to pump all keyboard messages from the BIOS keyboard -handler into our event queue. This can be used to avoid using the -installable keyboard handler if this is causing problems. -****************************************************************************/ -static void EVTAPI _EVT_pumpMessages(void) -{ - RMREGS regs; - uint key,ps; - - /* Since the keyboard ISR has not been installed if NO_IDE_BUG has - * been defined, we first check for any pending keyboard events - * here, and if there are some insert them into the event queue to - * be picked up later - what a kludge. - */ - while ((key = _EVT_getKeyCode()) != 0) { - ps = _EVT_disableInt(); - addKeyEvent(EVT_KEYDOWN, key); - _EVT_restoreInt(ps); - } - - regs.x.ax = 0x0B; /* Reset Move Mouse */ - PM_int86(0x33,®s,®s); -} -#endif - -/**************************************************************************** -REMARKS: -This function is used to return the number of ticks since system -startup in milliseconds. This should be the same value that is placed into -the time stamp fields of events, and is used to implement auto mouse down -events. -****************************************************************************/ -ulong _EVT_getTicks(void) -{ - return (ulong)PM_getLong(_EVT_biosPtr+0x6C) * 55UL; -} - -/**************************************************************************** -REMARKS: -Reboots the machine from DOS (warm boot) -****************************************************************************/ -static void Reboot(void) -{ - PMREGS regs; - PMSREGS sregs; - - ushort *rebootType = PM_mapRealPointer(0x40,0x72); - *rebootType = 0x1234; - PM_callRealMode(0xFFFF,0x0000,®s,&sregs); -} - -/**************************************************************************** -REMARKS: -Include generic raw scancode keyboard module. -****************************************************************************/ -#define SUPPORT_CTRL_ALT_DEL -#include "common/keyboard.c" - -/**************************************************************************** -REMARKS: -This function fools the DOS mouse driver into thinking that it is running -in graphics mode, rather than text mode so we always get virtual coordinates -correctly rather than character coordinates. -****************************************************************************/ -int _EVT_foolMouse(void) -{ - int oldmode = PM_getByte(_EVT_biosPtr+0x49); - PM_setByte(_EVT_biosPtr+0x49,0x10); - oldmode |= (EVT_rdinx(0x3C4,0x2) << 8); - return oldmode; -} - -/**************************************************************************** -REMARKS: -This function unfools the DOS mouse driver after we have finished calling it. -****************************************************************************/ -void _EVT_unfoolMouse( - int oldmode) -{ - PM_setByte(_EVT_biosPtr+0x49,oldmode); - - /* Some mouse drivers reset the plane mask register for VGA plane 4 - * modes, which screws up the display on some VGA compatible controllers - * in SuperVGA modes. We reset the value back again in here to solve - * the problem. - */ - EVT_wrinx(0x3C4,0x2,oldmode >> 8); -} - -/**************************************************************************** -REMARKS: -Determines if we have a mouse attached and functioning. -****************************************************************************/ -static ibool detectMouse(void) -{ - RMREGS regs; - RMSREGS sregs; - uchar *p; - ibool retval; - - regs.x.ax = 0x3533; /* Get interrupt vector 0x33 */ - PM_int86x(0x21,®s,®s,&sregs); - - /* Check that interrupt vector 0x33 is not a zero, and that the first - * instruction in the interrupt vector is not an IRET instruction - */ - p = PM_mapRealPointer(sregs.es, regs.x.bx); - retval = ((sregs.es != 0) || (regs.x.bx != 0)) && (PM_getByte(p) != 207); - return retval; -} - -/**************************************************************************** -PARAMETERS: -what - Event code -message - Event message -x,y - Mouse position at time of event -but_stat - Mouse button status at time of event - -REMARKS: -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). -****************************************************************************/ -static void addMouseEvent( - uint what, - uint message, - int x, - int y, - int mickeyX, - int mickeyY, - uint but_stat) -{ - 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 */ - } -} - -/**************************************************************************** -PARAMETERS: -mask - Event mask -butstate - Button state -x - Mouse x coordinate -y - Mouse y coordinate - -REMARKS: -Mouse event handling routine. This gets called when a mouse event occurs, -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. -****************************************************************************/ -static void EVTAPI mouseISR( - uint mask, - uint butstate, - int x, - int y, - int mickeyX, - int mickeyY) -{ - uint ps; - 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); - } - 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); - } - 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); - } - EVT.oldKey = -1; -} - -/**************************************************************************** -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. -****************************************************************************/ -static void EVTAPI keyboardISR(void) -{ - processRawScanCode(PM_inpb(0x60)); - PM_outpb(0x20,0x20); -} - -/**************************************************************************** -REMARKS: -Safely abort the event module upon catching a fatal error. -****************************************************************************/ -void _EVT_abort() -{ - EVT_exit(); - PM_fatalError("Unhandled exception!"); -} - -/**************************************************************************** -PARAMETERS: -mouseMove - Callback function to call wheneve the mouse needs to be moved - -REMARKS: -Initiliase the event handling module. Here we install our mouse handling ISR -to be called whenever any button's are pressed or released. We also build -the free list of events in the event queue. - -We use handler number 2 of the mouse libraries interrupt handlers for our -event handling routines. -****************************************************************************/ -void EVTAPI EVT_init( - _EVT_mouseMoveHandler mouseMove) -{ - int i; - - PM_init(); - EVT.mouseMove = mouseMove; - _EVT_biosPtr = PM_getBIOSPointer(); - EVT_resume(); - - /* Grab all characters pending in the keyboard buffer and stuff - * them into our event buffer. This allows us to pick up any keypresses - * while the program is initialising. - */ - while ((i = _EVT_getKeyCode()) != 0) - addKeyEvent(EVT_KEYDOWN,i); -} - -/**************************************************************************** -REMARKS: -Initiailises the internal event handling modules. The EVT_suspend function -can be called to suspend event handling (such as when shelling out to DOS), -and this function can be used to resume it again later. -****************************************************************************/ -void EVTAPI EVT_resume(void) -{ - static int locked = 0; - int stat; - uchar mods; - PM_lockHandle lh; /* Unused in DOS */ - - if (_EVT_useEvents) { - /* Initialise the event queue and enable our interrupt handlers */ - initEventQueue(); -#ifndef NO_KEYBOARD_INTERRUPT - PM_setKeyHandler(keyboardISR); -#endif -#ifndef NO_MOUSE_INTERRUPT - 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; - } -} - -/**************************************************************************** -REMARKS -Changes the range of coordinates returned by the mouse functions to the -specified range of values. This is used when changing between graphics -modes set the range of mouse coordinates for the new display mode. -****************************************************************************/ -void EVTAPI EVT_setMouseRange( - int xRes, - int yRes) -{ - 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); - } -} - -/**************************************************************************** -REMARKS -Modifes the mouse coordinates as necessary if scaling to OS coordinates, -and sets the OS mouse cursor position. -****************************************************************************/ -void _EVT_setMousePos( - int *x, - int *y) -{ - 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); - } -} - -/**************************************************************************** -REMARKS -Suspends all of our event handling operations. This is also used to -de-install the event handling code. -****************************************************************************/ -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; - } -} - -/**************************************************************************** -REMARKS -Exits the event module for program terminatation. -****************************************************************************/ -void EVTAPI EVT_exit(void) -{ - EVT_suspend(); -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/dos/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/dos/oshdr.h deleted file mode 100644 index 35e8e00f72..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/oshdr.h +++ /dev/null @@ -1,29 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit DOS -* -* Description: Include file to include all OS specific header files. -* -****************************************************************************/ diff --git a/board/MAI/bios_emulator/scitech/src/pm/dos/pm.c b/board/MAI/bios_emulator/scitech/src/pm/dos/pm.c deleted file mode 100644 index 2ad9e34f91..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/pm.c +++ /dev/null @@ -1,2243 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 16/32 bit DOS -* -* Description: Implementation for the OS Portability Manager Library, which -* contains functions to implement OS specific services in a -* generic, cross platform API. Porting the OS Portability -* Manager library is the first step to porting any SciTech -* products to a new platform. -* -****************************************************************************/ - -#include "pmapi.h" -#include "drvlib/os/os.h" -#include "ztimerc.h" -#include "mtrr.h" -#include "pm_help.h" -#include -#include -#include -#include -#include -#ifdef __GNUC__ -#include -#include -#include -#else -#include -#endif -#ifdef __BORLANDC__ -#pragma warn -par -#endif - -/*--------------------------- Global variables ----------------------------*/ - -typedef struct { - int oldMode; - int old50Lines; - } DOS_stateBuf; - -#define MAX_RM_BLOCKS 10 - -static struct { - void *p; - uint tag; - } rmBlocks[MAX_RM_BLOCKS]; - -static uint VESABuf_len = 1024; /* Length of the VESABuf buffer */ -static void *VESABuf_ptr = NULL; /* Near pointer to VESABuf */ -static uint VESABuf_rseg; /* Real mode segment of VESABuf */ -static uint VESABuf_roff; /* Real mode offset of VESABuf */ -static void (PMAPIP fatalErrorCleanup)(void) = NULL; -ushort _VARAPI _PM_savedDS = 0; -#ifdef DOS4GW -static ulong PDB = 0,*pPDB = NULL; -#endif -#ifndef REALMODE -static char VXD_name[] = PMHELP_NAME; -static char VXD_module[] = PMHELP_MODULE; -static char VXD_DDBName[] = PMHELP_DDBNAME; -static uint VXD_version = -1; -static uint VXD_loadOff = 0; -static uint VXD_loadSel = 0; -uint _VARAPI _PM_VXD_off = 0; -uint _VARAPI _PM_VXD_sel = 0; -int _VARAPI _PM_haveCauseWay = -1; - -/* Memory mapping cache */ - -#define MAX_MEMORY_MAPPINGS 100 -typedef struct { - ulong physical; - ulong linear; - ulong limit; - } mmapping; -static mmapping maps[MAX_MEMORY_MAPPINGS] = {0}; -static int numMaps = 0; - -/* Page sized block cache */ - -#define PAGES_PER_BLOCK 100 -#define FREELIST_NEXT(p) (*(void**)(p)) -typedef struct pageblock { - struct pageblock *next; - struct pageblock *prev; - void *freeListStart; - void *freeList; - void *freeListEnd; - int freeCount; - } pageblock; -static pageblock *pageBlocks = NULL; -#endif - -/* Start of all page tables in CauseWay */ - -#define CW_PAGE_TABLE_START (1024UL*4096UL*1023UL) - -/*----------------------------- Implementation ----------------------------*/ - -/* External assembler functions */ - -ulong _ASMAPI _PM_getPDB(void); -int _ASMAPI _PM_pagingEnabled(void); -void _ASMAPI _PM_VxDCall(VXD_regs *regs,uint off,uint sel); - -#ifndef REALMODE -/**************************************************************************** -REMARKS: -Exit function to unload the dynamically loaded VxD -****************************************************************************/ -static void UnloadVxD(void) -{ - PMSREGS sregs; - VXD_regs r; - - r.eax = 2; - r.ebx = 0; - r.edx = (uint)VXD_module; - PM_segread(&sregs); -#ifdef __16BIT__ - r.ds = ((ulong)VXD_module) >> 16; -#else - r.ds = sregs.ds; -#endif - r.es = sregs.es; - _PM_VxDCall(&r,VXD_loadOff,VXD_loadSel); -} - -/**************************************************************************** -REMARKS: -External function to call the PMHELP helper VxD. -****************************************************************************/ -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); -} - -/**************************************************************************** -RETURNS: -BCD coded version number of the VxD, or 0 if not loaded (ie: 0x202 - 2.2) - -REMARKS: -This function gets the version number for the VxD that we have connected to. -****************************************************************************/ -uint PMAPI PMHELP_getVersion(void) -{ - VXD_regs r; - - /* 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; - } - return VXD_version = 0; -} - -/**************************************************************************** -DESCRIPTION: -Connects to the helper VxD and returns the version number - -RETURNS: -True if the VxD was found and loaded, false otherwise. - -REMARKS: -This function connects to the VxD (loading it if it is dynamically loadable) -and returns the version number of the VxD. -****************************************************************************/ -static ibool PMHELP_connect(void) -{ - PMREGS regs; - PMSREGS sregs; - VXD_regs r; - - /* Bail early if we have alread connected */ - if (VXD_version != -1) - return VXD_version != 0; - - /* Get the static SDDHELP.VXD entry point if available */ - PM_segread(&sregs); - regs.x.ax = 0x1684; - regs.x.bx = SDDHELP_DeviceID; - regs.x.di = 0; - sregs.es = 0; - PM_int386x(0x2F,®s,®s,&sregs); - _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 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 - * helper VxD instead. - */ - PM_segread(&sregs); - regs.x.ax = 0x1684; - regs.x.bx = VXDLDR_DeviceID; - regs.x.di = 0; - sregs.es = 0; - PM_int386x(0x2F,®s,®s,&sregs); - VXD_loadSel = sregs.es; - VXD_loadOff = regs.x.di; - if (VXD_loadSel == 0 && VXD_loadOff == 0) - return VXD_version = 0; - r.eax = 1; - r.ebx = 0; - r.edx = (uint)VXD_name; - PM_segread(&sregs); - r.ds = sregs.ds; - r.es = sregs.es; - _PM_VxDCall(&r,VXD_loadOff,VXD_loadSel); - if (r.eax != 0) - return VXD_version = 0; - - /* Get the dynamic VxD entry point so we can call it */ - atexit(UnloadVxD); - PM_segread(&sregs); - regs.x.ax = 0x1684; - regs.x.bx = 0; - regs.e.edi = (uint)VXD_DDBName; - PM_int386x(0x2F,®s,®s,&sregs); - _PM_VXD_sel = sregs.es; - _PM_VXD_off = regs.x.di; - if (_PM_VXD_sel == 0 && _PM_VXD_off == 0) - return VXD_version = 0; - if (PMHELP_getVersion() >= PMHELP_VERSION) - return true; - return VXD_version = 0; -} -#endif - -/**************************************************************************** -REMARKS: -Initialise the PM library. First we try to connect to a static SDDHELP.VXD -helper VxD, and check that it is a version we can use. If not we try to -dynamically load the PMHELP.VXD helper VxD -****************************************************************************/ -void PMAPI PM_init(void) -{ -#ifndef REALMODE - PMREGS regs; - - /* 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(); - } -#endif -} - -/**************************************************************************** -PARAMETERS: -base - The starting physical base address of the region -size - The size in bytes of the region -type - Type to place into the MTRR register - -RETURNS: -Error code describing the result. - -REMARKS: -Function to enable write combining for the specified region of memory. -****************************************************************************/ -int PMAPI PM_enableWriteCombine( - ulong base, - ulong size, - uint type) -{ -#ifndef REALMODE - 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; - } - return MTRR_enableWriteCombine(base,size,type); -#else - return PM_MTRR_NOT_SUPPORTED; -#endif -} - -ibool PMAPI PM_haveBIOSAccess(void) -{ return true; } - -long PMAPI PM_getOSType(void) -{ return _OS_DOS; } - -int PMAPI PM_getModeType(void) -{ -#if defined(REALMODE) - return PM_realMode; -#elif defined(PM286) - return PM_286; -#elif defined(PM386) - return PM_386; -#endif -} - -void PMAPI PM_backslash(char *s) -{ - uint pos = strlen(s); - if (s[pos-1] != '\\') { - s[pos] = '\\'; - s[pos+1] = '\0'; - } -} - -void PMAPI PM_setFatalErrorCleanup( - void (PMAPIP cleanup)(void)) -{ - fatalErrorCleanup = cleanup; -} - -void PMAPI PM_fatalError(const char *msg) -{ - if (fatalErrorCleanup) - fatalErrorCleanup(); - fprintf(stderr,"%s\n", msg); - exit(1); -} - -static void ExitVBEBuf(void) -{ - if (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); - } - *len = VESABuf_len; - *rseg = VESABuf_rseg; - *roff = VESABuf_roff; - return VESABuf_ptr; -} - -int PMAPI PM_int386(int intno, PMREGS *in, PMREGS *out) -{ - PMSREGS sregs; - PM_segread(&sregs); - return PM_int386x(intno,in,out,&sregs); -} - -/* Routines to set and get the real mode interrupt vectors, by making - * direct real mode calls to DOS and bypassing the DOS extenders API. - * This is the safest way to handle this, as some servers try to be - * smart about changing real mode vectors. - */ - -void PMAPI _PM_getRMvect(int intno, long *realisr) -{ - RMREGS regs; - RMSREGS sregs; - - PM_saveDS(); - regs.h.ah = 0x35; - regs.h.al = intno; - PM_int86x(0x21, ®s, ®s, &sregs); - *realisr = ((long)sregs.es << 16) | regs.x.bx; -} - -void PMAPI _PM_setRMvect(int intno, long realisr) -{ - RMREGS regs; - RMSREGS sregs; - - PM_saveDS(); - regs.h.ah = 0x25; - regs.h.al = intno; - sregs.ds = (int)(realisr >> 16); - regs.x.dx = (int)(realisr & 0xFFFF); - PM_int86x(0x21, ®s, ®s, &sregs); -} - -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; - } - } - PM_fatalError("To many real mode memory block allocations!"); -} - -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; - } - PM_fatalError("Could not find prior real mode memory block allocation!"); - return 0; -} - -char * PMAPI PM_getCurrentPath( - char *path, - int maxLen) -{ - return getcwd(path,maxLen); -} - -char PMAPI PM_getBootDrive(void) -{ return 'C'; } - -const char * PMAPI PM_getVBEAFPath(void) -{ return "c:\\"; } - -const char * PMAPI PM_getNucleusPath(void) -{ - static char path[256]; - char *env; - - if ((env = getenv("NUCLEUS_PATH")) != NULL) - 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; - } - if ((env = getenv("SystemRoot")) != NULL) { - /* Running in an NT/2K DOS box */ - strcpy(path,env); - strcat(path,"\\system32\\nucleus"); - return path; - } - return "c:\\nucleus"; -} - -const char * PMAPI PM_getNucleusConfigPath(void) -{ - static char path[256]; - strcpy(path,PM_getNucleusPath()); - PM_backslash(path); - strcat(path,"config"); - return path; -} - -const char * PMAPI PM_getUniqueID(void) -{ return "DOS"; } - -const char * PMAPI PM_getMachineName(void) -{ return "DOS"; } - -int PMAPI PM_kbhit(void) -{ - return kbhit(); -} - -int PMAPI PM_getch(void) -{ - return getch(); -} - -PM_HWND PMAPI PM_openConsole(PM_HWND hwndUser,int device,int xRes,int yRes,int bpp,ibool fullScreen) -{ - /* Not used for DOS */ - (void)hwndUser; - (void)device; - (void)xRes; - (void)yRes; - (void)bpp; - (void)fullScreen; - return 0; -} - -int PMAPI PM_getConsoleStateSize(void) -{ - return sizeof(DOS_stateBuf); -} - -void PMAPI PM_saveConsoleState(void *stateBuf,PM_HWND hwndConsole) -{ - RMREGS regs; - DOS_stateBuf *sb = stateBuf; - - /* Save the old video mode state */ - regs.h.ah = 0x0F; - PM_int86(0x10,®s,®s); - 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); - } - (void)hwndConsole; -} - -void PMAPI PM_setSuspendAppCallback(int (_ASMAPIP saveState)(int flags)) -{ - /* Not used for DOS */ - (void)saveState; -} - -void PMAPI PM_restoreConsoleState(const void *stateBuf,PM_HWND hwndConsole) -{ - RMREGS regs; - const DOS_stateBuf *sb = stateBuf; - - /* Retore 50 line mode if set */ - if (sb->old50Lines) { - regs.x.ax = 0x1112; - regs.x.bx = 0; - PM_int86(0x10,®s,®s); - } - (void)hwndConsole; -} - -void PMAPI PM_closeConsole(PM_HWND hwndConsole) -{ - /* Not used for DOS */ - (void)hwndConsole; -} - -void PMAPI PM_setOSCursorLocation(int x,int y) -{ - uchar *_biosPtr = PM_getBIOSPointer(); - PM_setByte(_biosPtr+0x50,x); - PM_setByte(_biosPtr+0x51,y); -} - -void PMAPI PM_setOSScreenWidth(int width,int height) -{ - uchar *_biosPtr = PM_getBIOSPointer(); - PM_setWord(_biosPtr+0x4A,width); - 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); - } - else { - PM_setWord(_biosPtr+0x60,0x0D0E); - PM_setByte(_biosPtr+0x85,0x016); - } -} - -void * PMAPI PM_mallocShared(long size) -{ - return PM_malloc(size); -} - -void PMAPI PM_freeShared(void *ptr) -{ - PM_free(ptr); -} - -#define GetRMVect(intno,isr) *(isr) = ((ulong*)rmZeroPtr)[intno] -#define SetRMVect(intno,isr) ((ulong*)rmZeroPtr)[intno] = (isr) - -ibool PMAPI PM_doBIOSPOST( - ushort axVal, - ulong BIOSPhysAddr, - void *mappedBIOS, - ulong BIOSLen) -{ - static int firstTime = true; - static uchar *rmZeroPtr; - long Current10,Current6D,Current42; - RMREGS regs; - RMSREGS sregs; - - /* Create a zero memory mapping for us to use */ - if (firstTime) { - 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; - } - - /* Save current handlers of int 10h and 6Dh */ - GetRMVect(0x10,&Current10); - GetRMVect(0x6D,&Current6D); - - /* POST the secondary BIOS */ - GetRMVect(0x42,&Current42); - SetRMVect(0x10,Current42); /* Restore int 10h to STD-BIOS */ - regs.x.ax = axVal; - PM_callRealMode(0xC000,0x0003,®s,&sregs); - - /* Restore current handlers */ - SetRMVect(0x10,Current10); - SetRMVect(0x6D,Current6D); - - /* Second the primary BIOS mappin 1:1 for 0xC0000 physical */ - if (BIOSPhysAddr != 0xC0000L) { - /* DOS does not support this */ - (void)mappedBIOS; - } - return true; -} - -void PMAPI PM_sleep(ulong milliseconds) -{ - ulong microseconds = milliseconds * 1000L; - LZTimerObject tm; - - LZTimerOnExt(&tm); - while (LZTimerLapExt(&tm) < microseconds) - ; - LZTimerOffExt(&tm); -} - -int PMAPI PM_getCOMPort(int port) -{ - switch (port) { - 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; - } - return 0; -} - -PM_MODULE PMAPI PM_loadLibrary( - const char *szDLLName) -{ - (void)szDLLName; - return NULL; -} - -void * PMAPI PM_getProcAddress( - PM_MODULE hModule, - const char *szProcName) -{ - (void)hModule; - (void)szProcName; - return NULL; -} - -void PMAPI PM_freeLibrary( - PM_MODULE hModule) -{ - (void)hModule; -} - -int PMAPI PM_setIOPL( - int level) -{ - return level; -} - -/**************************************************************************** -REMARKS: -Internal function to convert the find data to the generic interface. -****************************************************************************/ -static void convertFindData( - PM_findData *findData, - struct find_t *blk) -{ - ulong dwSize = findData->dwSize; - - memset(findData,0,findData->dwSize); - findData->dwSize = dwSize; - if (blk->attrib & _A_RDONLY) - findData->attrib |= PM_FILE_READONLY; - if (blk->attrib & _A_SUBDIR) - findData->attrib |= PM_FILE_DIRECTORY; - if (blk->attrib & _A_ARCH) - findData->attrib |= PM_FILE_ARCHIVE; - if (blk->attrib & _A_HIDDEN) - findData->attrib |= PM_FILE_HIDDEN; - if (blk->attrib & _A_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; -} - -#define FIND_MASK (_A_RDONLY | _A_ARCH | _A_SUBDIR | _A_HIDDEN | _A_SYSTEM) - -/**************************************************************************** -REMARKS: -Function to find the first file matching a search criteria in a directory. -****************************************************************************/ -void * PMAPI PM_findFirstFile( - const char *filename, - PM_findData *findData) -{ - struct find_t *blk; - - if ((blk = PM_malloc(sizeof(*blk))) == NULL) - return PM_FILE_INVALID; - if (_dos_findfirst((char*)filename,FIND_MASK,blk) == 0) { - convertFindData(findData,blk); - return blk; - } - return PM_FILE_INVALID; -} - -/**************************************************************************** -REMARKS: -Function to find the next file matching a search criteria in a directory. -****************************************************************************/ -ibool PMAPI PM_findNextFile( - void *handle, - PM_findData *findData) -{ - struct find_t *blk = handle; - - if (_dos_findnext(blk) == 0) { - convertFindData(findData,blk); - return true; - } - return false; -} - -/**************************************************************************** -REMARKS: -Function to close the find process -****************************************************************************/ -void PMAPI PM_findClose( - void *handle) -{ - PM_free(handle); -} - -/**************************************************************************** -REMARKS: -Function to determine if a drive is a valid drive or not. Under Unix this -function will return false for anything except a value of 3 (considered -the root drive, and equivalent to C: for non-Unix systems). The drive -numbering is: - - 1 - Drive A: - 2 - Drive B: - 3 - Drive C: - etc - -****************************************************************************/ -ibool PMAPI PM_driveValid( - char drive) -{ - RMREGS regs; - regs.h.dl = (uchar)(drive - 'A' + 1); - regs.h.ah = 0x36; /* Get disk information service */ - PM_int86(0x21,®s,®s); - return regs.x.ax != 0xFFFF; /* AX = 0xFFFF if disk is invalid */ -} - -/**************************************************************************** -REMARKS: -Function to get the current working directory for the specififed drive. -Under Unix this will always return the current working directory regardless -of what the value of 'drive' is. -****************************************************************************/ -void PMAPI PM_getdcwd( - int drive, - char *dir, - int len) -{ - uint oldDrive,maxDrives; - _dos_getdrive(&oldDrive); - _dos_setdrive(drive,&maxDrives); - getcwd(dir,len); - _dos_setdrive(oldDrive,&maxDrives); -} - -/**************************************************************************** -REMARKS: -Function to change the file attributes for a specific file. -****************************************************************************/ -void PMAPI PM_setFileAttr( - const char *filename, - uint attrib) -{ -#if defined(TNT) && defined(_MSC_VER) - DWORD attr = 0; - - if (attrib & PM_FILE_READONLY) - attr |= FILE_ATTRIBUTE_READONLY; - if (attrib & PM_FILE_ARCHIVE) - attr |= FILE_ATTRIBUTE_ARCHIVE; - if (attrib & PM_FILE_HIDDEN) - attr |= FILE_ATTRIBUTE_HIDDEN; - if (attrib & PM_FILE_SYSTEM) - attr |= FILE_ATTRIBUTE_SYSTEM; - SetFileAttributes((LPSTR)filename, attr); -#else - uint attr = 0; - - if (attrib & PM_FILE_READONLY) - attr |= _A_RDONLY; - if (attrib & PM_FILE_ARCHIVE) - attr |= _A_ARCH; - if (attrib & PM_FILE_HIDDEN) - attr |= _A_HIDDEN; - if (attrib & PM_FILE_SYSTEM) - attr |= _A_SYSTEM; - _dos_setfileattr(filename,attr); -#endif -} - -/**************************************************************************** -REMARKS: -Function to create a directory. -****************************************************************************/ -ibool PMAPI PM_mkdir( - const char *filename) -{ -#ifdef __GNUC__ - return mkdir(filename,S_IRUSR) == 0; -#else - return mkdir(filename) == 0; -#endif -} - -/**************************************************************************** -REMARKS: -Function to remove a directory. -****************************************************************************/ -ibool PMAPI PM_rmdir( - const char *filename) -{ - return rmdir(filename) == 0; -} - -/*-------------------------------------------------------------------------*/ -/* Generic DPMI routines common to 16/32 bit code */ -/*-------------------------------------------------------------------------*/ - -#ifndef REALMODE -ulong PMAPI DPMI_mapPhysicalToLinear(ulong physAddr,ulong limit) -{ - PMREGS r; - int i; - ulong baseAddr,baseOfs,roundedLimit; - - /* 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. - */ - if (physAddr < 0x100000L) - 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 - * DPMI 0.9 does not allow us to free physical memory mappings, and if - * the mappings get re-used in the program we want to avoid allocating - * more mappings than necessary. - */ - for (i = 0; i < numMaps; i++) { - 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 (i == numMaps) { - 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 - * will fail the calls unless this is the case. If we round the - * physical address, then we also add an extra offset into the address - * that we return. - */ - baseOfs = physAddr & 4095; - baseAddr = physAddr & ~4095; - roundedLimit = ((limit+baseOfs+1+4095) & ~4095)-1; - r.x.ax = 0x800; - r.x.bx = baseAddr >> 16; - r.x.cx = baseAddr & 0xFFFF; - r.x.si = roundedLimit >> 16; - r.x.di = roundedLimit & 0xFFFF; - PM_int386(0x31, &r, &r); - if (r.x.cflag) - return 0xFFFFFFFFUL; - maps[i].physical = physAddr; - maps[i].limit = limit; - maps[i].linear = ((ulong)r.x.bx << 16) + r.x.cx + baseOfs; - return maps[i].linear; -} - -int PMAPI DPMI_setSelectorBase(ushort sel,ulong linAddr) -{ - PMREGS r; - - r.x.ax = 7; /* DPMI set selector base address */ - r.x.bx = sel; - r.x.cx = linAddr >> 16; - r.x.dx = linAddr & 0xFFFF; - PM_int386(0x31, &r, &r); - if (r.x.cflag) - return 0; - return 1; -} - -ulong PMAPI DPMI_getSelectorBase(ushort sel) -{ - PMREGS r; - - r.x.ax = 6; /* DPMI get selector base address */ - r.x.bx = sel; - PM_int386(0x31, &r, &r); - return ((ulong)r.x.cx << 16) + r.x.dx; -} - -int PMAPI DPMI_setSelectorLimit(ushort sel,ulong limit) -{ - PMREGS r; - - r.x.ax = 8; /* DPMI set selector limit */ - r.x.bx = sel; - r.x.cx = limit >> 16; - r.x.dx = limit & 0xFFFF; - PM_int386(0x31, &r, &r); - if (r.x.cflag) - return 0; - return 1; -} - -uint PMAPI DPMI_createSelector(ulong base,ulong limit) -{ - uint sel; - PMREGS r; - - /* Allocate 1 descriptor */ - r.x.ax = 0; - r.x.cx = 1; - PM_int386(0x31, &r, &r); - if (r.x.cflag) return 0; - sel = r.x.ax; - - /* Set the descriptor access rights (for a 32 bit page granular - * segment). - */ - if (limit >= 0x10000L) { - 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; - if (!DPMI_setSelectorBase(sel,base)) - return 0; - if (!DPMI_setSelectorLimit(sel,limit)) - return 0; - return sel; -} - -void PMAPI DPMI_freeSelector(uint sel) -{ - PMREGS r; - - r.x.ax = 1; - r.x.bx = sel; - PM_int386(0x31, &r, &r); -} - -int PMAPI DPMI_lockLinearPages(ulong linear,ulong len) -{ - PMREGS r; - - r.x.ax = 0x600; /* DPMI Lock Linear Region */ - r.x.bx = (linear >> 16); /* Linear address in BX:CX */ - r.x.cx = (linear & 0xFFFF); - r.x.si = (len >> 16); /* Length in SI:DI */ - r.x.di = (len & 0xFFFF); - PM_int386(0x31, &r, &r); - return (!r.x.cflag); -} - -int PMAPI DPMI_unlockLinearPages(ulong linear,ulong len) -{ - PMREGS r; - - r.x.ax = 0x601; /* DPMI Unlock Linear Region */ - r.x.bx = (linear >> 16); /* Linear address in BX:CX */ - r.x.cx = (linear & 0xFFFF); - r.x.si = (len >> 16); /* Length in SI:DI */ - r.x.di = (len & 0xFFFF); - PM_int386(0x31, &r, &r); - return (!r.x.cflag); -} - -/**************************************************************************** -REMARKS: -Adjust the page table caching bits directly. Requires ring 0 access and -only works with DOS4GW and compatible extenders (CauseWay also works since -it has direct support for the ring 0 instructions we need from ring 3). Will -not work in a DOS box, but we call into the ring 0 helper VxD so we should -never get here in a DOS box anyway (assuming the VxD is present). If we -do get here and we are in windows, this code will be skipped. -****************************************************************************/ -static void PM_adjustPageTables( - ulong linear, - ulong limit, - ibool isCached) -{ -#ifdef DOS4GW - int startPDB,endPDB,iPDB,startPage,endPage,start,end,iPage; - ulong andMask,orMask,pageTable,*pPageTable; - - 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(); - } -#endif -} - -void * PMAPI DPMI_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) -{ - PMSREGS sregs; - ulong linAddr; - ulong DSBaseAddr; - - /* Get the base address for the default DS selector */ - 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; - } - - /* 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; - } - - /* Now expand the default DS selector to 4Gb so we can access it */ - if (!DPMI_setSelectorLimit(sregs.ds,0xFFFFFFFFUL)) - 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 - * caching enabled which hurts the performance of the linear framebuffer - * as it disables write combining on Pentium Pro and above processors. - * - * For those processors cache disabling is better handled through the - * MTRR registers anyway (we can write combine a region but disable - * caching) so that MMIO register regions do not screw up. - */ - if (DSBaseAddr == 0) - PM_adjustPageTables(linAddr,limit,isCached); - - /* Now return the base address of the memory into the default DS */ - return (void*)(linAddr - DSBaseAddr); -} - -#if defined(PM386) - -/* Some DOS extender implementations do not directly support calling a - * real mode procedure from protected mode. However we can simulate what - * we need temporarily hooking the INT 6Ah vector with a small real mode - * stub that will call our real mode code for us. - */ - -static uchar int6AHandler[] = { - 0x00,0x00,0x00,0x00, /* __PMODE_callReal variable */ - 0xFB, /* sti */ - 0x2E,0xFF,0x1E,0x00,0x00, /* call [cs:__PMODE_callReal] */ - 0xCF, /* iretf */ - }; -static uchar *crPtr = NULL; /* Pointer to of int 6A handler */ -static uint crRSeg,crROff; /* Real mode seg:offset of handler */ - -void PMAPI PM_callRealMode(uint seg,uint off, RMREGS *in, - RMSREGS *sregs) -{ - uchar *p; - 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)); - } - PM_setWord(crPtr,off); /* Plug in address to call */ - PM_setWord(crPtr+2,seg); - p = PM_mapRealPointer(0,0x6A * 4); - oldOff = PM_getWord(p); /* Save old handler address */ - oldSeg = PM_getWord(p+2); - PM_setWord(p,crROff+4); /* Hook 6A handler */ - PM_setWord(p+2,crRSeg); - PM_int86x(0x6A, in, in, sregs); /* Call real mode code */ - PM_setWord(p,oldOff); /* Restore old handler */ - PM_setWord(p+2,oldSeg); -} - -#endif /* PM386 */ - -#endif /* !REALMODE */ - -/**************************************************************************** -REMARKS: -Allocates a block of locked, physically contiguous memory. The memory -may be required to be below the 16Meg boundary. -****************************************************************************/ -void * PMAPI PM_allocLockedMem( - uint size, - ulong *physAddr, - ibool contiguous, - ibool below16Meg) -{ - uchar *p,*roundedP; - uint r_seg,r_off; - uint roundedSize = (size + 4 + 0xFFF) & ~0xFFF; - PM_lockHandle lh; /* Unused in DOS */ -#ifndef REALMODE - VXD_regs regs; - - /* If we have connected to our helper VxD in a Windows DOS box, use the - * 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; - } - - /* If the memory is not contiguous, we simply need to allocate it - * using regular memory allocation services, and lock it down - * in memory. - * - * For contiguous memory blocks, the only way to guarantee contiguous physical - * memory addresses under DOS is to allocate the memory below the - * 1Meg boundary as real mode memory. - * - * Note that we must page align the memory block, and we also must - * keep track of the non-aligned pointer so we can properly free - * it later. Hence we actually allocate 4 bytes more than the - * size rounded up to the next 4K boundary. - */ - if (!contiguous) - p = PM_malloc(roundedSize); - else -#endif - p = PM_allocRealSeg(roundedSize,&r_seg,&r_off); - if (p == 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; - } - - /* Disable caching for the memory since it is probably a DMA buffer */ -#ifndef REALMODE - PM_adjustPageTables((ulong)roundedP,size-1,false); -#endif - return roundedP; -} - -/**************************************************************************** -REMARKS: -Free a block of locked memory. -****************************************************************************/ -void PMAPI PM_freeLockedMem(void *p,uint size,ibool contiguous) -{ -#ifndef REALMODE - VXD_regs regs; - PM_lockHandle lh; /* Unused in DOS */ - - if (!p) - 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; - } - PM_unlockDataPages(p,size,&lh); - if (!contiguous) - free(*((void**)((uchar*)p + size))); - else -#endif - PM_freeRealSeg(*((void**)((char*)p + size))); -} - -#ifndef REALMODE -/**************************************************************************** -REMARKS: -Allocates a new block of pages for the page block manager. -****************************************************************************/ -static pageblock *PM_addNewPageBlock(void) -{ - int i,size; - pageblock *newBlock; - char *p,*next; - - /* 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; - newBlock->prev = NULL; - newBlock->next = pageBlocks; - if (pageBlocks) - pageBlocks->prev = newBlock; - pageBlocks = newBlock; - - /* Initialise the page aligned free list for the page block */ - newBlock->freeCount = PAGES_PER_BLOCK; - newBlock->freeList = p = (char*)(((ulong)(newBlock + 1) + (PM_PAGE_SIZE-1)) & ~(PM_PAGE_SIZE-1)); - 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 - PM_PAGE_SIZE) = NULL; - return newBlock; -} -#endif - -/**************************************************************************** -REMARKS: -Allocates a page aligned and page sized block of memory -****************************************************************************/ -void * PMAPI PM_allocPage( - ibool locked) -{ -#ifndef REALMODE - VXD_regs regs; - pageblock *block; - void *p; - PM_lockHandle lh; /* Unused in DOS */ - - /* 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; - } - - /* 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 == NULL && (block = PM_addNewPageBlock()) == NULL) - return NULL; - block->freeCount--; - p = block->freeList; - block->freeList = FREELIST_NEXT(p); - if (locked) - PM_lockDataPages(p,PM_PAGE_SIZE,&lh); - return p; -#else - return NULL; -#endif -} - -/**************************************************************************** -REMARKS: -Free a page aligned and page sized block of memory -****************************************************************************/ -void PMAPI PM_freePage( - void *p) -{ -#ifndef REALMODE - VXD_regs regs; - pageblock *block; - - /* 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; - } - - /* 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; - } - 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); - } -#else - (void)p; -#endif -} - -/*-------------------------------------------------------------------------*/ -/* DOS Real Mode support. */ -/*-------------------------------------------------------------------------*/ - -#ifdef REALMODE - -#ifndef MK_FP -#define MK_FP(s,o) ( (void far *)( ((ulong)(s) << 16) + \ - (ulong)(o) )) -#endif - -void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) -{ return MK_FP(r_seg,r_off); } - -void * PMAPI PM_getBIOSPointer(void) -{ - return MK_FP(0x40,0); -} - -void * PMAPI PM_getA0000Pointer(void) -{ - return MK_FP(0xA000,0); -} - -void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) -{ - uint sel = base >> 4; - uint off = base & 0xF; - limit = limit; - return MK_FP(sel,off); -} - -void PMAPI PM_freePhysicalAddr(void *ptr,ulong limit) -{ ptr = ptr; } - -ulong PMAPI PM_getPhysicalAddr(void *p) -{ - return ((((ulong)p >> 16) << 4) + (ushort)p); -} - -ibool PMAPI PM_getPhysicalAddrRange(void *p,ulong length,ulong *physAddress) -{ return false; } - -void * PMAPI PM_mapToProcess(void *base,ulong limit) -{ return (void*)base; } - -void * PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off) -{ - /* Call malloc() to allocate the memory for us */ - void *p = PM_malloc(size); - *r_seg = FP_SEG(p); - *r_off = FP_OFF(p); - return p; -} - -void PMAPI PM_freeRealSeg(void *mem) -{ - if (mem) PM_free(mem); -} - -int PMAPI PM_int86(int intno, RMREGS *in, RMREGS *out) -{ - return PM_int386(intno,in,out); -} - -int PMAPI PM_int86x(int intno, RMREGS *in, RMREGS *out, - RMSREGS *sregs) -{ - return PM_int386x(intno,in,out,sregs); -} - -void PMAPI PM_availableMemory(ulong *physical,ulong *total) -{ - PMREGS regs; - - regs.h.ah = 0x48; - regs.x.bx = 0xFFFF; - PM_int86(0x21,®s,®s); - *physical = *total = regs.x.bx * 16UL; -} - -#endif - -/*-------------------------------------------------------------------------*/ -/* Phar Lap TNT DOS Extender support. */ -/*-------------------------------------------------------------------------*/ - -#ifdef TNT - -#include -#include -#include - -static uchar *zeroPtr = NULL; - -void * PMAPI PM_getBIOSPointer(void) -{ - if (!zeroPtr) - zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF,true); - return (void*)(zeroPtr + 0x400); -} - -void * PMAPI PM_getA0000Pointer(void) -{ - static void *bankPtr; - if (!bankPtr) - bankPtr = PM_mapPhysicalAddr(0xA0000,0xFFFF,true); - return bankPtr; -} - -void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) -{ - CONFIG_INF config; - ULONG offset; - int err; - ulong baseAddr,baseOfs,newLimit; - VXD_regs regs; - - /* If we have connected to our helper VxD in a Windows DOS box, use - * the helper VxD services to map memory instead of the DPMI services. - * We do this because the helper VxD can properly disable caching - * where necessary, which we can only do directly here if we are - * running at ring 0 (ie: under real DOS). - */ - if (VXD_version == -1) - 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; - } - - /* 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 - * physical address, then we also add an extra offset into the address - * that we return. - */ - baseOfs = base & 4095; - baseAddr = base & ~4095; - newLimit = ((limit+baseOfs+1+4095) & ~4095)-1; - _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 (err == 0) - return (void*)(offset + baseOfs); - return NULL; -} - -void PMAPI PM_freePhysicalAddr(void *ptr,ulong limit) -{ -} - -ulong PMAPI PM_getPhysicalAddr(void *p) -{ return 0xFFFFFFFFUL; } - -ibool PMAPI PM_getPhysicalAddrRange(void *p,ulong length,ulong *physAddress) -{ return false; } - -void * PMAPI PM_mapToProcess(void *base,ulong limit) -{ return (void*)base; } - -void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) -{ - if (!zeroPtr) - zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF); - return (void*)(zeroPtr + MK_PHYS(r_seg,r_off)); -} - -void * PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off) -{ - USHORT addr,t; - void *p; - - if (_dx_real_alloc((size + 0xF) >> 4,&addr,&t) != 0) - return 0; - *r_seg = addr; /* Real mode segment address */ - *r_off = 0; /* Real mode segment offset */ - p = PM_mapRealPointer(*r_seg,*r_off); - _PM_addRealModeBlock(p,addr); - return p; -} - -void PMAPI PM_freeRealSeg(void *mem) -{ - if (mem) _dx_real_free(_PM_findRealModeBlock(mem)); -} - -#define INDPMI(reg) rmregs.reg = regs->reg -#define OUTDPMI(reg) regs->reg = rmregs.reg - -void PMAPI DPMI_int86(int intno, DPMI_regs *regs) -{ - SWI_REGS rmregs; - - memset(&rmregs, 0, sizeof(rmregs)); - INDPMI(eax); INDPMI(ebx); INDPMI(ecx); INDPMI(edx); INDPMI(esi); INDPMI(edi); - - _dx_real_int(intno,&rmregs); - - OUTDPMI(eax); OUTDPMI(ebx); OUTDPMI(ecx); OUTDPMI(edx); OUTDPMI(esi); OUTDPMI(edi); - regs->flags = rmregs.flags; -} - -#define IN(reg) rmregs.reg = in->e.reg -#define OUT(reg) out->e.reg = rmregs.reg - -int PMAPI PM_int86(int intno, RMREGS *in, RMREGS *out) -{ - SWI_REGS rmregs; - - memset(&rmregs, 0, sizeof(rmregs)); - IN(eax); IN(ebx); IN(ecx); IN(edx); IN(esi); IN(edi); - - _dx_real_int(intno,&rmregs); - - OUT(eax); OUT(ebx); OUT(ecx); OUT(edx); OUT(esi); OUT(edi); - out->x.cflag = rmregs.flags & 0x1; - return out->x.ax; -} - -int PMAPI PM_int86x(int intno, RMREGS *in, RMREGS *out, - RMSREGS *sregs) -{ - SWI_REGS rmregs; - - memset(&rmregs, 0, sizeof(rmregs)); - IN(eax); IN(ebx); IN(ecx); IN(edx); IN(esi); IN(edi); - rmregs.es = sregs->es; - rmregs.ds = sregs->ds; - - _dx_real_int(intno,&rmregs); - - OUT(eax); OUT(ebx); OUT(ecx); OUT(edx); OUT(esi); OUT(edi); - sregs->es = rmregs.es; - sregs->cs = rmregs.cs; - sregs->ss = rmregs.ss; - sregs->ds = rmregs.ds; - out->x.cflag = rmregs.flags & 0x1; - return out->x.ax; -} - -void PMAPI PM_availableMemory(ulong *physical,ulong *total) -{ - PMREGS r; - uint data[25]; - - r.x.ax = 0x2520; /* Get free memory info */ - r.x.bx = 0; - r.e.edx = (uint)data; - PM_int386(0x21, &r, &r); - *physical = data[21] * 4096; - *total = data[23] * 4096; -} - -#endif - -/*-------------------------------------------------------------------------*/ -/* Symantec C++ DOSX and FlashTek X-32/X-32VM support */ -/*-------------------------------------------------------------------------*/ - -#if defined(DOSX) || defined(X32VM) - -#ifdef X32VM -#include - -#define _x386_mk_protected_ptr(p) _x32_mk_protected_ptr((void*)p) -#define _x386_free_protected_ptr(p) _x32_free_protected_ptr(p) -#define _x386_zero_base_ptr _x32_zero_base_ptr -#else -extern void *_x386_zero_base_ptr; -#endif - -void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) -{ - return (void*)((ulong)_x386_zero_base_ptr + MK_PHYS(r_seg,r_off)); -} - -void * PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off) -{ - PMREGS r; - - r.h.ah = 0x48; /* DOS function 48h - allocate mem */ - 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 */ - *r_seg = r.e.eax; - *r_off = 0; - return PM_mapRealPointer(*r_seg,*r_off); -} - -void PMAPI PM_freeRealSeg(void *mem) -{ - /* Cannot de-allocate this memory */ - mem = mem; -} - -#pragma pack(1) - -typedef struct { - ushort intno; - ushort ds; - ushort es; - ushort fs; - ushort gs; - ulong eax; - ulong edx; - } _RMREGS; - -#pragma pack() - -#define IN(reg) regs.e.reg = in->e.reg -#define OUT(reg) out->e.reg = regs.e.reg - -int PMAPI PM_int86(int intno, RMREGS *in, RMREGS *out) -{ - _RMREGS rmregs; - PMREGS regs; - PMSREGS pmsregs; - - rmregs.intno = intno; - rmregs.eax = in->e.eax; - rmregs.edx = in->e.edx; - IN(ebx); IN(ecx); IN(esi); IN(edi); - regs.x.ax = 0x2511; - regs.e.edx = (uint)(&rmregs); - PM_segread(&pmsregs); - PM_int386x(0x21,®s,®s,&pmsregs); - - OUT(eax); OUT(ebx); OUT(ecx); OUT(esi); OUT(edi); - out->x.dx = rmregs.edx; - out->x.cflag = regs.x.cflag; - return out->x.ax; -} - -int PMAPI PM_int86x(int intno, RMREGS *in, RMREGS *out, RMSREGS *sregs) -{ - _RMREGS rmregs; - PMREGS regs; - PMSREGS pmsregs; - - rmregs.intno = intno; - rmregs.eax = in->e.eax; - rmregs.edx = in->e.edx; - rmregs.es = sregs->es; - rmregs.ds = sregs->ds; - IN(ebx); IN(ecx); IN(esi); IN(edi); - regs.x.ax = 0x2511; - regs.e.edx = (uint)(&rmregs); - PM_segread(&pmsregs); - PM_int386x(0x21,®s,®s,&pmsregs); - - OUT(eax); OUT(ebx); OUT(ecx); OUT(esi); OUT(edi); - sregs->es = rmregs.es; - sregs->ds = rmregs.ds; - out->x.dx = rmregs.edx; - out->x.cflag = regs.x.cflag; - return out->x.ax; -} - -void * PMAPI PM_getBIOSPointer(void) -{ - return (void*)((ulong)_x386_zero_base_ptr + 0x400); -} - -void * PMAPI PM_getA0000Pointer(void) -{ - return (void*)((ulong)_x386_zero_base_ptr + 0xA0000); -} - -void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) -{ - VXD_regs regs; - - /* If we have connected to our helper VxD in a Windows DOS box, use - * the helper VxD services to map memory instead of the DPMI services. - * We do this because the helper VxD can properly disable caching - * where necessary, which we can only do directly here if we are - * running at ring 0 (ie: under real DOS). - */ - if (VXD_version == -1) - 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; - } - - if (base > 0x100000) - return _x386_map_physical_address((void*)base,limit); - return (void*)((ulong)_x386_zero_base_ptr + base); -} - -void PMAPI PM_freePhysicalAddr(void *ptr,ulong limit) -{ - /* Mapping cannot be freed */ -} - -ulong PMAPI PM_getPhysicalAddr(void *p) -{ return 0xFFFFFFFFUL; } - -ibool PMAPI PM_getPhysicalAddrRange(void *p,ulong length,ulong *physAddress) -{ return false; } - -void * PMAPI PM_mapToProcess(void *base,ulong limit) -{ return (void*)base; } - -ulong _cdecl _X32_getPhysMem(void); - -void PMAPI PM_availableMemory(ulong *physical,ulong *total) -{ - PMREGS regs; - - /* Get total memory available, including virtual memory */ - regs.x.ax = 0x350B; - PM_int386(0x21,®s,®s); - *total = regs.e.eax; - - /* Get physical memory available */ - *physical = _X32_getPhysMem(); - if (*physical > *total) - *physical = *total; -} - -#endif - -/*-------------------------------------------------------------------------*/ -/* Borland's DPMI32, Watcom DOS4GW and DJGPP DPMI support routines */ -/*-------------------------------------------------------------------------*/ - -#if defined(DPMI32) || defined(DOS4GW) || defined(DJGPP) - -void * PMAPI PM_getBIOSPointer(void) -{ - return PM_mapPhysicalAddr(0x400,0xFFFF,true); -} - -void * PMAPI PM_getA0000Pointer(void) -{ - return PM_mapPhysicalAddr(0xA0000,0xFFFF,true); -} - -void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) -{ - VXD_regs regs; - -#ifdef DJGPP - /* Enable near pointers for DJGPP V2 */ - __djgpp_nearptr_enable(); -#endif - /* If we have connected to our helper VxD in a Windows DOS box, use - * the helper VxD services to map memory instead of the DPMI services. - * We do this because the helper VxD can properly disable caching - * where necessary, which we can only do directly here if we are - * running at ring 0 (ie: under real DOS). - */ - if (VXD_version == -1) - 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; - } - return DPMI_mapPhysicalAddr(base,limit,isCached); -} - -void PMAPI PM_freePhysicalAddr(void *ptr,ulong limit) -{ - /* Mapping cannot be freed */ - (void)ptr; - (void)limit; -} - -ulong PMAPI PM_getPhysicalAddr(void *p) -{ - ulong physAddr; - if (!PM_getPhysicalAddrRange(p,1,&physAddr)) - return 0xFFFFFFFF; - return physAddr | ((ulong)p & 0xFFF); -} - -ibool PMAPI PM_getPhysicalAddrRange( - void *p, - ulong length, - ulong *physAddress) -{ - VXD_regs regs; - ulong pte; - PMSREGS sregs; - ulong DSBaseAddr; - - /* If we have connected to our helper VxD in a Windows DOS box, use the - * 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; - } - - /* Find base address for default DS selector */ - PM_segread(&sregs); - DSBaseAddr = DPMI_getSelectorBase(sregs.ds); - - /* Otherwise directly access the page tables to determine the - * physical memory address. Note that we touch the memory before - * calling, otherwise the memory may not be paged in correctly. - */ - 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; - } - 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; - } - } -#endif - return false; -} - -void * PMAPI PM_mapToProcess(void *base,ulong limit) -{ - (void)limit; - return (void*)base; -} - -void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) -{ - static uchar *zeroPtr = NULL; - - if (!zeroPtr) - zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF,true); - return (void*)(zeroPtr + MK_PHYS(r_seg,r_off)); -} - -void * PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off) -{ - PMREGS r; - void *p; - - r.x.ax = 0x100; /* DPMI allocate DOS memory */ - r.x.bx = (size + 0xF) >> 4; /* number of paragraphs */ - PM_int386(0x31, &r, &r); - if (r.x.cflag) - return NULL; /* DPMI call failed */ - *r_seg = r.x.ax; /* Real mode segment */ - *r_off = 0; - p = PM_mapRealPointer(*r_seg,*r_off); - _PM_addRealModeBlock(p,r.x.dx); - return p; -} - -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); - } -} - -static DPMI_handler_t DPMI_int10 = NULL; - -void PMAPI DPMI_setInt10Handler(DPMI_handler_t handler) -{ - DPMI_int10 = handler; -} - -void PMAPI DPMI_int86(int intno, DPMI_regs *regs) -{ - PMREGS r; - PMSREGS sr; - - if (intno == 0x10 && DPMI_int10) { - if (DPMI_int10(regs)) - return; - } - PM_segread(&sr); - r.x.ax = 0x300; /* DPMI issue real interrupt */ - r.h.bl = intno; - r.h.bh = 0; - r.x.cx = 0; - sr.es = sr.ds; - r.e.edi = (uint)regs; - PM_int386x(0x31, &r, &r, &sr); /* Issue the interrupt */ -} - -#define IN(reg) rmregs.reg = in->e.reg -#define OUT(reg) out->e.reg = rmregs.reg - -int PMAPI PM_int86(int intno, RMREGS *in, RMREGS *out) -{ - DPMI_regs rmregs; - - memset(&rmregs, 0, sizeof(rmregs)); - IN(eax); IN(ebx); IN(ecx); IN(edx); IN(esi); IN(edi); - - 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; - return out->x.ax; -} - -int PMAPI PM_int86x(int intno, RMREGS *in, RMREGS *out, - RMSREGS *sregs) -{ - DPMI_regs rmregs; - - memset(&rmregs, 0, sizeof(rmregs)); - IN(eax); IN(ebx); IN(ecx); IN(edx); IN(esi); IN(edi); - rmregs.es = sregs->es; - rmregs.ds = sregs->ds; - - DPMI_int86(intno,&rmregs); /* DPMI issue real interrupt */ - - OUT(eax); OUT(ebx); OUT(ecx); OUT(edx); OUT(esi); OUT(edi); - sregs->es = rmregs.es; - sregs->cs = rmregs.cs; - sregs->ss = rmregs.ss; - sregs->ds = rmregs.ds; - out->x.cflag = rmregs.flags & 0x1; - return out->x.ax; -} - -#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; - -#pragma pack() - -void PMAPI PM_availableMemory(ulong *physical,ulong *total) -{ - PMREGS r; - PMSREGS sr; - MemInfo memInfo; - - PM_segread(&sr); - r.x.ax = 0x500; /* DPMI get free memory info */ - sr.es = sr.ds; - r.e.edi = (uint)&memInfo; - PM_int386x(0x31, &r, &r, &sr); /* Issue the interrupt */ - *physical = memInfo.NumPhysicalPagesFree * 4096; - *total = memInfo.LargestBlockAvail; - if (*total < *physical) - *physical = *total; -} - -#endif - -#ifndef __16BIT__ - -/**************************************************************************** -REMARKS: -Call the VBE/Core software interrupt to change display banks. -****************************************************************************/ -void PMAPI PM_setBankA( - int bank) -{ - DPMI_regs regs; - memset(®s, 0, sizeof(regs)); - regs.eax = 0x4F05; - regs.ebx = 0x0000; - regs.edx = bank; - DPMI_int86(0x10,®s); -} - -/**************************************************************************** -REMARKS: -Call the VBE/Core software interrupt to change display banks. -****************************************************************************/ -void PMAPI PM_setBankAB( - int bank) -{ - DPMI_regs regs; - memset(®s, 0, sizeof(regs)); - regs.eax = 0x4F05; - regs.ebx = 0x0000; - regs.edx = bank; - DPMI_int86(0x10,®s); - regs.eax = 0x4F05; - regs.ebx = 0x0001; - regs.edx = bank; - DPMI_int86(0x10,®s); -} - -/**************************************************************************** -REMARKS: -Call the VBE/Core software interrupt to change display start address. -****************************************************************************/ -void PMAPI PM_setCRTStart( - int x, - int y, - int waitVRT) -{ - DPMI_regs regs; - memset(®s, 0, sizeof(regs)); - regs.eax = 0x4F07; - regs.ebx = waitVRT; - regs.ecx = x; - regs.edx = y; - DPMI_int86(0x10,®s); -} - -#endif - -/**************************************************************************** -REMARKS: -Function to get the file attributes for a specific file. -****************************************************************************/ -uint PMAPI PM_getFileAttr( - const char *filename) -{ - /* TODO: Implement this! */ - return 0; -} - -/**************************************************************************** -REMARKS: -Function to get the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_getFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - /* TODO: Implement this! */ - return false; -} - -/**************************************************************************** -REMARKS: -Function to set the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_setFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - /* 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 deleted file mode 100644 index eecc2daede..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/pmdos.c +++ /dev/null @@ -1,1637 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 16/32 bit DOS -* -* Description: Implementation for the OS Portability Manager Library, which -* contains functions to implement OS specific services in a -* generic, cross platform API. Porting the OS Portability -* Manager library is the first step to porting any SciTech -* products to a new platform. -* -****************************************************************************/ - -#include "pmapi.h" -#include -#include -#include -#include - -/*--------------------------- Global variables ----------------------------*/ - -#ifndef REALMODE -static int globalDataStart; -#endif - -PM_criticalHandler _VARAPI _PM_critHandler = NULL; -PM_breakHandler _VARAPI _PM_breakHandler = NULL; -PM_intHandler _VARAPI _PM_timerHandler = NULL; -PM_intHandler _VARAPI _PM_rtcHandler = NULL; -PM_intHandler _VARAPI _PM_keyHandler = NULL; -PM_key15Handler _VARAPI _PM_key15Handler = NULL; -PM_mouseHandler _VARAPI _PM_mouseHandler = NULL; -PM_intHandler _VARAPI _PM_int10Handler = NULL; -int _VARAPI _PM_mouseMask; - -uchar * _VARAPI _PM_ctrlCPtr; /* Location of Ctrl-C flag */ -uchar * _VARAPI _PM_ctrlBPtr; /* Location of Ctrl-Break flag */ -uchar * _VARAPI _PM_critPtr; /* Location of Critical error Bf*/ -PMFARPTR _VARAPI _PM_prevTimer = PMNULL; /* Previous timer handler */ -PMFARPTR _VARAPI _PM_prevRTC = PMNULL; /* Previous RTC handler */ -PMFARPTR _VARAPI _PM_prevKey = PMNULL; /* Previous key handler */ -PMFARPTR _VARAPI _PM_prevKey15 = PMNULL; /* Previous key15 handler */ -PMFARPTR _VARAPI _PM_prevBreak = PMNULL; /* Previous break handler */ -PMFARPTR _VARAPI _PM_prevCtrlC = PMNULL; /* Previous CtrlC handler */ -PMFARPTR _VARAPI _PM_prevCritical = PMNULL; /* Previous critical handler */ -long _VARAPI _PM_prevRealTimer; /* Previous real mode timer */ -long _VARAPI _PM_prevRealRTC; /* Previous real mode RTC */ -long _VARAPI _PM_prevRealKey; /* Previous real mode key */ -long _VARAPI _PM_prevRealKey15; /* Previous real mode key15 */ -long _VARAPI _PM_prevRealInt10; /* Previous real mode int 10h */ -static uchar _PM_oldCMOSRegA; /* CMOS register A contents */ -static uchar _PM_oldCMOSRegB; /* CMOS register B contents */ -static uchar _PM_oldRTCPIC2; /* Mask value for RTC IRQ8 */ - -/* Structure to maintain information about hardware interrupt handlers, - * include a copy of the hardware IRQ assembler thunk (one for each - * hooked interrupt handler). - */ - -typedef struct { - uchar IRQ; - uchar IRQVect; - uchar prevPIC; - uchar prevPIC2; - PMFARPTR prevHandler; - long prevRealhandler; - uchar thunk[1]; - /* IRQ assembler thunk follows ... */ - } _PM_IRQHandle; - -/*----------------------------- Implementation ----------------------------*/ - -/* Globals for locking interrupt handlers in _pmdos.asm */ - -#ifndef REALMODE -extern int _VARAPI _PM_pmdosDataStart; -extern int _VARAPI _PM_pmdosDataEnd; -extern int _VARAPI _PM_DMADataStart; -extern int _VARAPI _PM_DMADataEnd; -void _ASMAPI _PM_pmdosCodeStart(void); -void _ASMAPI _PM_pmdosCodeEnd(void); -void _ASMAPI _PM_DMACodeStart(void); -void _ASMAPI _PM_DMACodeEnd(void); -#endif - -/* Protected mode interrupt handlers, also called by PM callbacks below */ - -void _ASMAPI _PM_timerISR(void); -void _ASMAPI _PM_rtcISR(void); -void _ASMAPI _PM_irqISRTemplate(void); -void _ASMAPI _PM_irqISRTemplateEnd(void); -void _ASMAPI _PM_keyISR(void); -void _ASMAPI _PM_key15ISR(void); -void _ASMAPI _PM_breakISR(void); -void _ASMAPI _PM_ctrlCISR(void); -void _ASMAPI _PM_criticalISR(void); -void _ASMAPI _PM_mouseISR(void); -void _ASMAPI _PM_int10PMCB(void); - -/* Protected mode DPMI callback handlers */ - -void _ASMAPI _PM_mousePMCB(void); - -/* Routine to install a mouse handler function */ - -void _ASMAPI _PM_setMouseHandler(int mask); - -/* Routine to allocate DPMI real mode callback routines */ - -ibool _ASMAPI _DPMI_allocateCallback(void (_ASMAPI *pmcode)(),void *rmregs,long *RMCB); -void _ASMAPI _DPMI_freeCallback(long RMCB); - -/* DPMI helper functions in PMLITE.C */ - -ulong PMAPI DPMI_mapPhysicalToLinear(ulong physAddr,ulong limit); -int PMAPI DPMI_setSelectorBase(ushort sel,ulong linAddr); -ulong PMAPI DPMI_getSelectorBase(ushort sel); -int PMAPI DPMI_setSelectorLimit(ushort sel,ulong limit); -uint PMAPI DPMI_createSelector(ulong base,ulong limit); -void PMAPI DPMI_freeSelector(uint sel); -int PMAPI DPMI_lockLinearPages(ulong linear,ulong len); -int PMAPI DPMI_unlockLinearPages(ulong linear,ulong len); - -/* Functions to read and write CMOS registers */ - -uchar PMAPI _PM_readCMOS(int index); -void PMAPI _PM_writeCMOS(int index,uchar value); - -/*-------------------------------------------------------------------------*/ -/* Generic routines common to all environments */ -/*-------------------------------------------------------------------------*/ - -void PMAPI PM_resetMouseDriver(int hardReset) -{ - RMREGS regs; - PM_mouseHandler oldHandler = _PM_mouseHandler; - - PM_restoreMouseHandler(); - regs.x.ax = hardReset ? 0 : 33; - PM_int86(0x33, ®s, ®s); - if (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, - }; - 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); - } - 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,0x20 | (i+3)); - _PM_writeCMOS(0x0B,(_PM_oldCMOSRegB & 0x0F) | 0x40); - } -} - -#ifndef REALMODE - -static void PMAPI lockPMHandlers(void) -{ - static int locked = 0; - int stat; - PM_lockHandle lh; /* Unused in DOS */ - - /* 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_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 - -/*-------------------------------------------------------------------------*/ -/* DOS Real Mode support. */ -/*-------------------------------------------------------------------------*/ - -#ifdef REALMODE - -#ifndef MK_FP -#define MK_FP(s,o) ( (void far *)( ((ulong)(s) << 16) + \ - (ulong)(o) )) -#endif - -int PMAPI PM_setMouseHandler(int mask, PM_mouseHandler mh) -{ - PM_saveDS(); - _PM_mouseHandler = mh; - _PM_setMouseHandler(_PM_mouseMask = mask); - return 1; -} - -void PMAPI PM_restoreMouseHandler(void) -{ - union REGS regs; - - if (_PM_mouseHandler) { - regs.x.ax = 33; - int86(0x33, ®s, ®s); - _PM_mouseHandler = NULL; - } -} - -void PMAPI PM_setTimerHandler(PM_intHandler th) -{ - _PM_getRMvect(0x8, (long*)&_PM_prevTimer); - _PM_timerHandler = th; - _PM_setRMvect(0x8, (long)_PM_timerISR); -} - -void PMAPI PM_restoreTimerHandler(void) -{ - if (_PM_timerHandler) { - _PM_setRMvect(0x8, (long)_PM_prevTimer); - _PM_timerHandler = NULL; - } -} - -ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler th,int frequency) -{ - /* Save the old CMOS real time clock values */ - _PM_oldCMOSRegA = _PM_readCMOS(0x0A); - _PM_oldCMOSRegB = _PM_readCMOS(0x0B); - - /* Set the real time clock interrupt handler */ - _PM_getRMvect(0x70, (long*)&_PM_prevRTC); - _PM_rtcHandler = th; - _PM_setRMvect(0x70, (long)_PM_rtcISR); - - /* Program the real time clock default frequency */ - PM_setRealTimeClockFrequency(frequency); - - /* Unmask IRQ8 in the PIC2 */ - _PM_oldRTCPIC2 = PM_inpb(0xA1); - PM_outpb(0xA1,_PM_oldRTCPIC2 & 0xFE); - return true; -} - -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 */ - _PM_setRMvect(0x70, (long)_PM_prevRTC); - _PM_rtcHandler = NULL; - } -} - -void PMAPI PM_setKeyHandler(PM_intHandler kh) -{ - _PM_getRMvect(0x9, (long*)&_PM_prevKey); - _PM_keyHandler = kh; - _PM_setRMvect(0x9, (long)_PM_keyISR); -} - -void PMAPI PM_restoreKeyHandler(void) -{ - if (_PM_keyHandler) { - _PM_setRMvect(0x9, (long)_PM_prevKey); - _PM_keyHandler = NULL; - } -} - -void PMAPI PM_setKey15Handler(PM_key15Handler kh) -{ - _PM_getRMvect(0x15, (long*)&_PM_prevKey15); - _PM_key15Handler = kh; - _PM_setRMvect(0x15, (long)_PM_key15ISR); -} - -void PMAPI PM_restoreKey15Handler(void) -{ - if (_PM_key15Handler) { - _PM_setRMvect(0x15, (long)_PM_prevKey15); - _PM_key15Handler = NULL; - } -} - -void PMAPI PM_installAltBreakHandler(PM_breakHandler bh) -{ - static int ctrlCFlag,ctrlBFlag; - - _PM_ctrlCPtr = (uchar*)&ctrlCFlag; - _PM_ctrlBPtr = (uchar*)&ctrlBFlag; - _PM_getRMvect(0x1B, (long*)&_PM_prevBreak); - _PM_getRMvect(0x23, (long*)&_PM_prevCtrlC); - _PM_breakHandler = bh; - _PM_setRMvect(0x1B, (long)_PM_breakISR); - _PM_setRMvect(0x23, (long)_PM_ctrlCISR); -} - -void PMAPI PM_installBreakHandler(void) -{ - PM_installAltBreakHandler(NULL); -} - -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; - } -} - -void PMAPI PM_installAltCriticalHandler(PM_criticalHandler ch) -{ - static short critBuf[2]; - - _PM_critPtr = (uchar*)critBuf; - _PM_getRMvect(0x24, (long*)&_PM_prevCritical); - _PM_critHandler = ch; - _PM_setRMvect(0x24, (long)_PM_criticalISR); -} - -void PMAPI PM_installCriticalHandler(void) -{ - PM_installAltCriticalHandler(NULL); -} - -void PMAPI PM_restoreCriticalHandler(void) -{ - if (_PM_prevCritical) { - _PM_setRMvect(0x24, (long)_PM_prevCritical); - _PM_prevCritical = NULL; - _PM_critHandler = NULL; - } -} - -int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - p = p; len = len; /* Do nothing for real mode */ - return 1; -} - -int PMAPI PM_unlockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - p = p; len = len; /* Do nothing for real mode */ - return 1; -} - -int PMAPI PM_lockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - p = p; len = len; /* Do nothing for real mode */ - return 1; -} - -int PMAPI PM_unlockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - p = p; len = len; /* Do nothing for real mode */ - return 1; -} - -void PMAPI PM_getPMvect(int intno, PMFARPTR *isr) -{ - long t; - _PM_getRMvect(intno,&t); - *isr = (void*)t; -} - -void PMAPI PM_setPMvect(int intno, PM_intHandler isr) -{ - PM_saveDS(); - _PM_setRMvect(intno,(long)isr); -} - -void PMAPI PM_restorePMvect(int intno, PMFARPTR isr) -{ - _PM_setRMvect(intno,(long)isr); -} - -#endif - -/*-------------------------------------------------------------------------*/ -/* Phar Lap TNT DOS Extender support. */ -/*-------------------------------------------------------------------------*/ - -#ifdef TNT - -#include -#include -#include - -static long prevRealBreak; /* Previous real mode break handler */ -static long prevRealCtrlC; /* Previous real mode CtrlC handler */ -static long prevRealCritical; /* Prev real mode critical handler */ -static uchar *mousePtr; - -/* The following real mode routine is used to call a 32 bit protected - * mode FAR function from real mode. We use this for passing up control - * from the real mode mouse callback to our protected mode code. - */ - -static UCHAR realHandler[] = { /* Real mode code generic handler */ - 0x00,0x00,0x00,0x00, /* __PM_callProtp */ - 0x00,0x00, /* __PM_protCS */ - 0x00,0x00,0x00,0x00, /* __PM_protHandler */ - 0x66,0x60, /* pushad */ - 0x1E, /* push ds */ - 0x6A,0x00, /* push 0 */ - 0x6A,0x00, /* push 0 */ - 0x2E,0xFF,0x36,0x04,0x00, /* push [cs:__PM_protCS] */ - 0x66,0x2E,0xFF,0x36,0x06,0x00, /* push [cs:__PM_protHandler] */ - 0x2E,0xFF,0x1E,0x00,0x00, /* call [cs:__PM_callProtp] */ - 0x83,0xC4,0x0A, /* add sp,10 */ - 0x1F, /* pop ds */ - 0x66,0x61, /* popad */ - 0xCB, /* retf */ - }; - -/* The following functions installs the above realmode callback mechanism - * in real mode memory for calling the protected mode routine. - */ - -uchar * installCallback(void (PMAPI *pmCB)(),uint *rseg, uint *roff) -{ - CONFIG_INF config; - REALPTR realBufAdr,callProtp; - ULONG bufSize; - FARPTR protBufAdr; - uchar *p; - - /* Get address of real mode routine to call up to protected mode */ - _dx_rmlink_get(&callProtp, &realBufAdr, &bufSize, &protBufAdr); - _dx_config_inf(&config, (UCHAR*)&config); - - /* Fill in the values in the real mode code segment so that it will - * call the correct routine. - */ - *((REALPTR*)&realHandler[0]) = callProtp; - *((USHORT*)&realHandler[4]) = config.c_cs_sel; - *((ULONG*)&realHandler[6]) = (ULONG)pmCB; - - /* Copy the real mode handler to real mode memory */ - if ((p = PM_allocRealSeg(sizeof(realHandler),rseg,roff)) == NULL) - return NULL; - memcpy(p,realHandler,sizeof(realHandler)); - - /* Skip past global variabls in real mode code segment */ - *roff += 0x0A; - return p; -} - -int PMAPI PM_setMouseHandler(int mask, PM_mouseHandler mh) -{ - RMREGS regs; - RMSREGS sregs; - uint rseg,roff; - - lockPMHandlers(); /* Ensure our handlers are locked */ - - if ((mousePtr = installCallback(_PM_mouseISR, &rseg, &roff)) == NULL) - return 0; - _PM_mouseHandler = mh; - - /* Install the real mode mouse handler */ - sregs.es = rseg; - regs.x.dx = roff; - regs.x.cx = _PM_mouseMask = mask; - regs.x.ax = 0xC; - PM_int86x(0x33, ®s, ®s, &sregs); - return 1; -} - -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; - } -} - -void PMAPI PM_getPMvect(int intno, PMFARPTR *isr) -{ - FARPTR ph; - - _dx_pmiv_get(intno, &ph); - isr->sel = FP_SEL(ph); - isr->off = FP_OFF(ph); -} - -void PMAPI PM_setPMvect(int intno, PM_intHandler isr) -{ - CONFIG_INF config; - FARPTR ph; - - PM_saveDS(); - _dx_config_inf(&config, (UCHAR*)&config); - FP_SET(ph,(uint)isr,config.c_cs_sel); - _dx_pmiv_set(intno,ph); -} - -void PMAPI PM_restorePMvect(int intno, PMFARPTR isr) -{ - FARPTR ph; - - FP_SET(ph,isr.off,isr.sel); - _dx_pmiv_set(intno,ph); -} - -static void getISR(int intno, PMFARPTR *pmisr, long *realisr) -{ - PM_getPMvect(intno,pmisr); - _PM_getRMvect(intno, realisr); -} - -static void restoreISR(int intno, PMFARPTR pmisr, long realisr) -{ - _PM_setRMvect(intno,realisr); - PM_restorePMvect(intno,pmisr); -} - -static void setISR(int intno, void (PMAPI *isr)()) -{ - CONFIG_INF config; - FARPTR ph; - - lockPMHandlers(); /* Ensure our handlers are locked */ - - _dx_config_inf(&config, (UCHAR*)&config); - FP_SET(ph,(uint)isr,config.c_cs_sel); - _dx_apmiv_set(intno,ph); -} - -void PMAPI PM_setTimerHandler(PM_intHandler th) -{ - getISR(0x8, &_PM_prevTimer, &_PM_prevRealTimer); - _PM_timerHandler = th; - setISR(0x8, _PM_timerISR); -} - -void PMAPI PM_restoreTimerHandler(void) -{ - if (_PM_timerHandler) { - restoreISR(0x8, _PM_prevTimer, _PM_prevRealTimer); - _PM_timerHandler = NULL; - } -} - -ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler th,int frequency) -{ - /* Save the old CMOS real time clock values */ - _PM_oldCMOSRegA = _PM_readCMOS(0x0A); - _PM_oldCMOSRegB = _PM_readCMOS(0x0B); - - /* Set the real time clock interrupt handler */ - getISR(0x70, &_PM_prevRTC, &_PM_prevRealRTC); - _PM_rtcHandler = th; - setISR(0x70, _PM_rtcISR); - - /* Program the real time clock default frequency */ - PM_setRealTimeClockFrequency(frequency); - - /* Unmask IRQ8 in the PIC2 */ - _PM_oldRTCPIC2 = PM_inpb(0xA1); - PM_outpb(0xA1,_PM_oldRTCPIC2 & 0xFE); - return true; -} - -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; - } -} - -void PMAPI PM_setKeyHandler(PM_intHandler kh) -{ - getISR(0x9, &_PM_prevKey, &_PM_prevRealKey); - _PM_keyHandler = kh; - setISR(0x9, _PM_keyISR); -} - -void PMAPI PM_restoreKeyHandler(void) -{ - if (_PM_keyHandler) { - restoreISR(0x9, _PM_prevKey, _PM_prevRealKey); - _PM_keyHandler = NULL; - } -} - -void PMAPI PM_setKey15Handler(PM_key15Handler kh) -{ - getISR(0x15, &_PM_prevKey15, &_PM_prevRealKey15); - _PM_key15Handler = kh; - setISR(0x15, _PM_key15ISR); -} - -void PMAPI PM_restoreKey15Handler(void) -{ - if (_PM_key15Handler) { - restoreISR(0x15, _PM_prevKey15, _PM_prevRealKey15); - _PM_key15Handler = NULL; - } -} - -void PMAPI PM_installAltBreakHandler(PM_breakHandler bh) -{ - static int ctrlCFlag,ctrlBFlag; - - _PM_ctrlCPtr = (uchar*)&ctrlCFlag; - _PM_ctrlBPtr = (uchar*)&ctrlBFlag; - getISR(0x1B, &_PM_prevBreak, &prevRealBreak); - getISR(0x23, &_PM_prevCtrlC, &prevRealCtrlC); - _PM_breakHandler = bh; - setISR(0x1B, _PM_breakISR); - setISR(0x23, _PM_ctrlCISR); -} - -void PMAPI PM_installBreakHandler(void) -{ - PM_installAltBreakHandler(NULL); -} - -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; - } -} - -void PMAPI PM_installAltCriticalHandler(PM_criticalHandler ch) -{ - static short critBuf[2]; - - _PM_critPtr = (uchar*)critBuf; - getISR(0x24, &_PM_prevCritical, &prevRealCritical); - _PM_critHandler = ch; - setISR(0x24, _PM_criticalISR); -} - -void PMAPI PM_installCriticalHandler(void) -{ - PM_installAltCriticalHandler(NULL); -} - -void PMAPI PM_restoreCriticalHandler(void) -{ - if (_PM_prevCritical.sel) { - restoreISR(0x24, _PM_prevCritical, prevRealCritical); - _PM_prevCritical.sel = 0; - _PM_critHandler = NULL; - } -} - -int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - return (_dx_lock_pgsn(p,len) == 0); -} - -int PMAPI PM_unlockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - return (_dx_ulock_pgsn(p,len) == 0); -} - -int PMAPI PM_lockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - CONFIG_INF config; - FARPTR fp; - - _dx_config_inf(&config, (UCHAR*)&config); - FP_SET(fp,p,config.c_cs_sel); - return (_dx_lock_pgs(fp,len) == 0); -} - -int PMAPI PM_unlockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - CONFIG_INF config; - FARPTR fp; - - _dx_config_inf(&config, (UCHAR*)&config); - FP_SET(fp,p,config.c_cs_sel); - return (_dx_ulock_pgs(fp,len) == 0); -} - -#endif - -/*-------------------------------------------------------------------------*/ -/* Symantec C++ DOSX and FlashTek X-32/X-32VM support */ -/*-------------------------------------------------------------------------*/ - -#if defined(DOSX) || defined(X32VM) - -#ifdef X32VM -#include -#endif - -static long prevRealBreak; /* Previous real mode break handler */ -static long prevRealCtrlC; /* Previous real mode CtrlC handler */ -static long prevRealCritical; /* Prev real mode critical handler */ - -static uint mouseSel = 0,mouseOff; - -/* The following real mode routine is used to call a 32 bit protected - * mode FAR function from real mode. We use this for passing up control - * from the real mode mouse callback to our protected mode code. - */ - -static char realHandler[] = { /* Real mode code generic handler */ - 0x00,0x00,0x00,0x00, /* __PM_callProtp */ - 0x00,0x00, /* __PM_protCS */ - 0x00,0x00,0x00,0x00, /* __PM_protHandler */ - 0x1E, /* push ds */ - 0x6A,0x00, /* push 0 */ - 0x6A,0x00, /* push 0 */ - 0x2E,0xFF,0x36,0x04,0x00, /* push [cs:__PM_protCS] */ - 0x66,0x2E,0xFF,0x36,0x06,0x00, /* push [cs:__PM_protHandler] */ - 0x2E,0xFF,0x1E,0x00,0x00, /* call [cs:__PM_callProtp] */ - 0x83,0xC4,0x0A, /* add sp,10 */ - 0x1F, /* pop ds */ - 0xCB, /* retf */ - }; - -/* The following functions installs the above realmode callback mechanism - * in real mode memory for calling the protected mode routine. - */ - -int installCallback(void (PMAPI *pmCB)(),uint *psel, uint *poff, - uint *rseg, uint *roff) -{ - PMREGS regs; - PMSREGS sregs; - - regs.x.ax = 0x250D; - PM_segread(&sregs); - PM_int386x(0x21,®s,®s,&sregs); /* Get RM callback address */ - - /* Fill in the values in the real mode code segment so that it will - * call the correct routine. - */ - *((ulong*)&realHandler[0]) = regs.e.eax; - *((ushort*)&realHandler[4]) = sregs.cs; - *((ulong*)&realHandler[6]) = (ulong)pmCB; - - /* Copy the real mode handler to real mode memory (only allocate the - * buffer once since we cant dealloate it with X32). - */ - if (*psel == 0) { - if (!PM_allocRealSeg(sizeof(realHandler),psel,poff,rseg,roff)) - return 0; - } - PM_memcpyfn(*psel,*poff,realHandler,sizeof(realHandler)); - - /* Skip past global variables in real mode code segment */ - *roff += 0x0A; - return 1; -} - -int PMAPI PM_setMouseHandler(int mask, PM_mouseHandler mh) -{ - RMREGS regs; - RMSREGS sregs; - uint rseg,roff; - - lockPMHandlers(); /* Ensure our handlers are locked */ - - if (!installCallback(_PM_mouseISR, &mouseSel, &mouseOff, &rseg, &roff)) - return 0; - _PM_mouseHandler = mh; - - /* Install the real mode mouse handler */ - sregs.es = rseg; - regs.x.dx = roff; - regs.x.cx = _PM_mouseMask = mask; - regs.x.ax = 0xC; - PM_int86x(0x33, ®s, ®s, &sregs); - return 1; -} - -void PMAPI PM_restoreMouseHandler(void) -{ - RMREGS regs; - - if (_PM_mouseHandler) { - regs.x.ax = 33; - PM_int86(0x33, ®s, ®s); - _PM_mouseHandler = NULL; - } -} - -void PMAPI PM_getPMvect(int intno, PMFARPTR *isr) -{ - PMREGS regs; - PMSREGS sregs; - - PM_segread(&sregs); - regs.x.ax = 0x2502; /* Get PM interrupt vector */ - regs.x.cx = intno; - PM_int386x(0x21, ®s, ®s, &sregs); - isr->sel = sregs.es; - isr->off = regs.e.ebx; -} - -void PMAPI PM_setPMvect(int intno, PM_intHandler isr) -{ - PMFARPTR pmisr; - PMSREGS sregs; - - PM_saveDS(); - PM_segread(&sregs); - pmisr.sel = sregs.cs; - pmisr.off = (uint)isr; - PM_restorePMvect(intno, pmisr); -} - -void PMAPI PM_restorePMvect(int intno, PMFARPTR isr) -{ - PMREGS regs; - PMSREGS sregs; - - PM_segread(&sregs); - regs.x.ax = 0x2505; /* Set PM interrupt vector */ - regs.x.cx = intno; - sregs.ds = isr.sel; - regs.e.edx = isr.off; - PM_int386x(0x21, ®s, ®s, &sregs); -} - -static void getISR(int intno, PMFARPTR *pmisr, long *realisr) -{ - PM_getPMvect(intno,pmisr); - _PM_getRMvect(intno,realisr); -} - -static void restoreISR(int intno, PMFARPTR pmisr, long realisr) -{ - PMREGS regs; - PMSREGS sregs; - - PM_segread(&sregs); - regs.x.ax = 0x2507; /* Set real and PM vectors */ - regs.x.cx = intno; - sregs.ds = pmisr.sel; - regs.e.edx = pmisr.off; - regs.e.ebx = realisr; - PM_int386x(0x21, ®s, ®s, &sregs); -} - -static void setISR(int intno, void *isr) -{ - PMREGS regs; - PMSREGS sregs; - - lockPMHandlers(); /* Ensure our handlers are locked */ - - PM_segread(&sregs); - regs.x.ax = 0x2506; /* Hook real and protected vectors */ - regs.x.cx = intno; - sregs.ds = sregs.cs; - regs.e.edx = (uint)isr; - PM_int386x(0x21, ®s, ®s, &sregs); -} - -void PMAPI PM_setTimerHandler(PM_intHandler th) -{ - getISR(0x8, &_PM_prevTimer, &_PM_prevRealTimer); - _PM_timerHandler = th; - setISR(0x8, _PM_timerISR); -} - -void PMAPI PM_restoreTimerHandler(void) -{ - if (_PM_timerHandler) { - restoreISR(0x8, _PM_prevTimer, _PM_prevRealTimer); - _PM_timerHandler = NULL; - } -} - -ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler th,int frequency) -{ - /* Save the old CMOS real time clock values */ - _PM_oldCMOSRegA = _PM_readCMOS(0x0A); - _PM_oldCMOSRegB = _PM_readCMOS(0x0B); - - /* Set the real time clock interrupt handler */ - getISR(0x70, &_PM_prevRTC, &_PM_prevRealRTC); - _PM_rtcHandler = th; - setISR(0x70, _PM_rtcISR); - - /* Program the real time clock default frequency */ - PM_setRealTimeClockFrequency(frequency); - - /* Unmask IRQ8 in the PIC2 */ - _PM_oldRTCPIC2 = PM_inpb(0xA1); - PM_outpb(0xA1,_PM_oldRTCPIC2 & 0xFE); - return true; -} - -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; - } -} - -void PMAPI PM_setKeyHandler(PM_intHandler kh) -{ - getISR(0x9, &_PM_prevKey, &_PM_prevRealKey); - _PM_keyHandler = kh; - setISR(0x9, _PM_keyISR); -} - -void PMAPI PM_restoreKeyHandler(void) -{ - if (_PM_keyHandler) { - restoreISR(0x9, _PM_prevKey, _PM_prevRealKey); - _PM_keyHandler = NULL; - } -} - -void PMAPI PM_setKey15Handler(PM_key15Handler kh) -{ - getISR(0x15, &_PM_prevKey15, &_PM_prevRealKey15); - _PM_key15Handler = kh; - setISR(0x15, _PM_key15ISR); -} - -void PMAPI PM_restoreKey15Handler(void) -{ - if (_PM_key15Handler) { - restoreISR(0x15, _PM_prevKey15, _PM_prevRealKey15); - _PM_key15Handler = NULL; - } -} - -void PMAPI PM_installAltBreakHandler(PM_breakHandler bh) -{ - static int ctrlCFlag,ctrlBFlag; - - _PM_ctrlCPtr = (uchar*)&ctrlCFlag; - _PM_ctrlBPtr = (uchar*)&ctrlBFlag; - getISR(0x1B, &_PM_prevBreak, &prevRealBreak); - getISR(0x23, &_PM_prevCtrlC, &prevRealCtrlC); - _PM_breakHandler = bh; - setISR(0x1B, _PM_breakISR); - setISR(0x23, _PM_ctrlCISR); -} - -void PMAPI PM_installBreakHandler(void) -{ - PM_installAltBreakHandler(NULL); -} - -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; - } -} - -void PMAPI PM_installAltCriticalHandler(PM_criticalHandler ch) -{ - static short critBuf[2]; - - _PM_critPtr = (uchar*)critBuf; - getISR(0x24, &_PM_prevCritical, &prevRealCritical); - _PM_critHandler = ch; - setISR(0x24, _PM_criticalISR); -} - -void PMAPI PM_installCriticalHandler(void) -{ - PM_installAltCriticalHandler(NULL); -} - -void PMAPI PM_restoreCriticalHandler(void) -{ - if (_PM_prevCritical.sel) { - restoreISR(0x24, _PM_prevCritical, prevRealCritical); - _PM_prevCritical.sel = 0; - _PM_critHandler = NULL; - } -} - -int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - return (_x386_memlock(p,len) == 0); -} - -int PMAPI PM_unlockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - return (_x386_memunlock(p,len) == 0); -} - -int PMAPI PM_lockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - return (_x386_memlock(p,len) == 0); -} - -int PMAPI PM_unlockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - return (_x386_memunlock(p,len) == 0); -} - -#endif - -/*-------------------------------------------------------------------------*/ -/* Borland's DPMI32 DOS Power Pack Extender support. */ -/*-------------------------------------------------------------------------*/ - -#ifdef DPMI32 -#define GENERIC_DPMI32 /* Use generic 32 bit DPMI routines */ - -void PMAPI PM_getPMvect(int intno, PMFARPTR *isr) -{ - PMREGS regs; - - regs.x.ax = 0x204; - regs.h.bl = intno; - PM_int386(0x31,®s,®s); - isr->sel = regs.x.cx; - isr->off = regs.e.edx; -} - -void PMAPI PM_setPMvect(int intno, PM_intHandler isr) -{ - PMSREGS sregs; - PMREGS regs; - - PM_saveDS(); - regs.x.ax = 0x205; /* Set protected mode vector */ - regs.h.bl = intno; - PM_segread(&sregs); - regs.x.cx = sregs.cs; - regs.e.edx = (uint)isr; - PM_int386(0x31,®s,®s); -} - -void PMAPI PM_restorePMvect(int intno, PMFARPTR isr) -{ - PMREGS regs; - - regs.x.ax = 0x205; - regs.h.bl = intno; - regs.x.cx = isr.sel; - regs.e.edx = isr.off; - PM_int386(0x31,®s,®s); -} -#endif - -/*-------------------------------------------------------------------------*/ -/* Watcom C/C++ with Rational DOS/4GW support. */ -/*-------------------------------------------------------------------------*/ - -#ifdef DOS4GW -#define GENERIC_DPMI32 /* Use generic 32 bit DPMI routines */ - -#define MOUSE_SUPPORTED /* DOS4GW directly supports mouse */ - -/* We use the normal DOS services to save and restore interrupts handlers - * for Watcom C++, because using the direct DPMI functions does not - * appear to work properly. At least if we use the DPMI functions, we - * dont get the auto-passup feature that we need to correctly trap - * real and protected mode interrupts without installing Bi-model - * interrupt handlers. - */ - -void PMAPI PM_getPMvect(int intno, PMFARPTR *isr) -{ - PMREGS regs; - PMSREGS sregs; - - PM_segread(&sregs); - regs.h.ah = 0x35; - regs.h.al = intno; - PM_int386x(0x21,®s,®s,&sregs); - isr->sel = sregs.es; - isr->off = regs.e.ebx; -} - -void PMAPI PM_setPMvect(int intno, PM_intHandler isr) -{ - PMREGS regs; - PMSREGS sregs; - - PM_saveDS(); - PM_segread(&sregs); - regs.h.ah = 0x25; - regs.h.al = intno; - sregs.ds = sregs.cs; - regs.e.edx = (uint)isr; - PM_int386x(0x21,®s,®s,&sregs); -} - -void PMAPI PM_restorePMvect(int intno, PMFARPTR isr) -{ - PMREGS regs; - PMSREGS sregs; - - PM_segread(&sregs); - regs.h.ah = 0x25; - regs.h.al = intno; - sregs.ds = isr.sel; - regs.e.edx = isr.off; - PM_int386x(0x21,®s,®s,&sregs); -} - -int PMAPI PM_setMouseHandler(int mask, PM_mouseHandler mh) -{ - lockPMHandlers(); /* Ensure our handlers are locked */ - - _PM_mouseHandler = mh; - _PM_setMouseHandler(_PM_mouseMask = mask); - return 1; -} - -void PMAPI PM_restoreMouseHandler(void) -{ - PMREGS regs; - - if (_PM_mouseHandler) { - regs.x.ax = 33; - PM_int386(0x33, ®s, ®s); - _PM_mouseHandler = NULL; - } -} - -#endif - -/*-------------------------------------------------------------------------*/ -/* DJGPP port of GNU C++ support. */ -/*-------------------------------------------------------------------------*/ - -#ifdef DJGPP -#define GENERIC_DPMI32 /* Use generic 32 bit DPMI routines */ - -void PMAPI PM_getPMvect(int intno, PMFARPTR *isr) -{ - PMREGS regs; - - regs.x.ax = 0x204; - regs.h.bl = intno; - PM_int386(0x31,®s,®s); - isr->sel = regs.x.cx; - isr->off = regs.e.edx; -} - -void PMAPI PM_setPMvect(int intno, PM_intHandler isr) -{ - PMSREGS sregs; - PMREGS regs; - - PM_saveDS(); - regs.x.ax = 0x205; /* Set protected mode vector */ - regs.h.bl = intno; - PM_segread(&sregs); - regs.x.cx = sregs.cs; - regs.e.edx = (uint)isr; - PM_int386(0x31,®s,®s); -} - -void PMAPI PM_restorePMvect(int intno, PMFARPTR isr) -{ - PMREGS regs; - - regs.x.ax = 0x205; - regs.h.bl = intno; - regs.x.cx = isr.sel; - regs.e.edx = isr.off; - PM_int386(0x31,®s,®s); -} - -#endif - -/*-------------------------------------------------------------------------*/ -/* Generic 32 bit DPMI routines */ -/*-------------------------------------------------------------------------*/ - -#if defined(GENERIC_DPMI32) - -static long prevRealBreak; /* Previous real mode break handler */ -static long prevRealCtrlC; /* Previous real mode CtrlC handler */ -static long prevRealCritical; /* Prev real mode critical handler */ - -#ifndef MOUSE_SUPPORTED - -/* The following real mode routine is used to call a 32 bit protected - * mode FAR function from real mode. We use this for passing up control - * from the real mode mouse callback to our protected mode code. - */ - -static long mouseRMCB; /* Mouse real mode callback address */ -static uchar *mousePtr; -static char mouseRegs[0x32]; /* Real mode regs for mouse callback */ -static uchar mouseHandler[] = { - 0x00,0x00,0x00,0x00, /* _realRMCB */ - 0x2E,0xFF,0x1E,0x00,0x00, /* call [cs:_realRMCB] */ - 0xCB, /* retf */ - }; - -int PMAPI PM_setMouseHandler(int mask, PM_mouseHandler mh) -{ - RMREGS regs; - RMSREGS sregs; - uint rseg,roff; - - lockPMHandlers(); /* Ensure our handlers are locked */ - - /* Copy the real mode handler to real mode memory */ - if ((mousePtr = PM_allocRealSeg(sizeof(mouseHandler),&rseg,&roff)) == NULL) - return 0; - memcpy(mousePtr,mouseHandler,sizeof(mouseHandler)); - if (!_DPMI_allocateCallback(_PM_mousePMCB, mouseRegs, &mouseRMCB)) - PM_fatalError("Unable to allocate real mode callback!\n"); - PM_setLong(mousePtr,mouseRMCB); - - /* Install the real mode mouse handler */ - _PM_mouseHandler = mh; - sregs.es = rseg; - regs.x.dx = roff+4; - regs.x.cx = _PM_mouseMask = mask; - regs.x.ax = 0xC; - PM_int86x(0x33, ®s, ®s, &sregs); - return 1; -} - -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; - } -} - -#endif - -static void getISR(int intno, PMFARPTR *pmisr, long *realisr) -{ - PM_getPMvect(intno,pmisr); - _PM_getRMvect(intno,realisr); -} - -static void restoreISR(int intno, PMFARPTR pmisr, long realisr) -{ - _PM_setRMvect(intno,realisr); - PM_restorePMvect(intno,pmisr); -} - -static void setISR(int intno, void (* PMAPI pmisr)()) -{ - lockPMHandlers(); /* Ensure our handlers are locked */ - PM_setPMvect(intno,pmisr); -} - -void PMAPI PM_setTimerHandler(PM_intHandler th) -{ - getISR(0x8, &_PM_prevTimer, &_PM_prevRealTimer); - _PM_timerHandler = th; - setISR(0x8, _PM_timerISR); -} - -void PMAPI PM_restoreTimerHandler(void) -{ - if (_PM_timerHandler) { - restoreISR(0x8, _PM_prevTimer, _PM_prevRealTimer); - _PM_timerHandler = NULL; - } -} - -ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler th,int frequency) -{ - /* Save the old CMOS real time clock values */ - _PM_oldCMOSRegA = _PM_readCMOS(0x0A); - _PM_oldCMOSRegB = _PM_readCMOS(0x0B); - - /* Set the real time clock interrupt handler */ - getISR(0x70, &_PM_prevRTC, &_PM_prevRealRTC); - _PM_rtcHandler = th; - setISR(0x70, _PM_rtcISR); - - /* Program the real time clock default frequency */ - PM_setRealTimeClockFrequency(frequency); - - /* Unmask IRQ8 in the PIC2 */ - _PM_oldRTCPIC2 = PM_inpb(0xA1); - PM_outpb(0xA1,_PM_oldRTCPIC2 & 0xFE); - return true; -} - -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; - } -} - -PM_IRQHandle PMAPI PM_setIRQHandler( - int IRQ, - PM_irqHandler ih) -{ - int thunkSize,PICmask,chainPrevious; - ulong offsetAdjust; - _PM_IRQHandle *handle; - - thunkSize = (ulong)_PM_irqISRTemplateEnd - (ulong)_PM_irqISRTemplate; - if ((handle = PM_malloc(sizeof(_PM_IRQHandle) + thunkSize)) == 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); - } - else { - 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; - memcpy(handle->thunk,_PM_irqISRTemplate,thunkSize); - *((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; - } - else { - *((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 */ - getISR(handle->IRQVect, &handle->prevHandler, &handle->prevRealhandler); - setISR(handle->IRQVect, (PM_intHandler)handle->thunk); - - /* Unmask the IRQ in the PIC */ - PM_outpb(0xA1,handle->prevPIC2 & ~(PICmask >> 8)); - PM_outpb(0x21,handle->prevPIC & ~PICmask); - return handle; -} - -void PMAPI PM_restoreIRQHandler( - PM_IRQHandle irqHandle) -{ - int PICmask; - _PM_IRQHandle *handle = irqHandle; - - /* Restore PIC mask for the interrupt */ - if (handle->IRQ < 8) - PICmask = (1 << handle->IRQ); - else - 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)); - - /* Restore the interrupt vector */ - restoreISR(handle->IRQVect, handle->prevHandler, handle->prevRealhandler); - - /* Finally free the thunk */ - PM_free(handle); -} - -void PMAPI PM_setKeyHandler(PM_intHandler kh) -{ - getISR(0x9, &_PM_prevKey, &_PM_prevRealKey); - _PM_keyHandler = kh; - setISR(0x9, _PM_keyISR); -} - -void PMAPI PM_restoreKeyHandler(void) -{ - if (_PM_keyHandler) { - restoreISR(0x9, _PM_prevKey, _PM_prevRealKey); - _PM_keyHandler = NULL; - } -} - -void PMAPI PM_setKey15Handler(PM_key15Handler kh) -{ - getISR(0x15, &_PM_prevKey15, &_PM_prevRealKey15); - _PM_key15Handler = kh; - setISR(0x15, _PM_key15ISR); -} - -void PMAPI PM_restoreKey15Handler(void) -{ - if (_PM_key15Handler) { - restoreISR(0x15, _PM_prevKey15, _PM_prevRealKey15); - _PM_key15Handler = NULL; - } -} - -/* Real mode Ctrl-C and Ctrl-Break handler. This handler simply sets a - * flag in the real mode code segment and exit. We save the location - * of this flag in real mode memory so that both the real mode and - * protected mode code will be modifying the same flags. - */ - -#ifndef DOS4GW -static uchar ctrlHandler[] = { - 0x00,0x00,0x00,0x00, /* ctrlBFlag */ - 0x66,0x2E,0xC7,0x06,0x00,0x00, - 0x01,0x00,0x00,0x00, /* mov [cs:ctrlBFlag],1 */ - 0xCF, /* iretf */ - }; -#endif - -void PMAPI PM_installAltBreakHandler(PM_breakHandler bh) -{ -#ifndef DOS4GW - uint rseg,roff; -#else - static int ctrlCFlag,ctrlBFlag; - - _PM_ctrlCPtr = (uchar*)&ctrlCFlag; - _PM_ctrlBPtr = (uchar*)&ctrlBFlag; -#endif - - getISR(0x1B, &_PM_prevBreak, &prevRealBreak); - getISR(0x23, &_PM_prevCtrlC, &prevRealCtrlC); - _PM_breakHandler = bh; - setISR(0x1B, _PM_breakISR); - setISR(0x23, _PM_ctrlCISR); - -#ifndef DOS4GW - /* Hook the real mode vectors for these handlers, as these are not - * normally reflected by the DPMI server up to protected mode - */ - _PM_ctrlBPtr = PM_allocRealSeg(sizeof(ctrlHandler)*2, &rseg, &roff); - memcpy(_PM_ctrlBPtr,ctrlHandler,sizeof(ctrlHandler)); - memcpy(_PM_ctrlBPtr+sizeof(ctrlHandler),ctrlHandler,sizeof(ctrlHandler)); - _PM_ctrlCPtr = _PM_ctrlBPtr + sizeof(ctrlHandler); - _PM_setRMvect(0x1B,((long)rseg << 16) | (roff+4)); - _PM_setRMvect(0x23,((long)rseg << 16) | (roff+sizeof(ctrlHandler)+4)); -#endif -} - -void PMAPI PM_installBreakHandler(void) -{ - PM_installAltBreakHandler(NULL); -} - -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; -#ifndef DOS4GW - PM_freeRealSeg(_PM_ctrlBPtr); -#endif - } -} - -/* Real mode Critical Error handler. This handler simply saves the AX and - * DI values in the real mode code segment and exits. We save the location - * of this flag in real mode memory so that both the real mode and - * protected mode code will be modifying the same flags. - */ - -#ifndef DOS4GW -static uchar criticalHandler[] = { - 0x00,0x00, /* axCode */ - 0x00,0x00, /* diCode */ - 0x2E,0xA3,0x00,0x00, /* mov [cs:axCode],ax */ - 0x2E,0x89,0x3E,0x02,0x00, /* mov [cs:diCode],di */ - 0xB8,0x03,0x00, /* mov ax,3 */ - 0xCF, /* iretf */ - }; -#endif - -void PMAPI PM_installAltCriticalHandler(PM_criticalHandler ch) -{ -#ifndef DOS4GW - uint rseg,roff; -#else - static short critBuf[2]; - - _PM_critPtr = (uchar*)critBuf; -#endif - - getISR(0x24, &_PM_prevCritical, &prevRealCritical); - _PM_critHandler = ch; - setISR(0x24, _PM_criticalISR); - -#ifndef DOS4GW - /* Hook the real mode vector, as this is not normally reflected by the - * DPMI server up to protected mode. - */ - _PM_critPtr = PM_allocRealSeg(sizeof(criticalHandler)*2, &rseg, &roff); - memcpy(_PM_critPtr,criticalHandler,sizeof(criticalHandler)); - _PM_setRMvect(0x24,((long)rseg << 16) | (roff+4)); -#endif -} - -void PMAPI PM_installCriticalHandler(void) -{ - PM_installAltCriticalHandler(NULL); -} - -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; - } -} - -int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - PMSREGS sregs; - PM_segread(&sregs); - return DPMI_lockLinearPages((uint)p + DPMI_getSelectorBase(sregs.ds),len); -} - -int PMAPI PM_unlockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - PMSREGS sregs; - PM_segread(&sregs); - return DPMI_unlockLinearPages((uint)p + DPMI_getSelectorBase(sregs.ds),len); -} - -int PMAPI PM_lockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - PMSREGS sregs; - PM_segread(&sregs); - return DPMI_lockLinearPages((uint)p + DPMI_getSelectorBase(sregs.cs),len); -} - -int PMAPI PM_unlockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - PMSREGS sregs; - PM_segread(&sregs); - return DPMI_unlockLinearPages((uint)p + DPMI_getSelectorBase(sregs.cs),len); -} - -#endif diff --git a/board/MAI/bios_emulator/scitech/src/pm/dos/vflat.c b/board/MAI/bios_emulator/scitech/src/pm/dos/vflat.c deleted file mode 100644 index c3e9b6c33f..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/vflat.c +++ /dev/null @@ -1,251 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit DOS -* -* Description: Main C module for the VFlat framebuffer routines. The page -* fault handler is always installed to handle up to a 4Mb -* framebuffer with a window size of 4Kb or 64Kb in size. -* -****************************************************************************/ - -#include "pmapi.h" -#include -#include - -/*-------------------------------------------------------------------------*/ -/* DOS4G/W, PMODE/W and CauseWay support. */ -/*-------------------------------------------------------------------------*/ - -#if defined(DOS4GW) - -#define VFLAT_START_ADDR 0xF0000000U -#define VFLAT_END_ADDR 0xF03FFFFFU -#define VFLAT_LIMIT (VFLAT_END_ADDR - VFLAT_START_ADDR) -#define PAGE_PRESENT 1 -#define PAGE_NOTPRESENT 0 -#define PAGE_READ 0 -#define PAGE_WRITE 2 - -PRIVATE ibool installed = false; -PRIVATE ibool haveDPMI = false; -PUBLIC ibool _ASMAPI VF_haveCauseWay = false; -PUBLIC uchar * _ASMAPI VF_zeroPtr = NULL; - -/* Low level assembler code */ - -int _ASMAPI InitPaging(void); -void _ASMAPI ClosePaging(void); -void _ASMAPI MapPhysical2Linear(ulong pAddr, ulong lAddr, int pages, int flags); -void _ASMAPI InstallFaultHandler(ulong baseAddr,int bankSize); -void _ASMAPI RemoveFaultHandler(void); -void _ASMAPI InstallBankFunc(int codeLen,void *bankFunc); - -void * _ASMAPI VF_malloc(uint size) -{ return PM_malloc(size); } - -void _ASMAPI VF_free(void *p) -{ PM_free(p); } - -PRIVATE ibool CheckDPMI(void) -/**************************************************************************** -* -* Function: CheckDPMI -* Returns: True if we are running under DPMI -* -****************************************************************************/ -{ - PMREGS regs; - - if (haveDPMI) - 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 - * DVA.386 or VFLATD.386 virtual device drivers if they are present. - */ - regs.x.ax = 0xFF00; - PM_int386(0x31,®s,®s); - if (!regs.x.cflag && (regs.e.edi & 8)) - return (haveDPMI = true); - return false; -} - -ibool PMAPI VF_available(void) -/**************************************************************************** -* -* Function: VF_available -* Returns: True if virtual buffer is available, false if not. -* -****************************************************************************/ -{ - if (!VF_zeroPtr) - VF_zeroPtr = PM_mapPhysicalAddr(0,0xFFFFFFFF,true); - if (CheckDPMI()) - return false; - - /* Standard DOS4GW, PMODE/W and Causeway */ - if (InitPaging() == -1) - return false; - ClosePaging(); - return true; -} - -void * PMAPI InitDPMI(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) -/**************************************************************************** -* -* Function: InitDOS4GW -* Parameters: baseAddr - Base address of framebuffer bank window -* bankSize - Physical size of banks in Kb (4 or 64) -* codeLen - Length of 32 bit bank switch function -* bankFunc - Pointer to protected mode bank function -* Returns: Near pointer to virtual framebuffer, or NULL on failure. -* -* Description: Installs the virtual linear framebuffer handling for -* DPMI environments. This requires the DVA.386 or VFLATD.386 -* virtual device drivers to be installed and functioning. -* -****************************************************************************/ -{ - (void)baseAddr; - (void)bankSize; - (void)codeLen; - (void)bankFunc; - return NULL; -} - -void * PMAPI InitDOS4GW(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) -/**************************************************************************** -* -* Function: InitDOS4GW -* Parameters: baseAddr - Base address of framebuffer bank window -* bankSize - Physical size of banks in Kb (4 or 64) -* codeLen - Length of 32 bit bank switch function -* bankFunc - Pointer to protected mode bank function -* Returns: Near pointer to virtual framebuffer, or NULL on failure. -* -* Description: Installs the virtual linear framebuffer handling for -* the DOS4GW extender. -* -****************************************************************************/ -{ - int i; - - if (InitPaging() == -1) - 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); - } - } - else { - 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); - InstallBankFunc(codeLen,bankFunc); - installed = true; - return (void*)VFLAT_START_ADDR; -} - -void * PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) -/**************************************************************************** -* -* Function: VF_init -* Parameters: baseAddr - Base address of framebuffer bank window -* bankSize - Physical size of banks in Kb (4 or 64) -* codeLen - Length of 32 bit bank switch function -* bankFunc - Pointer to protected mode bank function -* Returns: Near pointer to virtual framebuffer, or NULL on failure. -* -* Description: Installs the virtual linear framebuffer handling. -* -****************************************************************************/ -{ - if (installed) - return (void*)VFLAT_START_ADDR; - if (codeLen > 100) - return NULL; /* Bank function is too large! */ - if (!VF_zeroPtr) - VF_zeroPtr = PM_mapPhysicalAddr(0,0xFFFFFFFF,true); - if (CheckDPMI()) - return InitDPMI(baseAddr,bankSize,codeLen,bankFunc); - return InitDOS4GW(baseAddr,bankSize,codeLen,bankFunc); -} - -void PMAPI VF_exit(void) -/**************************************************************************** -* -* Function: VF_exit -* -* Description: Closes down the virtual framebuffer services and -* restores the previous page fault handler. -* -****************************************************************************/ -{ - if (installed) { - if (haveDPMI) { - /* DPMI support */ - } - else { - /* Standard DOS4GW and PMODE/W support */ - RemoveFaultHandler(); - ClosePaging(); - } - installed = false; - } -} - -/*-------------------------------------------------------------------------*/ -/* Support mapped out for other compilers. */ -/*-------------------------------------------------------------------------*/ - -#else - -ibool PMAPI VF_available(void) -{ - return false; -} - -void * PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) -{ - (void)baseAddr; - (void)bankSize; - (void)codeLen; - (void)bankFunc; - return NULL; -} - -void PMAPI VF_exit(void) -{ -} - -#endif diff --git a/board/MAI/bios_emulator/scitech/src/pm/dos/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/dos/ztimer.c deleted file mode 100644 index 53ab16cf40..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/ztimer.c +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: MSDOS -* -* Description: OS specific implementation for the Zen Timer functions. -* -****************************************************************************/ - - -/*---------------------------- Global variables ---------------------------*/ - -uchar * _VARAPI _ZTimerBIOSPtr; - -/*----------------------------- Implementation ----------------------------*/ - -/* External assembler functions */ - -void _ASMAPI LZ_timerOn(void); -ulong _ASMAPI LZ_timerLap(void); -void _ASMAPI LZ_timerOff(void); -ulong _ASMAPI LZ_timerCount(void); -void _ASMAPI LZ_disable(void); -void _ASMAPI LZ_enable(void); - -/**************************************************************************** -REMARKS: -Initialise the Zen Timer module internals. -****************************************************************************/ -void __ZTimerInit(void) -{ - _ZTimerBIOSPtr = PM_getBIOSPointer(); -} - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerOn(tm) LZ_timerOn() - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerLap(tm) LZ_timerLap() - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerOff(tm) LZ_timerOff() - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerCount(tm) LZ_timerCount() - -/**************************************************************************** -REMARKS: -Define the resolution of the long period timer as microseconds per timer tick. -****************************************************************************/ -#define ULZTIMER_RESOLUTION 54925 - -/**************************************************************************** -REMARKS: -Read the Long Period timer value from the BIOS timer tick. -****************************************************************************/ -static ulong __ULZReadTime(void) -{ - ulong ticks; - LZ_disable(); /* Turn of interrupts */ - ticks = PM_getLong(_ZTimerBIOSPtr+0x6C); - LZ_enable(); /* Turn on interrupts again */ - return ticks; -} - -/**************************************************************************** -REMARKS: -Compute the elapsed time from the BIOS timer tick. Note that we check to see -whether a midnight boundary has passed, and if so adjust the finish time to -account for this. We cannot detect if more that one midnight boundary has -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 */ - 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 deleted file mode 100644 index b6f458654b..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/event.c +++ /dev/null @@ -1,1115 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Main implementation for the SciTech cross platform event -* library. This module contains all the generic cross platform -* code, and pulls in modules specific to each target OS -* environment. -* -****************************************************************************/ - -#include "event.h" -#include "pmapi.h" -#include -#include -#include -#include -#include -#include "oshdr.h" - -/*--------------------------- Global variables ----------------------------*/ - -#define EVENTQSIZE 100 /* Number of events in event queue */ -#define JOY_NUM_AXES 4 /* Number of joystick axes supported */ - -static struct { - int mx,my; /* Current mouse position */ - int head; /* Head of event queue */ - int tail; /* Tail of event queue */ - int freeHead; /* Head of free list */ - int count; /* No. of items currently in queue */ - event_t evtq[EVENTQSIZE]; /* The queue structure itself */ - int oldMove; /* Previous movement event */ - int oldKey; /* Previous key repeat event */ - int oldJoyMove; /* Previous joystick movement event */ - int joyMask; /* Mask of joystick axes present */ - int joyMin[JOY_NUM_AXES]; - int joyCenter[JOY_NUM_AXES]; - int joyMax[JOY_NUM_AXES]; - int joyPrev[JOY_NUM_AXES]; - int joyButState; - ulong doubleClick; - ulong autoRepeat; - ulong autoDelay; - ulong autoTicks; - ulong doubleClickThresh; - ulong firstAuto; - int autoMouse_x; - int autoMouse_y; - event_t downMouse; - ulong keyModifiers; /* Current keyboard modifiers */ - uchar keyTable[128]; /* Table of key up/down flags */ - ibool allowLEDS; /* True if LEDS should change */ - _EVT_userEventFilter userEventCallback; - _EVT_mouseMoveHandler mouseMove; - _EVT_heartBeatCallback heartBeat; - void *heartBeatParams; - codepage_t *codePage; - } EVT; - -/*---------------------------- Implementation -----------------------------*/ - -#if defined(__REALDOS__) || defined(__SMX32__) -/* {secret} */ -void EVTAPI _EVT_cCodeStart(void) {} -#endif - -/* External assembler functions */ - -int EVTAPI _EVT_readJoyAxis(int mask,int *axis); -int EVTAPI _EVT_readJoyButtons(void); - -/* Forward declaration */ - -ulong _EVT_getTicks(void); - -/**************************************************************************** -PARAMETERS: -evt - Event to add to the event queue - -REMARKS: -Adds an event to the event queue by tacking it onto the tail of the event -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). -****************************************************************************/ -static void addEvent( - event_t *evt) -{ - int evtID; - - /* 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; - } - } - - /* Call user supplied callback to modify the event if desired */ - if (EVT.userEventCallback) { - if (!EVT.userEventCallback(evt)) - return; - } - - /* Get spot to place the event from the free list */ - evtID = EVT.freeHead; - EVT.freeHead = EVT.evtq[EVT.freeHead].next; - - /* Add to the EVT.tail of the event queue */ - evt->next = -1; - evt->prev = EVT.tail; - if (EVT.tail != -1) - EVT.evtq[EVT.tail].next = evtID; - else - EVT.head = evtID; - EVT.tail = evtID; - EVT.evtq[evtID] = *evt; - EVT.count++; -} - -/**************************************************************************** -REMARKS: -Internal function to initialise the event queue to the empty state. -****************************************************************************/ -static void initEventQueue(void) -{ - int i; - - /* Build free list, and initialize global data structures */ - for (i = 0; i < EVENTQSIZE; i++) - EVT.evtq[i].next = i+1; - EVT.evtq[EVENTQSIZE-1].next = -1; /* Terminate list */ - EVT.count = EVT.freeHead = 0; - EVT.head = EVT.tail = -1; - EVT.oldMove = -1; - EVT.oldKey = -1; - EVT.oldJoyMove = -1; - EVT.joyButState = 0; - EVT.mx = EVT.my = 0; - EVT.keyModifiers = 0; - EVT.allowLEDS = true; - - /* Set default values for mouse double click and mouse auto events */ - EVT.doubleClick = 440; - EVT.autoRepeat = 55; - EVT.autoDelay = 330; - EVT.autoTicks = 0; - EVT.doubleClickThresh = 5; - EVT.firstAuto = true; - EVT.autoMouse_x = EVT.autoMouse_y = 0; - memset(&EVT.downMouse,0,sizeof(EVT.downMouse)); - - /* Setup default pointers for event library */ - EVT.userEventCallback = NULL; - EVT.codePage = &_CP_US_English; - - /* Initialise the joystick module and do basic calibration (which assumes - * the joystick is centered. - */ - EVT.joyMask = EVT_joyIsPresent(); -} - -#if defined(NEED_SCALE_JOY_AXIS) || !defined(USE_OS_JOYSTICK) -/**************************************************************************** -REMARKS: -This function scales a joystick axis value to normalised form. -****************************************************************************/ -static int scaleJoyAxis( - int raw, - int axis) -{ - int scaled,range; - - /* Make sure the joystick is calibrated properly */ - if (EVT.joyCenter[axis] - EVT.joyMin[axis] < 5) - return raw; - if (EVT.joyMax[axis] - EVT.joyCenter[axis] < 5) - return raw; - - /* Now scale the coordinates to -128 to 127 */ - raw -= EVT.joyCenter[axis]; - if (raw < 0) - range = EVT.joyCenter[axis]-EVT.joyMin[axis]; - else - range = EVT.joyMax[axis]-EVT.joyCenter[axis]; - scaled = (raw * 128) / range; - if (scaled < -128) - scaled = -128; - if (scaled > 127) - scaled = 127; - return scaled; -} -#endif - -#if defined(__SMX32__) -#include "smx/event.c" -#elif defined(__RTTARGET__) -#include "rttarget/event.c" -#elif defined(__REALDOS__) -#include "dos/event.c" -#elif defined(__WINDOWS32__) -#include "win32/event.c" -#elif defined(__OS2__) -#if defined(__OS2_PM__) -#include "os2pm/event.c" -#else -#include "os2/event.c" -#endif -#elif defined(__LINUX__) -#if defined(__USE_X11__) -#include "x11/event.c" -#else -#include "linux/event.c" -#endif -#elif defined(__QNX__) -#if defined(__USE_PHOTON__) -#include "photon/event.c" -#elif defined(__USE_X11__) -#include "x11/event.c" -#else -#include "qnx/event.c" -#endif -#elif defined(__BEOS__) -#include "beos/event.c" -#else -#error Event library not ported to this platform yet! -#endif - -/*------------------------ Public interface routines ----------------------*/ - -/* If USE_OS_JOYSTICK is defined, the OS specific libraries will implement - * the joystick code rather than using the generic OS portable version. - */ - -#ifndef USE_OS_JOYSTICK -/**************************************************************************** -DESCRIPTION: -Returns the mask indicating what joystick axes are attached. - -HEADER: -event.h - -REMARKS: -This function is used to detect the attached joysticks, and determine -what axes are present and functioning. This function will re-detect any -attached joysticks when it is called, so if the user forgot to attach -the joystick when the application started, you can call this function to -re-detect any newly attached joysticks. - -SEE ALSO: -EVT_joySetLowerRight, EVT_joySetCenter, EVT_joyIsPresent -****************************************************************************/ -int EVTAPI EVT_joyIsPresent(void) -{ - int mask,i; - - 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; -#ifdef __LINUX__ - PM_init(); -#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; - } - return mask; -} - -/**************************************************************************** -DESCRIPTION: -Polls the joystick for position and button information. - -HEADER: -event.h - -REMARKS: -This routine is used to poll analogue joysticks for button and position -information. It should be called once for each main loop of the user -application, just before processing all pending events via EVT_getNext. -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. - -SEE ALSO: -EVT_getNext, EVT_peekNext, EVT_joySetUpperLeft, EVT_joySetLowerRight, -EVT_joySetCenter, EVT_joyIsPresent -****************************************************************************/ -void EVTAPI EVT_pollJoystick(void) -{ - event_t evt; - 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; - } - } -} - -/**************************************************************************** -DESCRIPTION: -Calibrates the joystick upper left position - -HEADER: -event.h - -REMARKS: -This function can be used to zero in on better joystick calibration factors, -which may work better than the default simplistic calibration (which assumes -the joystick is centered when the event library is initialised). -To use this function, ask the user to hold the stick in the upper left -position and then have them press a key or button. and then call this -function. This function will then read the joystick and update the -calibration factors. - -Usually, assuming that the stick was centered when the event library was -initialized, you really only need to call EVT_joySetLowerRight since the -upper left position is usually always 0,0 on most joysticks. However, the -safest procedure is to call all three calibration functions. - -SEE ALSO: -EVT_joySetUpperLeft, EVT_joySetLowerRight, EVT_joyIsPresent -****************************************************************************/ -void EVTAPI EVT_joySetUpperLeft(void) -{ - _EVT_readJoyAxis(EVT_JOY_AXIS_ALL,EVT.joyMin); -} - -/**************************************************************************** -DESCRIPTION: -Calibrates the joystick lower right position - -HEADER: -event.h - -REMARKS: -This function can be used to zero in on better joystick calibration factors, -which may work better than the default simplistic calibration (which assumes -the joystick is centered when the event library is initialised). -To use this function, ask the user to hold the stick in the lower right -position and then have them press a key or button. and then call this -function. This function will then read the joystick and update the -calibration factors. - -Usually, assuming that the stick was centered when the event library was -initialized, you really only need to call EVT_joySetLowerRight since the -upper left position is usually always 0,0 on most joysticks. However, the -safest procedure is to call all three calibration functions. - -SEE ALSO: -EVT_joySetUpperLeft, EVT_joySetCenter, EVT_joyIsPresent -****************************************************************************/ -void EVTAPI EVT_joySetLowerRight(void) -{ - _EVT_readJoyAxis(EVT_JOY_AXIS_ALL,EVT.joyMax); -} - -/**************************************************************************** -DESCRIPTION: -Calibrates the joystick center position - -HEADER: -event.h - -REMARKS: -This function can be used to zero in on better joystick calibration factors, -which may work better than the default simplistic calibration (which assumes -the joystick is centered when the event library is initialised). -To use this function, ask the user to hold the stick in the center -position and then have them press a key or button. and then call this -function. This function will then read the joystick and update the -calibration factors. - -Usually, assuming that the stick was centered when the event library was -initialized, you really only need to call EVT_joySetLowerRight since the -upper left position is usually always 0,0 on most joysticks. However, the -safest procedure is to call all three calibration functions. - -SEE ALSO: -EVT_joySetUpperLeft, EVT_joySetLowerRight, EVT_joySetCenter -****************************************************************************/ -void EVTAPI EVT_joySetCenter(void) -{ - _EVT_readJoyAxis(EVT_JOY_AXIS_ALL,EVT.joyCenter); -} -#endif - -/**************************************************************************** -DESCRIPTION: -Posts a user defined event to the event queue - -HEADER: -event.h - -RETURNS: -True if event was posted, false if event queue is full. - -PARAMETERS: -what - Type code for message to post -message - Event specific message to post -modifiers - Event specific modifier flags to post - -REMARKS: -This routine is used to post user defined events to the event queue. - -SEE ALSO: -EVT_flush, EVT_getNext, EVT_peekNext, EVT_halt -****************************************************************************/ -ibool EVTAPI EVT_post( - ulong which, - ulong what, - ulong message, - ulong modifiers) -{ - event_t evt; - 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; - } - else - return false; -} - -/**************************************************************************** -DESCRIPTION: -Flushes all events of a specified type from the event queue. - -PARAMETERS: -mask - Mask specifying the types of events that should be removed - -HEADER: -event.h - -REMARKS: -Flushes (removes) all pending events of the specified type from the event -queue. You may combine the masks for different event types with a simple -logical OR. - -SEE ALSO: -EVT_getNext, EVT_halt, EVT_peekNext -****************************************************************************/ -void EVTAPI EVT_flush( - ulong mask) -{ - event_t evt; - - do { /* Flush all events */ - EVT_getNext(&evt,mask); - } while (evt.what != EVT_NULLEVT); -} - -/**************************************************************************** -DESCRIPTION: -Halts until and event of the specified type is recieved. - -HEADER: -event.h - -PARAMETERS: -evt - Pointer to -mask - Mask specifying the types of events that should be removed - -REMARKS: -This functions halts exceution until an event of the specified type is -recieved into the event queue. It does not flush the event queue of events -before performing the busy loop. However this function does throw away -any events other than the ones you have requested via the event mask, to -avoid the event queue filling up with unwanted events (like EVT_KEYUP or -EVT_MOUSEMOVE events). - -SEE ALSO: -EVT_getNext, EVT_flush, EVT_peekNext -****************************************************************************/ -void EVTAPI EVT_halt( - event_t *evt, - ulong mask) -{ - do { /* Wait for an event */ - if (mask & (EVT_JOYEVT)) - EVT_pollJoystick(); - EVT_getNext(evt,EVT_EVERYEVT); - } while (!(evt->what & mask)); -} - -/**************************************************************************** -DESCRIPTION: -Peeks at the next pending event in the event queue. - -HEADER: -event.h - -RETURNS: -True if an event is pending, false if not. - -PARAMETERS: -evt - Pointer to structure to return the event info in -mask - Mask specifying the types of events that should be removed - -REMARKS: -Peeks at the next pending event of the specified type in the event queue. The -mask parameter is used to specify the type of events to be peeked at, and -can be any logical combination of any of the flags defined by the -EVT_eventType enumeration. - -In contrast to EVT_getNext, the event is not removed from the event queue. -You may combine the masks for different event types with a simple logical OR. - -SEE ALSO: -EVT_flush, EVT_getNext, EVT_halt -****************************************************************************/ -ibool EVTAPI EVT_peekNext( - event_t *evt, - ulong mask) -{ - int evtID; - uint ps; - - if (EVT.heartBeat) - 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); - } - return evt->what != EVT_NULLEVT; -} - -/**************************************************************************** -DESCRIPTION: -Retrieves the next pending event from the event queue. - -PARAMETERS: -evt - Pointer to structure to return the event info in -mask - Mask specifying the types of events that should be removed - -HEADER: -event.h - -RETURNS: -True if an event was pending, false if not. - -REMARKS: -Retrieves the next pending event from the event queue, and stores it in a -event_t structure. The mask parameter is used to specify the type of events -to be removed, and can be any logical combination of any of the flags defined -by the EVT_eventType enumeration. - -The what field of the event contains the event code of the event that was -extracted. All application specific events should begin with the EVT_USEREVT -code and build from there. Since the event code is stored in an integer, -there is a maximum of 32 different event codes that can be distinguished. -You can store extra information about the event in the message field to -distinguish between events of the same class (for instance the button used in -a EVT_MOUSEDOWN event). - -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. - -SEE ALSO: -EVT_flush, EVT_halt, EVT_peekNext -****************************************************************************/ -ibool EVTAPI EVT_getNext( - event_t *evt, - ulong mask) -{ - int evtID,next,prev; - uint ps; - - if (EVT.heartBeat) - 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); - } - - /* 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; - } - } - return evt->what != EVT_NULLEVT; -} - -/**************************************************************************** -DESCRIPTION: -Installs a user supplied event filter callback for event handling. - -HEADER: -event.h - -PARAMETERS: -userEventFilter - Address of user supplied event filter callback - -REMARKS: -This function allows the application programmer to install an event filter -callback for event handling. Once you install your callback, the MGL -event handling routines will call your callback with a pointer to the -new event that will be placed into the event queue. Your callback can the -modify the contents of the event before it is placed into the queue (for -instance adding custom information or perhaps high precision timing -information). - -If your callback returns FALSE, the event will be ignore and will not be -posted to the event queue. You should always return true from your event -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. - -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. - -SEE ALSO: -EVT_getNext, EVT_peekNext -****************************************************************************/ -void EVTAPI EVT_setUserEventFilter( - _EVT_userEventFilter filter) -{ - EVT.userEventCallback = filter; -} - -/**************************************************************************** -DESCRIPTION: -Installs a user supplied event heartbeat callback function. - -HEADER: -event.h - -PARAMETERS: -callback - Address of user supplied event heartbeat callback -params - Parameters to pass to the event heartbeat function - -REMARKS: -This function allows the application programmer to install an event heatbeat -function that gets called every time that EVT_getNext or EVT_peekNext -is called. This is primarily useful for simulating text mode cursors inside -event handling code when running in graphics modes as opposed to hardware -text modes. - -SEE ALSO: -EVT_getNext, EVT_peekNext, EVT_getHeartBeatCallback -****************************************************************************/ -void EVTAPI EVT_setHeartBeatCallback( - _EVT_heartBeatCallback callback, - void *params) -{ - EVT.heartBeat = callback; - EVT.heartBeatParams = params; -} - - -/**************************************************************************** -DESCRIPTION: -Returns the current user supplied event heartbeat callback function. - -HEADER: -event.h - -PARAMETERS: -callback - Place to store the address of user supplied event heartbeat callback -params - Place to store the parameters to pass to the event heartbeat function - -REMARKS: -This function retrieves the current event heatbeat function that gets called -every time that EVT_getNext or EVT_peekNext is called. - -SEE ALSO: -EVT_getNext, EVT_peekNext, EVT_setHeartBeatCallback -****************************************************************************/ -void EVTAPI EVT_getHeartBeatCallback( - _EVT_heartBeatCallback *callback, - void **params) -{ - *callback = EVT.heartBeat; - *params = EVT.heartBeatParams; -} - -/**************************************************************************** -DESCRIPTION: -Determines if a specified key is currently down. - -PARAMETERS: -scanCode - Scan code to test - -RETURNS: -True of the specified key is currently held down. - -HEADER: -event.h - -REMARKS: -This function determines if a specified key is currently down at the -time that the call is made. You simply need to pass in the scan code of -the key that you wish to test, and the MGL will tell you if it is currently -down or not. The MGL does this by keeping track of the up and down state -of all the keys. -****************************************************************************/ -ibool EVTAPI EVT_isKeyDown( - uchar scanCode) -{ - return _EVT_isKeyDown(scanCode); -} - -/**************************************************************************** -DESCRIPTION: -Set the mouse position for the event module - -PARAMETERS: -x - X coordinate to move the mouse cursor position to -y - Y coordinate to move the mouse cursor position to - -HEADER: -event.h - -REMARKS: -This function moves the mouse cursor position for the event module to the -specified location. - -SEE ALSO: -EVT_getMousePos -****************************************************************************/ -void EVTAPI EVT_setMousePos( - int x, - int y) -{ - EVT.mx = x; - EVT.my = y; - _EVT_setMousePos(&EVT.mx,&EVT.my); - EVT.mouseMove(EVT.mx,EVT.my); -} - -/**************************************************************************** -DESCRIPTION: -Returns the current mouse cursor location. - -HEADER: -event.h - -PARAMETERS: -x - Place to store value for mouse x coordinate (screen coordinates) -y - Place to store value for mouse y coordinate (screen coordinates) - -REMARKS: -Obtains the current mouse cursor position in screen coordinates. Normally the -mouse cursor location is tracked using the mouse movement events that are -posted to the event queue when the mouse moves, however this routine -provides an alternative method of polling the mouse cursor location. - -SEE ALSO: -EVT_setMousePos -****************************************************************************/ -void EVTAPI EVT_getMousePos( - int *x, - int *y) -{ - *x = EVT.mx; - *y = EVT.my; -} - -/**************************************************************************** -DESCRIPTION: -Returns the currently active code page for translation of keyboard characters. - -HEADER: -event.h - -RETURNS: -Pointer to the currently active code page translation table. - -REMARKS: -This function is returns a pointer to the currently active code page -translation table. See EVT_setCodePage for more information. - -SEE ALSO: -EVT_setCodePage -****************************************************************************/ -codepage_t * EVTAPI EVT_getCodePage(void) -{ - return EVT.codePage; -} - -/**************************************************************************** -DESCRIPTION: -Sets the currently active code page for translation of keyboard characters. - -HEADER: -event.h - -PARAMETERS: -page - New code page to make active - -REMARKS: -This function is used to set a new code page translation table that is used -to translate virtual scan code values to ASCII characters for different -keyboard configurations. The default is usually US English, although if -possible the PM library will auto-detect the correct code page translation -for the target OS if OS services are available to determine what type of -keyboard is currently attached. - -SEE ALSO: -EVT_getCodePage -****************************************************************************/ -void EVTAPI EVT_setCodePage( - codepage_t *page) -{ - EVT.codePage = page; -} - -/* The following contains fake C prototypes and documentation for the - * macro functions in the event.h header file. These exist soley so - * that DocJet will correctly pull in the documentation for these functions. - */ -#ifdef INCLUDE_DOC_FUNCTIONS - -/**************************************************************************** -DESCRIPTION: -Macro to extract the ASCII code from a message. - -PARAMETERS: -message - Message to extract ASCII code from - -RETURNS: -ASCII code extracted from the message. - -HEADER: -event.h - -REMARKS: -Macro to extract the ASCII code from the message field of the event_t -structure. You pass the message field to the macro as the parameter and -the ASCII code is the result, for example: - - event_t EVT.myEvent; - uchar code; - code = EVT_asciiCode(EVT.myEvent.message); - -SEE ALSO: -EVT_scanCode, EVT_repeatCount -****************************************************************************/ -uchar EVT_asciiCode( - ulong message); - -/**************************************************************************** -DESCRIPTION: -Macro to extract the keyboard scan code from a message. - -HEADER: -event.h - -PARAMETERS: -message - Message to extract scan code from - -RETURNS: -Keyboard scan code extracted from the message. - -REMARKS: -Macro to extract the keyboard scan code from the message field of the event -structure. You pass the message field to the macro as the parameter and -the scan code is the result, for example: - - event_t EVT.myEvent; - uchar code; - 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. - -SEE ALSO: -EVT_asciiCode, EVT_repeatCount -****************************************************************************/ -uchar EVT_scanCode( - ulong message); - -/**************************************************************************** -DESCRIPTION: -Macro to extract the repeat count from a message. - -HEADER: -event.h - -PARAMETERS: -message - Message to extract repeat count from - -RETURNS: -Repeat count extracted from the message. - -REMARKS: -Macro to extract the repeat count from the message field of the event -structure. The repeat count is the number of times that the key repeated -before there was another keyboard event to be place in the queue, and -allows the event handling code to avoid keyboard buffer overflow -conditions when a single key is held down by the user. If you are processing -a key repeat code, you will probably want to check this field to see how -many key repeats you should process for this message. - -SEE ALSO: -EVT_asciiCode, EVT_repeatCount -****************************************************************************/ -short EVT_repeatCount( - ulong message); - -#endif /* DOC FUNCTIONS */ - -#if defined(__REALDOS__) || defined(__SMX32__) -/* {secret} */ -void EVTAPI _EVT_cCodeEnd(void) {} -#endif diff --git a/board/MAI/bios_emulator/scitech/src/pm/linux/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/linux/cpuinfo.c deleted file mode 100644 index e88d210954..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/linux/cpuinfo.c +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Linux -* -* Description: Linux specific code for the CPU detection module. -* -****************************************************************************/ - -#include - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -TODO: We should implement this for Linux! -****************************************************************************/ -#define SetMaxThreadPriority() 0 - -/**************************************************************************** -REMARKS: -TODO: We should implement this for Linux! -****************************************************************************/ -#define RestoreThreadPriority(i) - -/**************************************************************************** -REMARKS: -Initialise the counter and return the frequency of the counter. -****************************************************************************/ -static void GetCounterFrequency( - CPU_largeInteger *freq) -{ - freq->low = 1000000; - freq->high = 0; -} - -/**************************************************************************** -REMARKS: -Read the counter and return the counter value. -****************************************************************************/ -#define GetCounter(t) \ -{ \ - struct timeval tv; \ - gettimeofday(&tv,NULL); \ - (t)->low = tv.tv_sec*1000000 + tv.tv_usec; \ - (t)->high = 0; \ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/linux/event.c b/board/MAI/bios_emulator/scitech/src/pm/linux/event.c deleted file mode 100644 index ce38732097..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/linux/event.c +++ /dev/null @@ -1,1360 +0,0 @@ -/**************************************************************************** -* -* SciTech Multi-platform Graphics Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Linux -* -* Description: Linux fullscreen console implementation for the SciTech -* cross platform event library. -* Portions ripped straigth from the gpm source code for mouse -* handling. -* -****************************************************************************/ - -/*---------------------------- Global Variables ---------------------------*/ - -extern int _PM_console_fd; -static ushort keyUpMsg[256] = {0}; -static int _EVT_mouse_fd = 0; -static int range_x, range_y; -static int opt_baud = 1200, opt_sample = 100; -#ifdef USE_OS_JOYSTICK -static short *axis0 = NULL, *axis1 = NULL; -static uchar *buts0 = NULL, *buts1 = NULL; -static int joystick0_fd = 0, joystick1_fd = 0; -static int js_version = 0; -#endif - -/* This defines the supported mouse drivers */ - -typedef enum { - EVT_noMouse = -1, - EVT_microsoft = 0, - EVT_ps2, - EVT_mousesystems, - EVT_gpm, - EVT_MMseries, - EVT_logitech, - EVT_busmouse, - EVT_mouseman, - EVT_intellimouse, - EVT_intellimouse_ps2, - } mouse_drivers_t; - -static mouse_drivers_t mouse_driver = EVT_noMouse; -static char mouse_dev[20] = "/dev/mouse"; - -typedef struct { - char *name; - int flags; - void (*init)(void); - uchar proto[4]; - int packet_len; - int read; - } mouse_info; - -#define STD_FLG (CREAD | CLOCAL | HUPCL) - -static void _EVT_mouse_init(void); -static void _EVT_logitech_init(void); -static void _EVT_pnpmouse_init(void); - -mouse_info mouse_infos[] = { - {"Microsoft", CS7 | B1200 | STD_FLG, _EVT_mouse_init, {0x40, 0x40, 0x40, 0x00}, 3, 1}, - {"PS2", STD_FLG, NULL, {0xc0, 0x00, 0x00, 0x00}, 3, 1}, - {"MouseSystems", CS8 | CSTOPB | STD_FLG, _EVT_mouse_init, {0xf8, 0x80, 0x00, 0x00}, 5, 5}, - {"GPM", CS8 | CSTOPB | STD_FLG, NULL, {0xf8, 0x80, 0x00, 0x00}, 5, 5}, - {"MMSeries", CS8 | PARENB | PARODD | STD_FLG, _EVT_mouse_init, {0xe0, 0x80, 0x80, 0x00}, 3, 1}, - {"Logitech", CS8 | CSTOPB | STD_FLG, _EVT_logitech_init, {0xe0, 0x80, 0x80, 0x00}, 3, 3}, - {"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}, /* ? */ - }; - -#define NB_MICE (sizeof(mouse_infos)/sizeof(mouse_info)) - -/* The name of the environment variables that are used to change the defaults above */ - -#define ENV_MOUSEDRV "MGL_MOUSEDRV" -#define ENV_MOUSEDEV "MGL_MOUSEDEV" -#define ENV_MOUSESPD "MGL_MOUSESPD" -#define ENV_JOYDEV0 "MGL_JOYDEV1" -#define ENV_JOYDEV1 "MGL_JOYDEV2" - -/* Scancode mappings on Linux for special keys */ - -typedef struct { - int scan; - int map; - } keymap; - -/* TODO: Fix this and set it up so we can do a binary search! */ - -keymap keymaps[] = { - {96, KB_padEnter}, - {74, KB_padMinus}, - {78, KB_padPlus}, - {55, KB_padTimes}, - {98, KB_padDivide}, - {71, KB_padHome}, - {72, KB_padUp}, - {73, KB_padPageUp}, - {75, KB_padLeft}, - {76, KB_padCenter}, - {77, KB_padRight}, - {79, KB_padEnd}, - {80, KB_padDown}, - {81, KB_padPageDown}, - {82, KB_padInsert}, - {83, KB_padDelete}, - {105,KB_left}, - {108,KB_down}, - {106,KB_right}, - {103,KB_up}, - {110,KB_insert}, - {102,KB_home}, - {104,KB_pageUp}, - {111,KB_delete}, - {107,KB_end}, - {109,KB_pageDown}, - {125,KB_leftWindows}, - {126,KB_rightWindows}, - {127,KB_menu}, - {100,KB_rightAlt}, - {97,KB_rightCtrl}, - }; - -/* And the keypad with num lock turned on (changes the ASCII code only) */ - -keymap keypad[] = { - {71, ASCII_7}, - {72, ASCII_8}, - {73, ASCII_9}, - {75, ASCII_4}, - {76, ASCII_5}, - {77, ASCII_6}, - {79, ASCII_1}, - {80, ASCII_2}, - {81, ASCII_3}, - {82, ASCII_0}, - {83, ASCII_period}, - }; - -#define NB_KEYMAPS (sizeof(keymaps)/sizeof(keymaps[0])) -#define NB_KEYPAD (sizeof(keypad)/sizeof(keypad[0])) - -typedef struct { - int sample; - char code[2]; - } sample_rate; - -sample_rate sampletab[]={ - { 0,"O"}, - { 15,"J"}, - { 27,"K"}, - { 42,"L"}, - { 60,"R"}, - { 85,"M"}, - {125,"Q"}, - {1E9,"N"}, - }; - -/* Number of keycodes to read at a time from the console */ - -#define KBDREADBUFFERSIZE 32 - -/*---------------------------- Implementation -----------------------------*/ - -/* These are not used under Linux */ -#define _EVT_disableInt() 1 -#define _EVT_restoreInt(flaps) - -/**************************************************************************** -PARAMETERS: -scanCode - Scan code to test - -REMARKS: -This macro determines if a specified key is currently down at the -time that the call is made. -****************************************************************************/ -#define _EVT_isKeyDown(scanCode) (keyUpMsg[scanCode] != 0) - -/**************************************************************************** -REMARKS: -This function is used to return the number of ticks since system -startup in milliseconds. This should be the same value that is placed into -the time stamp fields of events, and is used to implement auto mouse down -events. -****************************************************************************/ -ulong _EVT_getTicks(void) -{ - static uint starttime = 0; - struct timeval t; - - gettimeofday(&t, NULL); - if (starttime == 0) - starttime = t.tv_sec * 1000 + (t.tv_usec/1000); - return ((t.tv_sec * 1000 + (t.tv_usec/1000)) - starttime); -} - -/**************************************************************************** -REMARKS: -Small Unix function that checks for availability on a file using select() -****************************************************************************/ -static ibool dataReady( - int fd) -{ - static struct timeval t = { 0L, 0L }; - fd_set fds; - - FD_ZERO(&fds); - FD_SET(fd, &fds); - return select(fd+1, &fds, NULL, NULL, &t) > 0; -} - -/**************************************************************************** -REMARKS: -Reads mouse data according to the selected mouse driver. -****************************************************************************/ -static ibool readMouseData( - int *buttons, - int *dx, - int *dy) -{ - static uchar data[32],prev = 0; - int cnt = 0,ret; - mouse_info *drv; - - /* 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; - } - if ((data[0] & drv->proto[0]) != drv->proto[1]) - 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; - } - } - if ((data[1] & drv->proto[2]) != drv->proto[3]) - 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; - } - return true; -} - -/**************************************************************************** -REMARKS: -Map a keypress via the key mapping table -****************************************************************************/ -static int getKeyMapping( - keymap *tab, - int nb, - int key) -{ - int i; - - for(i = 0; i < nb; i++) { - if (tab[i].scan == key) - return tab[i].map; - } - return key; -} - -#ifdef USE_OS_JOYSTICK - -static char js0_axes = 0, js0_buttons = 0; -static char js1_axes = 0, js1_buttons = 0; -static char joystick0_dev[20] = "/dev/js0"; -static char joystick1_dev[20] = "/dev/js1"; - -/**************************************************************************** -REMARKS: -Create a joystick event from the joystick data -****************************************************************************/ -static void makeJoyEvent( - event_t *evt) -{ - 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]; - } - else - 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]; - } - else - evt->where_x = evt->where_y = 0; -} - -/**************************************************************************** -REMARKS: -Read the joystick axis data -****************************************************************************/ -int EVTAPI _EVT_readJoyAxis( - int jmask, - int *axis) -{ - 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; - } - } - 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; - } - } - return mask; -} - -/**************************************************************************** -REMARKS: -Read the joystick button data -****************************************************************************/ -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; - } - 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]; - } - return buts; -} - -/**************************************************************************** -DESCRIPTION: -Returns the mask indicating what joystick axes are attached. - -HEADER: -event.h - -REMARKS: -This function is used to detect the attached joysticks, and determine -what axes are present and functioning. This function will re-detect any -attached joysticks when it is called, so if the user forgot to attach -the joystick when the application started, you can call this function to -re-detect any newly attached joysticks. - -SEE ALSO: -EVT_joySetLowerRight, EVT_joySetCenter, EVT_joyIsPresent -****************************************************************************/ -int EVTAPI EVT_joyIsPresent(void) -{ - static int mask = 0; - int i; - char *tmp, name0[128], name1[128]; - static ibool inited = false; - - if (inited) - 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); - if ((tmp = getenv(ENV_JOYDEV1)) != NULL) - strcpy(joystick1_dev,tmp); - if ((joystick0_fd = open(joystick0_dev, O_RDONLY)) < 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; - inited = true; - if (ioctl(joystick0_fd ? joystick0_fd : joystick1_fd, JSIOCGVERSION, &js_version) < 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); - } - } - - /* 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); - } - } - -#ifdef CHECKED - 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); - if (joystick1_fd) - 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; - } - return mask; -} - -/**************************************************************************** -DESCRIPTION: -Polls the joystick for position and button information. - -HEADER: -event.h - -REMARKS: -This routine is used to poll analogue joysticks for button and position -information. It should be called once for each main loop of the user -application, just before processing all pending events via EVT_getNext. -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. - -SEE ALSO: -EVT_getNext, EVT_peekNext, EVT_joySetUpperLeft, EVT_joySetLowerRight, -EVT_joySetCenter, EVT_joyIsPresent -****************************************************************************/ -void EVTAPI EVT_pollJoystick(void) -{ - event_t evt; - 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; - } - } -} - -/**************************************************************************** -DESCRIPTION: -Calibrates the joystick upper left position - -HEADER: -event.h - -REMARKS: -This function can be used to zero in on better joystick calibration factors, -which may work better than the default simplistic calibration (which assumes -the joystick is centered when the event library is initialised). -To use this function, ask the user to hold the stick in the upper left -position and then have them press a key or button. and then call this -function. This function will then read the joystick and update the -calibration factors. - -Usually, assuming that the stick was centered when the event library was -initialized, you really only need to call EVT_joySetLowerRight since the -upper left position is usually always 0,0 on most joysticks. However, the -safest procedure is to call all three calibration functions. - -SEE ALSO: -EVT_joySetUpperLeft, EVT_joySetLowerRight, EVT_joyIsPresent -****************************************************************************/ -void EVTAPI EVT_joySetUpperLeft(void) -{ - _EVT_readJoyAxis(EVT_JOY_AXIS_ALL,EVT.joyMin); -} - -/**************************************************************************** -DESCRIPTION: -Calibrates the joystick lower right position - -HEADER: -event.h - -REMARKS: -This function can be used to zero in on better joystick calibration factors, -which may work better than the default simplistic calibration (which assumes -the joystick is centered when the event library is initialised). -To use this function, ask the user to hold the stick in the lower right -position and then have them press a key or button. and then call this -function. This function will then read the joystick and update the -calibration factors. - -Usually, assuming that the stick was centered when the event library was -initialized, you really only need to call EVT_joySetLowerRight since the -upper left position is usually always 0,0 on most joysticks. However, the -safest procedure is to call all three calibration functions. - -SEE ALSO: -EVT_joySetUpperLeft, EVT_joySetCenter, EVT_joyIsPresent -****************************************************************************/ -void EVTAPI EVT_joySetLowerRight(void) -{ - _EVT_readJoyAxis(EVT_JOY_AXIS_ALL,EVT.joyMax); -} - -/**************************************************************************** -DESCRIPTION: -Calibrates the joystick center position - -HEADER: -event.h - -REMARKS: -This function can be used to zero in on better joystick calibration factors, -which may work better than the default simplistic calibration (which assumes -the joystick is centered when the event library is initialised). -To use this function, ask the user to hold the stick in the center -position and then have them press a key or button. and then call this -function. This function will then read the joystick and update the -calibration factors. - -Usually, assuming that the stick was centered when the event library was -initialized, you really only need to call EVT_joySetLowerRight since the -upper left position is usually always 0,0 on most joysticks. However, the -safest procedure is to call all three calibration functions. - -SEE ALSO: -EVT_joySetUpperLeft, EVT_joySetLowerRight, EVT_joySetCenter -****************************************************************************/ -void EVTAPI EVT_joySetCenter(void) -{ - _EVT_readJoyAxis(EVT_JOY_AXIS_ALL,EVT.joyCenter); -} -#endif - -/**************************************************************************** -REMARKS: -Pumps all messages in the message queue from Linux into our event queue. -****************************************************************************/ -static void _EVT_pumpMessages(void) -{ - event_t evt; - int i,numkeys, c; - ibool release; - static struct kbentry ke; - static char buf[KBDREADBUFFERSIZE]; - static ushort repeatKey[128] = {0}; - - /* 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); - } - } - } - - /* 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; - } - } - } - -#ifdef USE_OS_JOYSTICK - /* 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); - } - } - } - } -#endif -} - -/**************************************************************************** -REMARKS: -This macro/function is used to converts the scan codes reported by the -keyboard to our event libraries normalised format. We only have one scan -code for the 'A' key, and use shift _PM_modifiers to determine if it is a -Ctrl-F1, Alt-F1 etc. The raw scan codes from the keyboard work this way, -but the OS gives us 'cooked' scan codes, we have to translate them back -to the raw format. -****************************************************************************/ -#define _EVT_maskKeyCode(evt) - -/**************************************************************************** -REMARKS: -Set the speed of the serial port -****************************************************************************/ -static int setspeed( - int fd, - int old, - int new, - unsigned short flags) -{ - struct termios tty; - char *c; - - tcgetattr(fd, &tty); - tty.c_iflag = IGNBRK | IGNPAR; - tty.c_oflag = 0; - tty.c_lflag = 0; - tty.c_line = 0; - 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; - } - 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; - } - write(fd, c, 2); - usleep(100000); - tcsetattr(fd, TCSAFLUSH, &tty); - return 0; -} - -/**************************************************************************** -REMARKS: -Generic mouse driver init code -****************************************************************************/ -static void _EVT_mouse_init(void) -{ - int i; - - /* 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); -} - -/**************************************************************************** -REMARKS: -Logitech mouse driver init code -****************************************************************************/ -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"); - i = MAJOR(buf.st_rdev); - if (stat("/dev/ttyS0",&buf) == -1) - 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); - - /* 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); -} - -/**************************************************************************** -REMARKS: -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; - tty.c_lflag = 0; - tty.c_line = 0; - tty.c_cc[VTIME] = 0; - tty.c_cc[VMIN] = 1; - tty.c_cflag = mouse_infos[mouse_driver].flags | B1200; - tcsetattr(_EVT_mouse_fd, TCSAFLUSH, &tty); /* set parameters */ -} - -/**************************************************************************** -PARAMETERS: -mouseMove - Callback function to call wheneve the mouse needs to be moved - -REMARKS: -Initiliase the event handling module. Here we install our mouse handling ISR -to be called whenever any button's are pressed or released. We also build -the free list of events in the event queue. - -We use handler number 2 of the mouse libraries interrupt handlers for our -event handling routines. -****************************************************************************/ -void EVTAPI EVT_init( - _EVT_mouseMoveHandler mouseMove) -{ - int i; - char *tmp; - - /* Initialise the event queue */ - EVT.mouseMove = mouseMove; - initEventQueue(); - for (i = 0; i < 256; i++) - keyUpMsg[i] = 0; - - /* Keyboard initialization */ - if (_PM_console_fd == -1) - 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; - } - } - 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); -#ifdef CHECKED - 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) - ; - } - } -} - -/**************************************************************************** -REMARKS -Changes the range of coordinates returned by the mouse functions to the -specified range of values. This is used when changing between graphics -modes set the range of mouse coordinates for the new display mode. -****************************************************************************/ -void EVTAPI EVT_setMouseRange( - int xRes, - int yRes) -{ - range_x = xRes; - range_y = yRes; -} - -/**************************************************************************** -REMARKS -Modifes the mouse coordinates as necessary if scaling to OS coordinates, -and sets the OS mouse cursor position. -****************************************************************************/ -#define _EVT_setMousePos(x,y) - -/**************************************************************************** -REMARKS: -Initiailises the internal event handling modules. The EVT_suspend function -can be called to suspend event handling (such as when shelling out to DOS), -and this function can be used to resume it again later. -****************************************************************************/ -void EVT_resume(void) -{ - /* Do nothing for Linux */ -} - -/**************************************************************************** -REMARKS -Suspends all of our event handling operations. This is also used to -de-install the event handling code. -****************************************************************************/ -void EVT_suspend(void) -{ - /* Do nothing for Linux */ -} - -/**************************************************************************** -REMARKS -Exits the event module for program terminatation. -****************************************************************************/ -void EVT_exit(void) -{ - /* Restore signal handlers */ - _PM_restore_kb_mode(); - if (_EVT_mouse_fd) { - 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; - } - if (joystick1_fd) { - close(joystick1_fd); - free(axis1); - free(buts1); - joystick1_fd = 0; - } -#endif -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/linux/event.svga b/board/MAI/bios_emulator/scitech/src/pm/linux/event.svga deleted file mode 100644 index c0358a0f8a..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/linux/event.svga +++ /dev/null @@ -1,1058 +0,0 @@ -/**************************************************************************** -* -* The SuperVGA Kit - UniVBE Software Development Kit -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: IBM PC (MS DOS) -* -* Description: Routines to provide a Linux event queue, which automatically -* handles keyboard and mouse events for the Linux compatability -* libraries. Based on the event handling code in the MGL. -* -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "pm.h" -#include "vesavbe.h" -#include "wdirect.h" - -/*--------------------------- Global variables ----------------------------*/ - -#define EVENTQSIZE 100 /* Number of events in event queue */ - -static int head = -1; /* Head of event queue */ -static int tail = -1; /* Tail of event queue */ -static int freeHead = -1; /* Head of free list */ -static int count = 0; /* No. of items currently in queue */ -static WD_event evtq[EVENTQSIZE]; /* The queue structure itself */ -static int oldMove = -1; /* Previous movement event */ -static int oldKey = -1; /* Previous key repeat event */ -static int mx,my; /* Current mouse position */ -static int xRes,yRes; /* Screen resolution coordinates */ -static void *stateBuf; /* Pointer to console state buffer */ -static int conn; /* GPM file descriptor for mouse handling */ -static int tty_fd; /* File descriptor for /dev/console */ -extern int tty_vc; /* Virtual console ID, from the PM/Pro library */ -static ibool key_down[128]; /* State of all keyboard keys */ -static struct termios old_conf; /* Saved terminal configuration */ -static int oldkbmode; /* and previous keyboard mode */ -struct vt_mode oldvtmode; /* Old virtual terminal mode */ -static int old_flags; /* Old flags for fcntl */ -static ulong key_modifiers; /* Keyboard modifiers */ -static int forbid_vt_release=0;/* Flag to forbid release of VT */ -static int forbid_vt_acquire=0;/* Flag to forbid cature of VT */ -static int oldmode; /* Old SVGA mode saved for VT switch*/ -static int initmode; /* Initial text mode */ -static ibool installed = false; /* True if we are installed */ -static void (_ASMAPI *moveCursor)(int x,int y) = NULL; -static int (_ASMAPI *suspendAppCallback)(int flags) = NULL; - -#if 0 -/* Keyboard Translation table from scancodes to ASCII */ - -static uchar keyTable[128] = -"\0\0331234567890-=\010" -"\011qwertyuiop[]\015" -"\0asdfghjkl;'`\0\\" -"zxcvbnm,./\0*\0 \0" -"\0\0\0\0\0\0\0\0\0\0\0\0" /* Function keys */ -"789-456+1230.\0\0\0\0\0" /* Keypad keys */ -"\0\0\0\0\0\0\0\015\0/"; - -static uchar keyTableShifted[128] = -"\0\033!@#$%^&*()_+\010" -"\011QWERTYUIOP{}\015" -"\0ASDFGHJKL:\"~\0|" -"ZXCVBNM<>?\0*\0 \0" -"\0\0\0\0\0\0\0\0\0\0\0\0" /* Function keys */ -"789-456+1230.\0\0\0\0\0" /* Keypad keys */ -"\0\0\0\0\0\0\0\015\0/"; -#endif - -/* Macros to keep track of the CAPS and NUM lock states */ - -#define EVT_CAPSSTATE 0x0100 -#define EVT_NUMSTATE 0x0200 - -/* Helper macros for dealing with timers */ - -#define TICKS_TO_USEC(t) ((t)*65536.0/1.193180) -#define USEC_TO_TICKS(u) ((u)*1.193180/65536.0) - -/* Number of keycodes to read at a time from the console */ - -#define KBDREADBUFFERSIZE 32 - -/*---------------------------- Implementation -----------------------------*/ - -/**************************************************************************** -REMARKS: -Returns the current time stamp in units of 18.2 ticks per second. -****************************************************************************/ -static ulong getTimeStamp(void) -{ - return (ulong)(clock() / (CLOCKS_PER_SEC / 18.2)); -} - -/**************************************************************************** -PARAMETERS: -evt - Event to place onto event queue - -REMARKS: -Adds an event to the event queue by tacking it onto the tail of the event -queue. This routine assumes that at least one spot is available on the -freeList for the event to be inserted. -****************************************************************************/ -static void addEvent( - WD_event *evt) -{ - int evtID; - - /* Get spot to place the event from the free list */ - evtID = freeHead; - freeHead = evtq[freeHead].next; - - /* Add to the tail of the event queue */ - evt->next = -1; - evt->prev = tail; - if (tail != -1) - evtq[tail].next = evtID; - else - head = evtID; - tail = evtID; - evtq[evtID] = *evt; - count++; -} - -/**************************************************************************** -PARAMETERS: -what - Event code -message - Event message -modifiers - keyboard modifiers -x - Mouse X position at time of event -y - Mouse Y position at time of event -but_stat - Mouse button status at time of event - -REMARKS: -Adds a new mouse event to the event queue. This routine is called from -within the mouse interrupt subroutine, so it must be efficient. -****************************************************************************/ -static void addMouseEvent( - uint what, - uint message, - int x, - int y, - uint but_stat) -{ - WD_event evt; - - if (count < EVENTQSIZE) { - evt.what = what; - evt.when = getTimeStamp(); - evt.message = message; - evt.modifiers = but_stat | key_modifiers; - evt.where_x = x; - evt.where_y = y; - fprintf(stderr, "(%d,%d), buttons %ld\n", x,y, evt.modifiers); - addEvent(&evt); /* Add to tail of event queue */ - } -} - -/**************************************************************************** -PARAMETERS: -scancode - Raw keyboard scan code -modifiers - Keyboard modifiers flags - -REMARKS: -Converts the raw scan code into the appropriate ASCII code using the scan -code and the keyboard modifier flags. -****************************************************************************/ -static ulong getKeyMessage( - uint scancode, - ulong modifiers) -{ - ushort code = scancode << 8; - ushort ascii; - struct kbentry ke; - - ke.kb_index = scancode; - - /* Find the basic ASCII code for the scan code */ - if (modifiers & EVT_CAPSSTATE) { - if (modifiers & EVT_SHIFTKEY) - ke.kb_table = K_NORMTAB; - // ascii = tolower(keyTableShifted[scancode]); - else - ke.kb_table = K_SHIFTTAB; - // ascii = toupper(keyTable[scancode]); - } - else { - if (modifiers & EVT_SHIFTKEY) - ke.kb_table = K_SHIFTTAB; - // ascii = keyTableShifted[scancode]; - else - ke.kb_table = K_NORMTAB; - // ascii = keyTable[scancode]; - } - if(modifiers & EVT_ALTSTATE) - ke.kb_table |= K_ALTTAB; - - if (ioctl(tty_fd, KDGKBENT, (unsigned long)&ke)) { - fprintf(stderr, "KDGKBENT at index %d in table %d: ", - scancode, ke.kb_table); - return 0; - } - ascii = ke.kb_value; - - /* Add ASCII code if key is not alt'ed or ctrl'ed */ - if (!(modifiers & (EVT_ALTSTATE | EVT_CTRLSTATE))) - code |= ascii; - - return code; -} - -/**************************************************************************** -PARAMETERS: -what - Event code -scancode - Raw scancode of keyboard event to add - -REMARKS: -Adds a new keyboard event to the event queue. We only take KEYUP and -KEYDOWN event codes, however if a key is already down we convert the KEYDOWN -to a KEYREPEAT. -****************************************************************************/ -static void addKeyEvent( - uint what, - uint scancode) -{ - WD_event evt; - - if (count < EVENTQSIZE) { - evt.what = what; - evt.when = getTimeStamp(); - evt.message = getKeyMessage(scancode,key_modifiers) | 0x10000UL; - evt.where_x = evt.where_y = 0; - evt.modifiers = key_modifiers; - if (evt.what == EVT_KEYUP) - key_down[scancode] = false; - else if (evt.what == EVT_KEYDOWN) { - if (key_down[scancode]) { - if (oldKey != -1) { - evtq[oldKey].message += 0x10000UL; - } - else { - evt.what = EVT_KEYREPEAT; - oldKey = freeHead; - addEvent(&evt); - oldMove = -1; - } - return; - } - key_down[scancode] = true; - } - - addEvent(&evt); - oldMove = -1; - } -} - -/**************************************************************************** -PARAMETERS: -sig - Signal being sent to this signal handler - -REMARKS: -Signal handler for the timer. This routine takes care of periodically -posting timer events to the event queue. -****************************************************************************/ -void timerHandler( - int sig) -{ - WD_event evt; - - if (sig == SIGALRM) { - if (count < EVENTQSIZE) { - evt.when = getTimeStamp(); - evt.what = EVT_TIMERTICK; - evt.message = 0; - evt.where_x = evt.where_y = 0; - evt.modifiers = 0; - addEvent(&evt); - oldMove = -1; - oldKey = -1; - } - signal(SIGALRM, timerHandler); - } -} - -/**************************************************************************** -REMARKS: -Restore the terminal to normal operation on exit -****************************************************************************/ -static void restore_term(void) -{ - RMREGS regs; - - if (installed) { - /* Restore text mode and the state of the console */ - regs.x.ax = 0x3; - PM_int86(0x10,®s,®s); - PM_restoreConsoleState(stateBuf,tty_fd); - - /* Restore console to normal operation */ - ioctl(tty_fd, VT_SETMODE, &oldvtmode); - ioctl(tty_fd, KDSKBMODE, oldkbmode); - tcsetattr(tty_fd, TCSAFLUSH, &old_conf); - fcntl(tty_fd,F_SETFL,old_flags &= ~O_NONBLOCK); - PM_closeConsole(tty_fd); - - /* Close the mouse driver */ - close(conn); - - /* Flag that we are not no longer installed */ - installed = false; - } -} - -/**************************************************************************** -REMARKS: -Signal handler to capture forced program termination conditions so that -we can clean up properly. -****************************************************************************/ -static void exitHandler(int sig) -{ - exit(-1); -} - -/**************************************************************************** -REMARKS: -Sleep until the virtual terminal is active -****************************************************************************/ -void wait_vt_active(void) -{ - while (ioctl(tty_fd, VT_WAITACTIVE, tty_vc) < 0) { - if ((errno != EAGAIN) && (errno != EINTR)) { - perror("ioctl(VT_WAITACTIVE)"); - exit(1); - } - usleep(150000); - } -} - -/**************************************************************************** -REMARKS: -Signal handler called when our virtual terminal has been released and we are -losing the active focus. -****************************************************************************/ -static void release_vt_signal(int n) -{ - forbid_vt_acquire = 1; - if (forbid_vt_release) { - forbid_vt_acquire = 0; - ioctl(tty_fd, VT_RELDISP, 0); - return; - } - - // TODO: Call the user supplied suspendAppCallback and restore text - // mode (saving the existing mode so we can restore it). - // - // Also if the suspendAppCallback is NULL then we have to - // ignore the switch request! - if(suspendAppCallback){ - oldmode = VBE_getVideoMode(); - suspendAppCallback(true); - VBE_setVideoMode(initmode); - } - - ioctl(tty_fd, VT_RELDISP, 1); - forbid_vt_acquire = 0; - wait_vt_active(); -} - -/**************************************************************************** -REMARKS: -Signal handler called when our virtual terminal has been re-aquired and we -are now regaiing the active focus. -****************************************************************************/ -static void acquire_vt_signal(int n) -{ - forbid_vt_release = 1; - if (forbid_vt_acquire) { - forbid_vt_release = 0; - return; - } - - // TODO: Restore the old display mode, call the user suspendAppCallback - // and and we will be back in graphics mode. - - if(suspendAppCallback){ - VBE_setVideoMode(oldmode); - suspendAppCallback(false); - } - - ioctl(tty_fd, VT_RELDISP, VT_ACKACQ); - forbid_vt_release = 0; -} - -/**************************************************************************** -REMARKS: -Function to set the action for a specific signal to call our signal handler. -****************************************************************************/ -static void set_sigaction(int sig,void (*handler)(int)) -{ - struct sigaction siga; - - siga.sa_handler = handler; - siga.sa_flags = SA_RESTART; - memset(&(siga.sa_mask), 0, sizeof(sigset_t)); - sigaction(sig, &siga, NULL); -} - -/**************************************************************************** -REMARKS: -Function to take over control of VT switching so that we can capture -virtual terminal release and aquire signals, allowing us to properly -support VT switching while in graphics modes. -****************************************************************************/ -static void take_vt_control(void) -{ - struct vt_mode vtmode; - - ioctl(tty_fd, VT_GETMODE, &vtmode); - oldvtmode = vtmode; - vtmode.mode = VT_PROCESS; - vtmode.relsig = SIGUSR1; - vtmode.acqsig = SIGUSR2; - set_sigaction(SIGUSR1, release_vt_signal); - set_sigaction(SIGUSR2, acquire_vt_signal); - ioctl(tty_fd, VT_SETMODE, &oldvtmode); -} - -/**************************************************************************** -REMARKS: -Set the shift keyboard LED's based on the current keyboard modifiers flags. -****************************************************************************/ -static void updateLEDStatus(void) -{ - int state = 0; - if (key_modifiers & EVT_CAPSSTATE) - state |= LED_CAP; - if (key_modifiers & EVT_NUMSTATE) - state |= LED_NUM; - ioctl(tty_fd,KDSETLED,state); -} - -/**************************************************************************** -PARAMETERS: -scancode - Raw scan code to handle - -REMARKS: -Handles the shift key modifiers and keeps track of the shift key states -so that we can return the correct ASCII codes for the keyboard. -****************************************************************************/ -static void toggleModifiers( - int scancode) -{ - static int caps_down = 0,num_down = 0; - - if (scancode & 0x80) { - /* Handle key-release function */ - scancode &= 0x7F; - if (scancode == 0x2A || scancode == 0x36) - key_modifiers &= ~EVT_SHIFTKEY; - else if (scancode == 0x1D || scancode == 0x61) - key_modifiers &= ~EVT_CTRLSTATE; - else if (scancode == 0x38 || scancode == 0x64) - key_modifiers &= ~EVT_ALTSTATE; - else if (scancode == 0x3A) - caps_down = false; - else if (scancode == 0x45) - num_down = false; - } - else { - /* Handle key-down function */ - scancode &= 0x7F; - if (scancode == 0x2A || scancode == 0x36) - key_modifiers |= EVT_SHIFTKEY; - else if (scancode == 0x1D || scancode == 0x61) - key_modifiers |= EVT_CTRLSTATE; - else if (scancode == 0x38 || scancode == 0x64) - key_modifiers |= EVT_ALTSTATE; - else if (scancode == 0x3A) { - if (!caps_down) { - key_modifiers ^= EVT_CAPSSTATE; - updateLEDStatus(); - } - caps_down = true; - } - else if (scancode == 0x45) { - if (!num_down) { - key_modifiers ^= EVT_NUMSTATE; - updateLEDStatus(); - } - num_down = true; - } - } -} - -/*************************************************************************** -REMARKS: -Returns the number of bits that have changed from 0 to 1 -(a negative value means the number of bits that have changed from 1 to 0) - **************************************************************************/ -static int compareBits(short a, short b) -{ - int ret = 0; - if( (a&1) != (b&1) ) ret += (b&1) ? 1 : -1; - if( (a&2) != (b&2) ) ret += (b&2) ? 1 : -1; - if( (a&4) != (b&4) ) ret += (b&4) ? 1 : -1; - return ret; -} - -/*************************************************************************** -REMARKS: -Turns off all keyboard state because we can't rely on them anymore as soon -as we switch VT's -***************************************************************************/ -static void keyboard_clearstate(void) -{ - key_modifiers = 0; - memset(key_down, 0, sizeof(key_down)); -} - -/**************************************************************************** -REMARKS: -Pumps all events from the console event queue into the WinDirect event queue. -****************************************************************************/ -static void pumpEvents(void) -{ - static uchar buf[KBDREADBUFFERSIZE]; - static char data[5]; - static int old_buts, old_mx, old_my; - static struct timeval t; - fd_set fds; - int numkeys,i; - int dx, dy, buts; - - /* Read all pending keypresses from keyboard buffer and process */ - while ((numkeys = read(tty_fd, buf, KBDREADBUFFERSIZE)) > 0) { - for (i = 0; i < numkeys; i++) { - toggleModifiers(buf[i]); - if (key_modifiers & EVT_ALTSTATE){ - int fkey = 0; - - // Do VT switching here for Alt+Fx keypresses - switch(buf[i] & 0x7F){ - case 59 ... 68: /* F1 to F10 */ - fkey = (buf[i] & 0x7F) - 58; - break; - case 87: /* F11 */ - case 88: /* F12 */ - fkey = (buf[i] & 0x7F) - 76; - break; - } - if(fkey){ - struct vt_stat vts; - ioctl(tty_fd, VT_GETSTATE, &vts); - - if(fkey != vts.v_active){ - keyboard_clearstate(); - ioctl(tty_fd, VT_ACTIVATE, fkey); - } - } - } - - if (buf[i] & 0x80) - addKeyEvent(EVT_KEYUP,buf[i] & 0x7F); - else - addKeyEvent(EVT_KEYDOWN,buf[i] & 0x7F); - } - - // TODO: If we want to handle VC switching we will need to do it - // in here so that we can switch away from the VC and then - // switch back to it later. Right now VC switching is disabled - // and in order to enable it we need to save/restore the state - // of the graphics screen (using the suspendAppCallback and - // saving/restoring the state of the current display mode). - - } - - /* Read all pending mouse events and process them */ - if(conn > 0){ - FD_ZERO(&fds); - FD_SET(conn, &fds); - t.tv_sec = t.tv_usec = 0L; - while (select(conn+1, &fds, NULL, NULL, &t) > 0) { - if(read(conn, data, 5) == 5){ - buts = (~data[0]) & 0x07; - dx = (char)(data[1]) + (char)(data[3]); - dy = -((char)(data[2]) + (char)(data[4])); - - mx += dx; my += dy; - - if (dx || dy) - addMouseEvent(EVT_MOUSEMOVE, 0, mx, my, buts); - - if (buts != old_buts){ - int c = compareBits(buts,old_buts); - if(c>0) - addMouseEvent(EVT_MOUSEDOWN, 0, mx, my, buts); - else if(c<0) - addMouseEvent(EVT_MOUSEUP, 0, mx, my, buts); - } - old_mx = mx; old_my = my; - old_buts = buts; - FD_SET(conn, &fds); - t.tv_sec = t.tv_usec = 0L; - } - } - } -} - -/*------------------------ Public interface routines ----------------------*/ - -/**************************************************************************** -PARAMETERS: -which - Which code for event to post -what - Event code for event to post -message - Event message -modifiers - Shift key/mouse button modifiers - -RETURNS: -True if the event was posted, false if queue is full. - -REMARKS: -Posts an event to the event queue. This routine can be used to post any type -of event into the queue. -****************************************************************************/ -ibool _WDAPI WD_postEvent( - ulong which, - uint what, - ulong message, - ulong modifiers) -{ - WD_event evt; - - if (count < EVENTQSIZE) { - /* Save information in event record */ - evt.which = which; - evt.what = what; - evt.when = getTimeStamp(); - evt.message = message; - evt.modifiers = modifiers; - addEvent(&evt); /* Add to tail of event queue */ - return true; - } - else - return false; -} - -/**************************************************************************** -PARAMETERS: -mask - Event mask to use - -REMARKS: -Flushes all the event specified in 'mask' from the event queue. -****************************************************************************/ -void _WDAPI WD_flushEvent( - uint mask) -{ - WD_event evt; - - do { /* Flush all events */ - WD_getEvent(&evt,mask); - } while (evt.what != EVT_NULLEVT); -} - -/**************************************************************************** -PARAMETERS: -evt - Place to store event -mask - Event mask to use - -REMARKS: -Halts program execution until a specified event occurs. The event is -returned. All pending events not in the specified mask will be ignored and -removed from the queue. -****************************************************************************/ -void _WDAPI WD_haltEvent( - WD_event *evt, - uint mask) -{ - do { /* Wait for an event */ - WD_getEvent(evt,EVT_EVERYEVT); - } while (!(evt->what & mask)); -} - -/**************************************************************************** -PARAMETERS: -evt - Place to store event -mask - Event mask to use - -RETURNS: -True if an event was pending. - -REMARKS: -Retrieves the next pending event defined in 'mask' from the event queue. -The event queue is adjusted to reflect the new state after the event has -been removed. -****************************************************************************/ -ibool _WDAPI WD_getEvent( - WD_event *evt, - uint mask) -{ - int evtID,next,prev; - - pumpEvents(); - if (moveCursor) - moveCursor(mx,my); /* Move the mouse cursor */ - evt->what = EVT_NULLEVT; /* Default to null event */ - - if (count) { - for (evtID = head; evtID != -1; evtID = evtq[evtID].next) { - if (evtq[evtID].what & mask) - break; /* Found an event */ - } - if (evtID == -1) - return false; /* Event was not found */ - next = evtq[evtID].next; - prev = evtq[evtID].prev; - if (prev != -1) - evtq[prev].next = next; - else - head = next; - if (next != -1) - evtq[next].prev = prev; - else - tail = prev; - *evt = evtq[evtID]; /* Return the event */ - evtq[evtID].next = freeHead; /* and return to free list */ - freeHead = evtID; - count--; - if (evt->what == EVT_MOUSEMOVE) - oldMove = -1; - if (evt->what == EVT_KEYREPEAT) - oldKey = -1; - } - return evt->what != EVT_NULLEVT; -} - -/**************************************************************************** -PARAMETERS: -evt - Place to store event -mask - Event mask to use - -RETURNS: -True if an event is pending. - -REMARKS: -Peeks at the next pending event defined in 'mask' in the event queue. The -event is not removed from the event queue. -****************************************************************************/ -ibool _WDAPI WD_peekEvent( - WD_event *evt, - uint mask) -{ - int evtID; - - pumpEvents(); - if (moveCursor) - moveCursor(mx,my); /* Move the mouse cursor */ - evt->what = EVT_NULLEVT; /* Default to null event */ - - if (count) { - for (evtID = head; evtID != -1; evtID = evtq[evtID].next) { - if (evtq[evtID].what & mask) - break; /* Found an event */ - } - if (evtID == -1) - return false; /* Event was not found */ - - *evt = evtq[evtID]; /* Return the event */ - } - return evt->what != EVT_NULLEVT; -} - -/**************************************************************************** -PARAMETERS: -hwndMain - Handle to main window -_xRes - X resolution of graphics mode to be used -_yRes - Y resolulion of graphics mode to be used - -RETURNS: -Handle to the fullscreen event window if (we return hwndMain on Linux) - -REMARKS: -Initiliase the event handling module. Here we install our mouse handling -ISR to be called whenever any button's are pressed or released. We also -build the free list of events in the event queue. -****************************************************************************/ -WD_HWND _WDAPI WD_startFullScreen( - WD_HWND hwndMain, - int _xRes, - int _yRes) -{ - int i; - struct termios conf; - if (!installed) { - Gpm_Connect gpm; - - /* Build free list, and initialise global data structures */ - for (i = 0; i < EVENTQSIZE; i++) - evtq[i].next = i+1; - evtq[EVENTQSIZE-1].next = -1; /* Terminate list */ - count = freeHead = 0; - head = tail = -1; - oldMove = -1; - oldKey = -1; - xRes = _xRes; - yRes = _yRes; - - /* Open the console device and initialise it for raw mode */ - tty_fd = PM_openConsole(); - - /* Wait until virtual terminal is active and take over control */ - wait_vt_active(); - take_vt_control(); - - /* Initialise keyboard handling to raw mode */ - if (ioctl(tty_fd, KDGKBMODE, &oldkbmode)) { - printf("WD_startFullScreen: cannot get keyboard mode.\n"); - exit(-1); - } - old_flags = fcntl(tty_fd,F_GETFL); - fcntl(tty_fd,F_SETFL,old_flags |= O_NONBLOCK); - tcgetattr(tty_fd, &conf); - old_conf = conf; - conf.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL | NOFLSH | 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(tty_fd, TCSAFLUSH, &conf); - ioctl(tty_fd, KDSKBMODE, K_MEDIUMRAW); - - /* Clear the keyboard state information */ - memset(key_down, 0, sizeof(key_down)); - ioctl(tty_fd,KDSETLED,key_modifiers = 0); - - /* Initialize the mouse connection - The user *MUST* run gpm with the option -R for this to work (or have a MouseSystems mouse) - */ - if(Gpm_Open(&gpm,0) > 0){ /* GPM available */ - if ((conn = open(GPM_NODE_FIFO,O_RDONLY|O_SYNC)) < 0) - fprintf(stderr,"WD_startFullScreen: Can't open mouse connection.\n"); - }else{ - fprintf(stderr,"Warning: when not using gpm -R, only MouseSystems mice are currently supported.\n"); - if ((conn = open("/dev/mouse",O_RDONLY|O_SYNC)) < 0) - fprintf(stderr,"WD_startFullScreen: Can't open /dev/mouse.\n"); - } - Gpm_Close(); - - /* TODO: Scale the mouse coordinates to the specific resolution */ - - /* Save the state of the console */ - if ((stateBuf = malloc(PM_getConsoleStateSize())) == NULL) { - printf("Out of memory!\n"); - exit(-1); - } - PM_saveConsoleState(stateBuf,tty_fd); - initmode = VBE_getVideoMode(); - - /* Initialize the signal handler for timer events */ - signal(SIGALRM, timerHandler); - - /* Capture termination signals so we can clean up properly */ - signal(SIGTERM, exitHandler); - signal(SIGINT, exitHandler); - signal(SIGQUIT, exitHandler); - atexit(restore_term); - - /* Signal that we are installed */ - installed = true; - } - return hwndMain; -} - -/**************************************************************************** -REMARKS: -Lets the library know when fullscreen graphics mode has been initialized so -that we can properly scale the mouse driver coordinates. -****************************************************************************/ -void _WDAPI WD_inFullScreen(void) -{ - /* Nothing to do in here */ -} - -/**************************************************************************** -REMARKS: -Suspends all of our event handling operations. This is also used to -de-install the event handling code. -****************************************************************************/ -void _WDAPI WD_restoreGDI(void) -{ - restore_term(); -} - -/**************************************************************************** -PARAMETERS: -ticks - Number of ticks between timer tick messages - -RETURNS: -Previous value for the timer tick event spacing. - -REMARKS: -The event module will automatically generate periodic timer tick events for -you, with 'ticks' between each event posting. If you set the value of -'ticks' to 0, the timer tick events are turned off. -****************************************************************************/ -int _WDAPI WD_setTimerTick( - int ticks) -{ - int old; - struct itimerval tim; - long ms = TICKS_TO_USEC(ticks); - - getitimer(ITIMER_REAL, &tim); - old = USEC_TO_TICKS(tim.it_value.tv_sec*1000000.0 + tim.it_value.tv_usec); - tim.it_interval.tv_sec = ms / 1000000; - tim.it_interval.tv_usec = ms % 1000000; - setitimer(ITIMER_REAL, &tim, NULL); - return old; -} - -/**************************************************************************** -PARAMETERS: -saveState - Address of suspend app callback to register - -REMARKS: -Registers a user application supplied suspend application callback so that -we can properly handle virtual terminal switching. -****************************************************************************/ -void _WDAPI WD_setSuspendAppCallback( - int (_ASMAPI *saveState)(int flags)) -{ - suspendAppCallback = saveState; -} - -/**************************************************************************** -PARAMETERS: -x - New X coordinate to move the mouse cursor to -y - New Y coordinate to move the mouse cursor to - -REMARKS: -Moves to mouse cursor to the specified coordinate. -****************************************************************************/ -void _WDAPI WD_setMousePos( - int x, - int y) -{ - mx = x; - my = y; -} - -/**************************************************************************** -PARAMETERS: -x - Place to store X coordinate of mouse cursor -y - Place to store Y coordinate of mouse cursor - -REMARKS: -Reads the current mouse cursor location int *screen* coordinates. -****************************************************************************/ -void _WDAPI WD_getMousePos( - int *x, - int *y) -{ - *x = mx; - *y = my; -} - -/**************************************************************************** -PARAMETERS: -mcb - Address of mouse callback function - -REMARKS: -Registers an application supplied mouse callback function that is called -whenever the mouse cursor moves. -****************************************************************************/ -void _WDAPI WD_setMouseCallback( - void (_ASMAPI *mcb)(int x,int y)) -{ - moveCursor = mcb; -} - -/**************************************************************************** -PARAMETERS: -xRes - New X resolution of graphics mode -yRes - New Y resolution of graphics mode - -REMARKS: -This is called to inform the event handling code that the screen resolution -has changed so that the mouse coordinates can be scaled appropriately. -****************************************************************************/ -void _WDAPI WD_changeResolution( - int xRes, - int yRes) -{ - // Gpm_FitValues(xRes, yRes); // ?? -} - -/**************************************************************************** -PARAMETERS: -scancode - Scan code to check if a key is down - -REMARKS: -Determines if a particular key is down based on the scan code for the key. -****************************************************************************/ -ibool _WDAPI WD_isKeyDown( - uchar scancode) -{ - return key_down[scancode]; -} - -/**************************************************************************** -REMARKS: -Determines if the application needs to run in safe mode. Not necessary for -anything but broken Windows 95 display drivers so we return false for -Linux. -****************************************************************************/ -int _WDAPI WD_isSafeMode(void) -{ - return false; -} - - diff --git a/board/MAI/bios_emulator/scitech/src/pm/linux/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/linux/oshdr.h deleted file mode 100644 index eadedfb137..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/linux/oshdr.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -* -* SciTech Multi-platform Graphics Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Linux -* -* Description: Include all the OS specific header files. -* -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef USE_OS_JOYSTICK -#include -#endif -#include -#include -#include -#include -#include - -/* Internal global variables */ - -extern int _PM_console_fd,_PM_leds,_PM_modifiers; - -/* Internal function prototypes */ - -void _PM_restore_kb_mode(void); -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 deleted file mode 100644 index c12a83500a..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/linux/pm.c +++ /dev/null @@ -1,1809 +0,0 @@ -;/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Portions copyright (C) Josh Vanderhoof -* -* Language: ANSI C -* Environment: Linux -* -* Description: Implementation for the OS Portability Manager Library, which -* contains functions to implement OS specific services in a -* generic, cross platform API. Porting the OS Portability -* Manager library is the first step to porting any SciTech -* products to a new platform. -* -****************************************************************************/ - -#include "pmapi.h" -#include "drvlib/os/os.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef ENABLE_MTRR -#include -#endif -#include -#ifdef __GLIBC__ -#include -#endif - -/*--------------------------- Global variables ----------------------------*/ - -#define REAL_MEM_BASE ((void *)0x10000) -#define REAL_MEM_SIZE 0x10000 -#define REAL_MEM_BLOCKS 0x100 -#define DEFAULT_VM86_FLAGS (IF_MASK | IOPL_MASK) -#define DEFAULT_STACK_SIZE 0x1000 -#define RETURN_TO_32_INT 255 - -/* Quick and dirty fix for vm86() syscall from lrmi 0.6 */ -static int -vm86(struct vm86_struct *vm) - { - int r; -#ifdef __PIC__ - asm volatile ( - "pushl %%ebx\n\t" - "movl %2, %%ebx\n\t" - "int $0x80\n\t" - "popl %%ebx" - : "=a" (r) - : "0" (113), "r" (vm)); -#else - asm volatile ( - "int $0x80" - : "=a" (r) - : "0" (113), "b" (vm)); -#endif - return r; - } - - -static struct { - int ready; - unsigned short ret_seg, ret_off; - unsigned short stack_seg, stack_off; - struct vm86_struct vm; - } context = {0}; - -struct mem_block { - unsigned int size : 20; - unsigned int free : 1; - }; - -static struct { - int ready; - int count; - struct mem_block blocks[REAL_MEM_BLOCKS]; - } mem_info = {0}; - -int _PM_console_fd = -1; -int _PM_leds = 0,_PM_modifiers = 0; -static ibool inited = false; -static int tty_vc = 0; -static int console_count = 0; -static int startup_vc; -static int fd_mem = 0; -static ibool in_raw_mode = false; -#ifdef ENABLE_MTRR -static int mtrr_fd; -#endif -static uint VESABuf_len = 1024; /* Length of the VESABuf buffer */ -static void *VESABuf_ptr = NULL; /* Near pointer to VESABuf */ -static uint VESABuf_rseg; /* Real mode segment of VESABuf */ -static uint VESABuf_roff; /* Real mode offset of VESABuf */ -#ifdef TRACE_IO -static ulong traceAddr; -#endif - -static void (PMAPIP fatalErrorCleanup)(void) = NULL; - -/*----------------------------- Implementation ----------------------------*/ - -#ifdef TRACE_IO -extern void printk(char *msg,...); -#endif - -static inline void port_out(int value, int port) -{ -#ifdef TRACE_IO - 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)); -} - -static inline void port_outw(int value, int port) -{ -#ifdef TRACE_IO - 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)); -} - -static inline void port_outl(int value, int port) -{ -#ifdef TRACE_IO - 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)); -} - -static inline unsigned int port_in(int port) -{ - unsigned char value; - asm volatile ("inb %1,%0" - :"=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 - return value; -} - -static inline unsigned int port_inw(int port) -{ - unsigned short value; - asm volatile ("inw %1,%0" - :"=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 - return value; -} - -static inline unsigned int port_inl(int port) -{ - unsigned long value; - asm volatile ("inl %1,%0" - :"=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 - return value; -} - -static int real_mem_init(void) -{ - void *m; - int fd_zero; - - if (mem_info.ready) - return 1; - - if ((fd_zero = open("/dev/zero", O_RDONLY)) == -1) - 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!"); - } - mem_info.ready = 1; - mem_info.count = 1; - mem_info.blocks[0].size = REAL_MEM_SIZE; - mem_info.blocks[0].free = 1; - return 1; -} - -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.count++; -} - -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)); -} - -static inline void set_bit(unsigned int bit, void *array) -{ - unsigned char *a = array; - a[bit / 8] |= (1 << (bit % 8)); -} - -static inline unsigned int get_int_seg(int i) -{ - return *(unsigned short *)(i * 4 + 2); -} - -static inline unsigned int get_int_off(int i) -{ - return *(unsigned short *)(i * 4); -} - -static inline void pushw(unsigned short i) -{ - struct vm86_regs *r = &context.vm.regs; - r->esp -= 2; - *(unsigned short *)(((unsigned int)r->ss << 4) + r->esp) = i; -} - -ibool PMAPI PM_haveBIOSAccess(void) -{ return true; } - -void PMAPI PM_init(void) -{ - void *m; - uint r_seg,r_off; - - if (inited) - 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!"); - } - 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!"); - } - 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!"); - } - 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!"); - } - 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!"); - } - inited = 1; - - /* Allocate a stack */ - m = PM_allocRealSeg(DEFAULT_STACK_SIZE,&r_seg,&r_off); - context.stack_seg = r_seg; - context.stack_off = r_off+DEFAULT_STACK_SIZE; - - /* Allocate the return to 32 bit routine */ - m = PM_allocRealSeg(2,&r_seg,&r_off); - context.ret_seg = r_seg; - context.ret_off = r_off; - ((uchar*)m)[0] = 0xCD; /* int opcode */ - ((uchar*)m)[1] = RETURN_TO_32_INT; - memset(&context.vm, 0, sizeof(context.vm)); - - /* Enable kernel emulation of all ints except RETURN_TO_32_INT */ - memset(&context.vm.int_revectored, 0, sizeof(context.vm.int_revectored)); - set_bit(RETURN_TO_32_INT, &context.vm.int_revectored); - context.ready = 1; -#ifdef ENABLE_MTRR - mtrr_fd = open("/dev/cpu/mtrr", O_RDWR, 0); - if (mtrr_fd < 0) - mtrr_fd = open("/proc/mtrr", O_RDWR, 0); -#endif - /* Enable I/O permissions to directly access I/O ports. We break the - * allocation into two parts, one for the ports from 0-0x3FF and - * another for the remaining ports up to 0xFFFF. Standard Linux kernels - * only allow the first 0x400 ports to be enabled, so to enable all - * 65536 ports you need a patched kernel that will enable the full - * 8Kb I/O permissions bitmap. - */ -#ifndef TRACE_IO - ioperm(0x0,0x400,1); - ioperm(0x400,0x10000-0x400,1); -#endif - iopl(3); -} - -long PMAPI PM_getOSType(void) -{ return _OS_LINUX; } - -int PMAPI PM_getModeType(void) -{ return PM_386; } - -void PMAPI PM_backslash(char *s) -{ - uint pos = strlen(s); - if (s[pos-1] != '/') { - s[pos] = '/'; - s[pos+1] = '\0'; - } -} - -void PMAPI PM_setFatalErrorCleanup( - void (PMAPIP cleanup)(void)) -{ - fatalErrorCleanup = cleanup; -} - -void PMAPI PM_fatalError(const char *msg) -{ - if (fatalErrorCleanup) - fatalErrorCleanup(); - fprintf(stderr,"%s\n", msg); - fflush(stderr); - exit(1); -} - -static void ExitVBEBuf(void) -{ - if (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); - } - *len = VESABuf_len; - *rseg = VESABuf_rseg; - *roff = VESABuf_roff; - return VESABuf_ptr; -} - -/* New raw console based getch and kbhit functions */ - -#define KB_CAPS LED_CAP /* 4 */ -#define KB_NUMLOCK LED_NUM /* 2 */ -#define KB_SCROLL LED_SCR /* 1 */ -#define KB_SHIFT 8 -#define KB_CONTROL 16 -#define KB_ALT 32 - -/* Structure used to save the keyboard mode to disk. We save it to disk - * so that we can properly restore the mode later if the program crashed. - */ - -typedef struct { - struct termios termios; - int kb_mode; - int leds; - int flags; - int startup_vc; - } keyboard_mode; - -/* Name of the file used to save keyboard mode information */ - -#define KBMODE_DAT "kbmode.dat" - -/**************************************************************************** -REMARKS: -Open the keyboard mode file on disk. -****************************************************************************/ -static FILE *open_kb_mode( - char *mode, - char *path) -{ - if (!PM_findBPD("graphics.bpd",path)) - return NULL; - PM_backslash(path); - strcat(path,KBMODE_DAT); - return fopen(path,mode); -} - -/**************************************************************************** -REMARKS: -Restore the keyboard to normal mode -****************************************************************************/ -void _PM_restore_kb_mode(void) -{ - FILE *kbmode; - keyboard_mode mode; - 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; - } -} - -/**************************************************************************** -REMARKS: -Safely abort the event module upon catching a fatal error. -****************************************************************************/ -void _PM_abort( - int signo) -{ - char buf[80]; - - sprintf(buf,"Terminating on signal %d",signo); - _PM_restore_kb_mode(); - PM_fatalError(buf); -} - -/**************************************************************************** -REMARKS: -Put the keyboard into raw mode -****************************************************************************/ -void _PM_keyboard_rawmode(void) -{ - struct termios conf; - FILE *kbmode; - keyboard_mode mode; - char path[PM_MAX_PATH]; - int i; - static int sig_list[] = { - 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; - } -} - -int PMAPI PM_kbhit(void) -{ - fd_set s; - struct timeval tv = { 0, 0 }; - - if (console_count == 0) - PM_fatalError("You *must* open a console before using PM_kbhit!"); - if (!in_raw_mode) - _PM_keyboard_rawmode(); - FD_ZERO(&s); - FD_SET(_PM_console_fd, &s); - return select(_PM_console_fd+1, &s, NULL, NULL, &tv) > 0; -} - -int PMAPI PM_getch(void) -{ - static uchar c; - int release; - static struct kbentry ke; - - if (console_count == 0) - PM_fatalError("You *must* open a console before using PM_getch!"); - if (!in_raw_mode) - _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; - } - } - return 0; -} - -/**************************************************************************** -REMARKS: -Sleep until the virtual terminal is active -****************************************************************************/ -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); - } -} - -/**************************************************************************** -REMARKS: -Checks the owner of the specified virtual console. -****************************************************************************/ -static int check_owner( - int vc) -{ - struct stat sbuf; - char fname[30]; - - sprintf(fname, "/dev/tty%d", vc); - if ((stat(fname, &sbuf) >= 0) && (getuid() == sbuf.st_uid)) - return 1; - printf("You must be the owner of the current console to use this program.\n"); - return 0; -} - -/**************************************************************************** -REMARKS: -Checks if the console is currently in graphics mode, and if so we forcibly -restore it back to text mode again. This handles the case when a Nucleus or -MGL program crashes and leaves the console in graphics mode. Running the -textmode utility (or any other Nucleus/MGL program) via a telnet session -into the machine will restore it back to normal. -****************************************************************************/ -static void restore_text_console( - int console_id) -{ - if (ioctl(console_id, KDSETMODE, KD_TEXT) < 0) - LOGWARN("ioctl(KDSETMODE) failed"); - _PM_restore_kb_mode(); -} - -/**************************************************************************** -REMARKS: -Opens up the console device for output by finding an appropriate virutal -console that we can run on. -****************************************************************************/ -PM_HWND PMAPI PM_openConsole( - PM_HWND hwndUser, - int device, - int xRes, - int yRes, - int bpp, - ibool fullScreen) -{ - struct vt_mode vtm; - struct vt_stat vts; - struct stat sbuf; - char fname[30]; - - /* Check if we have already opened the console */ - if (console_count++) - 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 - * bound to. Thus we parse stdin through stderr for a reliable VC. - */ - 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 ((_PM_console_fd = open("/dev/console", O_RDWR)) < 0) { - printf("open_dev_console: can't open /dev/console \n"); - exit(1); - } - if (ioctl(_PM_console_fd, VT_OPENQRY, &tty_vc) < 0) - goto Error; - if (tty_vc <= 0) - goto Error; - sprintf(fname, "/dev/tty%d", tty_vc); - close(_PM_console_fd); - - /* Change our control terminal */ - setsid(); - - /* 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); - } - } - return _PM_console_fd; - -Error: - if (_PM_console_fd > 2) - close(_PM_console_fd); - console_count = 0; - PM_fatalError( - "Not running in a graphics capable console,\n" - "and unable to find one.\n"); - return -1; -} - -#define FONT_C 0x10000 /* 64KB for font data */ - -/**************************************************************************** -REMARKS: -Returns the size of the console state buffer. -****************************************************************************/ -int PMAPI PM_getConsoleStateSize(void) -{ - if (!inited) - PM_init(); - return PM_getVGAStateSize() + FONT_C*2; -} - -/**************************************************************************** -REMARKS: -Save the state of the Linux console. -****************************************************************************/ -void PMAPI PM_saveConsoleState(void *stateBuf,int console_id) -{ - uchar *regs = stateBuf; - - /* Save the current console font */ - if (ioctl(console_id,GIO_FONT,®s[PM_getVGAStateSize()]) < 0) - 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)"); - - /* Save state of VGA registers */ - PM_saveVGAState(stateBuf); -} - -void PMAPI PM_setSuspendAppCallback(int (_ASMAPIP saveState)(int flags)) -{ - /* TODO: Implement support for allowing console switching! */ -} - -/**************************************************************************** -REMARKS: -Restore the state of the Linux console. -****************************************************************************/ -void PMAPI PM_restoreConsoleState(const void *stateBuf,PM_HWND console_id) -{ - const uchar *regs = stateBuf; - - /* Restore the state of the VGA compatible registers */ - PM_restoreVGAState(stateBuf); - - /* Inform the Linux console that we are back from graphics modes */ - if (ioctl(console_id, KDSETMODE, KD_TEXT) < 0) - LOGWARN("ioctl(KDSETMODE) failed"); - - /* Restore the old console font */ - if (ioctl(console_id,PIO_FONT,®s[PM_getVGAStateSize()]) < 0) - 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 - * around this since the cursor does not get homed by our code. - */ - fflush(stdout); - fflush(stderr); - printf("\033[H\033[J"); - fflush(stdout); -} - -/**************************************************************************** -REMARKS: -Close the Linux console and put it back to normal. -****************************************************************************/ -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); - - /* 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) -{ - /* Nothing to do in here */ -} - -/**************************************************************************** -REMARKS: -Set the screen width and height for the Linux console. -****************************************************************************/ -void PM_setOSScreenWidth(int width,int height) -{ - struct winsize ws; - struct vt_sizes vs; - - /* Resize the software terminal */ - ws.ws_col = width; - ws.ws_row = height; - ioctl(_PM_console_fd, TIOCSWINSZ, &ws); - - /* And the hardware */ - vs.v_rows = height; - vs.v_cols = width; - vs.v_scrollsize = 0; - ioctl(_PM_console_fd, VT_RESIZE, &vs); -} - -ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler ih, int frequency) -{ - /* TODO: Implement this for Linux */ - return false; -} - -void PMAPI PM_setRealTimeClockFrequency(int frequency) -{ - /* TODO: Implement this for Linux */ -} - -void PMAPI PM_restoreRealTimeClockHandler(void) -{ - /* TODO: Implement this for Linux */ -} - -char * PMAPI PM_getCurrentPath( - char *path, - int maxLen) -{ - return getcwd(path,maxLen); -} - -char PMAPI PM_getBootDrive(void) -{ return '/'; } - -const char * PMAPI PM_getVBEAFPath(void) -{ return PM_getNucleusConfigPath(); } - -const char * PMAPI PM_getNucleusPath(void) -{ - char *env = getenv("NUCLEUS_PATH"); - return env ? env : "/usr/lib/nucleus"; -} - -const char * PMAPI PM_getNucleusConfigPath(void) -{ - static char path[256]; - strcpy(path,PM_getNucleusPath()); - PM_backslash(path); - strcat(path,"config"); - return path; -} - -const char * PMAPI PM_getUniqueID(void) -{ - static char buf[128]; - gethostname(buf, 128); - return buf; -} - -const char * PMAPI PM_getMachineName(void) -{ - static char buf[128]; - gethostname(buf, 128); - return buf; -} - -void * PMAPI PM_getBIOSPointer(void) -{ - static uchar *zeroPtr = NULL; - if (!zeroPtr) - zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF,true); - return (void*)(zeroPtr + 0x400); -} - -void * PMAPI PM_getA0000Pointer(void) -{ - /* PM_init maps in the 0xA0000 framebuffer region 1:1 with our - * address mapping, so we can return the address here. - */ - if (!inited) - PM_init(); - return (void*)(0xA0000); -} - -void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) -{ - uchar *p; - ulong baseAddr,baseOfs; - - if (!inited) - PM_init(); - if (base >= 0xA0000 && base < 0x100000) - return (void*)base; - if (!fd_mem && (fd_mem = open("/dev/mem", O_RDWR)) == -1) - 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 - * physical address, then we also add an extra offset into the address - * that we return. - */ - baseOfs = base & 4095; - 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; - return (void*)(p+baseOfs); -} - -void PMAPI PM_freePhysicalAddr(void *ptr,ulong limit) -{ - if ((ulong)ptr >= 0x100000) - munmap(ptr,limit+1); -} - -ulong PMAPI PM_getPhysicalAddr(void *p) -{ - /* 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. */ - return false; -} - -void PMAPI PM_sleep(ulong 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. */ - switch (port) { - 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. */ - switch (port) { - case 0: return 0x3BC; - case 1: return 0x378; - case 2: return 0x278; - } - return 0; -} - -void * PMAPI PM_mallocShared(long size) -{ - return PM_malloc(size); -} - -void PMAPI PM_freeShared(void *ptr) -{ - PM_free(ptr); -} - -void * PMAPI PM_mapToProcess(void *base,ulong limit) -{ return (void*)base; } - -void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) -{ - /* PM_init maps in the 0xA0000-0x100000 region 1:1 with our - * address mapping, as well as all memory blocks in a 1:1 address - * mapping so we can simply return the physical address in here. - */ - if (!inited) - PM_init(); - return (void*)MK_PHYS(r_seg,r_off); -} - -void * PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off) -{ - int i; - char *r = (char *)REAL_MEM_BASE; - - if (!inited) - PM_init(); - if (!mem_info.ready) - return NULL; - if (mem_info.count == REAL_MEM_BLOCKS) - 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; - } - return NULL; -} - -void PMAPI PM_freeRealSeg(void *mem) -{ - int i; - char *r = (char *)REAL_MEM_BASE; - - if (!mem_info.ready) - return; - i = 0; - while (mem != (void *)r) { - 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); - } - if (i - 1 >= 0 && mem_info.blocks[i - 1].free) { - mem_info.blocks[i - 1].size += mem_info.blocks[i].size; - delete_block(i); - } -} - -#define DIRECTION_FLAG (1 << 10) - -static void em_ins(int size) -{ - unsigned int edx, edi; - - edx = context.vm.regs.edx & 0xffff; - 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)); - } - 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)); - } - edi -= (unsigned int)context.vm.regs.ds << 4; - context.vm.regs.edi &= 0xffff0000; - context.vm.regs.edi |= edi & 0xffff; -} - -static void em_rep_ins(int size) -{ - unsigned int ecx, edx, edi; - - ecx = context.vm.regs.ecx & 0xffff; - edx = context.vm.regs.edx & 0xffff; - 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)); - } - 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)); - } - - edi -= (unsigned int)context.vm.regs.ds << 4; - context.vm.regs.edi &= 0xffff0000; - context.vm.regs.edi |= edi & 0xffff; - context.vm.regs.ecx &= 0xffff0000; - context.vm.regs.ecx |= ecx & 0xffff; -} - -static void em_outs(int size) -{ - unsigned int edx, esi; - - edx = context.vm.regs.edx & 0xffff; - 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)); - } - 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)); - } - - esi -= (unsigned int)context.vm.regs.ds << 4; - context.vm.regs.esi &= 0xffff0000; - context.vm.regs.esi |= esi & 0xffff; -} - -static void em_rep_outs(int size) -{ - unsigned int ecx, edx, esi; - - ecx = context.vm.regs.ecx & 0xffff; - edx = context.vm.regs.edx & 0xffff; - 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)); - } - 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)); - } - - esi -= (unsigned int)context.vm.regs.ds << 4; - context.vm.regs.esi &= 0xffff0000; - context.vm.regs.esi |= esi & 0xffff; - context.vm.regs.ecx &= 0xffff0000; - context.vm.regs.ecx |= ecx & 0xffff; -} - -static int emulate(void) -{ - unsigned char *insn; - struct { - unsigned int size : 1; - unsigned int rep : 1; - } prefix = { 0, 0 }; - int i = 0; - - insn = (unsigned char *)((unsigned int)context.vm.regs.cs << 4); - insn += context.vm.regs.eip; - - while (1) { -#ifdef TRACE_IO - 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; - } - - context.vm.regs.eip += i; - return 1; -} - -static void debug_info(int vret) -{ - int i; - unsigned char *p; - - fputs("vm86() failed\n", stderr); - fprintf(stderr, "return = 0x%x\n", vret); - fprintf(stderr, "eax = 0x%08lx\n", context.vm.regs.eax); - fprintf(stderr, "ebx = 0x%08lx\n", context.vm.regs.ebx); - fprintf(stderr, "ecx = 0x%08lx\n", context.vm.regs.ecx); - fprintf(stderr, "edx = 0x%08lx\n", context.vm.regs.edx); - fprintf(stderr, "esi = 0x%08lx\n", context.vm.regs.esi); - fprintf(stderr, "edi = 0x%08lx\n", context.vm.regs.edi); - fprintf(stderr, "ebp = 0x%08lx\n", context.vm.regs.ebp); - fprintf(stderr, "eip = 0x%08lx\n", context.vm.regs.eip); - fprintf(stderr, "cs = 0x%04x\n", context.vm.regs.cs); - fprintf(stderr, "esp = 0x%08lx\n", context.vm.regs.esp); - fprintf(stderr, "ss = 0x%04x\n", context.vm.regs.ss); - fprintf(stderr, "ds = 0x%04x\n", context.vm.regs.ds); - fprintf(stderr, "es = 0x%04x\n", context.vm.regs.es); - fprintf(stderr, "fs = 0x%04x\n", context.vm.regs.fs); - fprintf(stderr, "gs = 0x%04x\n", context.vm.regs.gs); - fprintf(stderr, "eflags = 0x%08lx\n", context.vm.regs.eflags); - 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]); - fputs("]\n", stderr); - fflush(stderr); -} - -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; - } - debug_info(vret); - return 0; -} - -#define IND(ereg) context.vm.regs.ereg = regs->ereg -#define OUTD(ereg) regs->ereg = context.vm.regs.ereg - -void PMAPI DPMI_int86(int intno, DPMI_regs *regs) -{ - if (!inited) - 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; - context.vm.regs.cs = get_int_seg(intno); - context.vm.regs.eip = get_int_off(intno); - 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(); - OUTD(eax); OUTD(ebx); OUTD(ecx); OUTD(edx); OUTD(esi); OUTD(edi); - regs->flags = context.vm.regs.eflags; -} - -#define IN(ereg) context.vm.regs.ereg = in->e.ereg -#define OUT(ereg) out->e.ereg = context.vm.regs.ereg - -int PMAPI PM_int86(int intno, RMREGS *in, RMREGS *out) -{ - if (!inited) - 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; - context.vm.regs.cs = get_int_seg(intno); - context.vm.regs.eip = get_int_off(intno); - 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); - out->x.cflag = context.vm.regs.eflags & 1; - return out->x.ax; -} - -int PMAPI PM_int86x(int intno, RMREGS *in, RMREGS *out, - RMSREGS *sregs) -{ - if (!inited) - 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; - } - 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; - } - return out->e.eax; -} - -#define OUTR(ereg) in->e.ereg = context.vm.regs.ereg - -void PMAPI PM_callRealMode(uint seg,uint off, RMREGS *in, - RMSREGS *sregs) -{ - if (!inited) - 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; - context.vm.regs.cs = seg; - context.vm.regs.eip = off; - context.vm.regs.ss = context.stack_seg; - context.vm.regs.esp = context.stack_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; - pushw(DEFAULT_VM86_FLAGS); - pushw(context.ret_seg); - pushw(context.ret_off); - run_vm86(); - OUTR(eax); OUTR(ebx); OUTR(ecx); OUTR(edx); OUTR(esi); OUTR(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; - in->x.cflag = context.vm.regs.eflags & 1; -} - -void PMAPI PM_availableMemory(ulong *physical,ulong *total) -{ - FILE *mem = fopen("/proc/meminfo","r"); - char buf[1024]; - - fgets(buf,1024,mem); - fgets(buf,1024,mem); - sscanf(buf,"Mem: %*d %*d %ld", physical); - fgets(buf,1024,mem); - sscanf(buf,"Swap: %*d %*d %ld", total); - fclose(mem); - *total += *physical; -} - -void * PMAPI PM_allocLockedMem(uint size,ulong *physAddr,ibool contiguous,ibool below16M) -{ - /* TODO: Implement this for Linux */ - return NULL; -} - -void PMAPI PM_freeLockedMem(void *p,uint size,ibool contiguous) -{ - /* TODO: Implement this for Linux */ -} - -void * PMAPI PM_allocPage( - ibool locked) -{ - /* TODO: Implement this for Linux */ - return NULL; -} - -void PMAPI PM_freePage( - void *p) -{ - /* TODO: Implement this for Linux */ -} - -void PMAPI PM_setBankA(int bank) -{ - if (!inited) - PM_init(); - memset(&context.vm.regs, 0, sizeof(context.vm.regs)); - context.vm.regs.eax = 0x4F05; - context.vm.regs.ebx = 0x0000; - context.vm.regs.edx = bank; - context.vm.regs.eflags = DEFAULT_VM86_FLAGS; - context.vm.regs.cs = get_int_seg(0x10); - context.vm.regs.eip = get_int_off(0x10); - 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(); -} - -void PMAPI PM_setBankAB(int bank) -{ - if (!inited) - PM_init(); - memset(&context.vm.regs, 0, sizeof(context.vm.regs)); - context.vm.regs.eax = 0x4F05; - context.vm.regs.ebx = 0x0000; - context.vm.regs.edx = bank; - context.vm.regs.eflags = DEFAULT_VM86_FLAGS; - context.vm.regs.cs = get_int_seg(0x10); - context.vm.regs.eip = get_int_off(0x10); - 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(); - context.vm.regs.eax = 0x4F05; - context.vm.regs.ebx = 0x0001; - context.vm.regs.edx = bank; - context.vm.regs.eflags = DEFAULT_VM86_FLAGS; - context.vm.regs.cs = get_int_seg(0x10); - context.vm.regs.eip = get_int_off(0x10); - 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(); -} - -void PMAPI PM_setCRTStart(int x,int y,int waitVRT) -{ - if (!inited) - PM_init(); - memset(&context.vm.regs, 0, sizeof(context.vm.regs)); - context.vm.regs.eax = 0x4F07; - context.vm.regs.ebx = waitVRT; - context.vm.regs.ecx = x; - context.vm.regs.edx = y; - context.vm.regs.eflags = DEFAULT_VM86_FLAGS; - context.vm.regs.cs = get_int_seg(0x10); - context.vm.regs.eip = get_int_off(0x10); - 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(); -} - -int PMAPI PM_enableWriteCombine(ulong base,ulong length,uint type) -{ -#ifdef ENABLE_MTRR - struct mtrr_sentry sentry; - - if (mtrr_fd < 0) - 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; - } - return PM_MTRR_ERR_OK; -#else - return PM_MTRR_ERR_NO_OS_SUPPORT; -#endif -} - -/**************************************************************************** -PARAMETERS: -callback - Function to callback with write combine information - -REMARKS: -Function to enumerate all write combine regions currently enabled for the -processor. -****************************************************************************/ -int PMAPI PM_enumWriteCombine( - PM_enumWriteCombine_t callback) -{ -#ifdef ENABLE_MTRR - struct mtrr_gentry gentry; - - if (mtrr_fd < 0) - 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); - } - } - - return PM_MTRR_ERR_OK; -#else - return PM_MTRR_ERR_NO_OS_SUPPORT; -#endif -} - -ibool PMAPI PM_doBIOSPOST( - ushort axVal, - ulong BIOSPhysAddr, - void *copyOfBIOS, - ulong BIOSLen) -{ - char *bios_ptr = (char*)0xC0000; - char *old_bios; - ulong Current10, Current6D, *rvec = 0; - RMREGS regs; - RMSREGS sregs; - - /* The BIOS is mapped to 0xC0000 with a private memory mapping enabled - * which means we have a copy on write scheme. Hence we simply copy - * the secondary BIOS image over the top of the old one. - */ - if (!inited) - PM_init(); - if ((old_bios = PM_malloc(BIOSLen)) == NULL) - return false; - if (BIOSPhysAddr != 0xC0000) { - 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]; - Current6D = rvec[0x6D]; - - /* POST the secondary BIOS */ - rvec[0x10] = rvec[0x42]; /* Restore int 10h to STD-BIOS */ - regs.x.ax = axVal; - PM_callRealMode(0xC000,0x0003,®s,&sregs); - - /* Restore interrupt vectors */ - rvec[0x10] = Current10; - rvec[0x6D] = Current6D; - - /* Restore original BIOS image */ - if (BIOSPhysAddr != 0xC0000) - memcpy(bios_ptr,old_bios,BIOSLen); - PM_free(old_bios); - return true; -} - -int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - p = p; len = len; - return 1; -} - -int PMAPI PM_unlockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - p = p; len = len; - return 1; -} - -int PMAPI PM_lockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - p = p; len = len; - return 1; -} - -int PMAPI PM_unlockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - p = p; len = len; - return 1; -} - -PM_MODULE PMAPI PM_loadLibrary( - const char *szDLLName) -{ - /* TODO: Implement this to load shared libraries! */ - (void)szDLLName; - return NULL; -} - -void * PMAPI PM_getProcAddress( - PM_MODULE hModule, - const char *szProcName) -{ - /* TODO: Implement this! */ - (void)hModule; - (void)szProcName; - return NULL; -} - -void PMAPI PM_freeLibrary( - PM_MODULE hModule) -{ - /* TODO: Implement this! */ - (void)hModule; -} - -int PMAPI PM_setIOPL( - int level) -{ - /* TODO: Move the IOPL switching into this function!! */ - return level; -} - -void PMAPI PM_flushTLB(void) -{ - /* Do nothing on Linux. */ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/linux/vflat.c b/board/MAI/bios_emulator/scitech/src/pm/linux/vflat.c deleted file mode 100644 index 579ef2c95c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/linux/vflat.c +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Dummy module; no virtual framebuffer for this OS -* -****************************************************************************/ - -#include "pmapi.h" - -ibool PMAPI VF_available(void) -{ - return false; -} - -void * PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) -{ - baseAddr = baseAddr; - bankSize = bankSize; - codeLen = codeLen; - bankFunc = bankFunc; - return NULL; -} - -void PMAPI VF_exit(void) -{ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/linux/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/linux/ztimer.c deleted file mode 100644 index 1b9bae28a6..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/linux/ztimer.c +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Linux -* -* Description: Linux specific implementation for the Zen Timer functions. -* -****************************************************************************/ - -#include -#include -#include "pmapi.h" - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Initialise the Zen Timer module internals. -****************************************************************************/ -void __ZTimerInit(void) -{ -} - -/**************************************************************************** -REMARKS: -Use the gettimeofday() function to get microsecond precision (probably less -though) -****************************************************************************/ -static inline ulong __ULZReadTime(void) -{ - struct timeval t; - gettimeofday(&t, NULL); - return t.tv_sec*1000000 + t.tv_usec; -} - -/**************************************************************************** -REMARKS: -Start the Zen Timer counting. -****************************************************************************/ -#define __LZTimerOn(tm) tm->start.low = __ULZReadTime() - -/**************************************************************************** -REMARKS: -Compute the lap time since the timer was started. -****************************************************************************/ -#define __LZTimerLap(tm) (__ULZReadTime() - tm->start.low) - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerOff(tm) tm->end.low = __ULZReadTime() - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerCount(tm) (tm->end.low - tm->start.low) - -/**************************************************************************** -REMARKS: -Define the resolution of the long period timer as microseconds per timer tick. -****************************************************************************/ -#define ULZTIMER_RESOLUTION 1 - -/**************************************************************************** -REMARKS: -Compute the elapsed time from the BIOS timer tick. Note that we check to see -whether a midnight boundary has passed, and if so adjust the finish time to -account for this. We cannot detect if more that one midnight boundary has -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/makefile b/board/MAI/bios_emulator/scitech/src/pm/makefile deleted file mode 100644 index 265f0e36d0..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/makefile +++ /dev/null @@ -1,290 +0,0 @@ -############################################################################# -# -# Copyright (C) 1996 SciTech Software. -# All rights reserved. -# -# Descripton: Generic makefile for the PM library. Builds the library -# file and all test programs. -# -############################################################################# - -.IMPORT .IGNORE : DEBUG_AGP_DRIVER TEST_HARNESS DEBUG_SDDPMI - -#---------------------------------------------------------------------------- -# Add DOS extender dependant flags to command line -#---------------------------------------------------------------------------- - -CFLAGS += $(DX_CFLAGS) -ASFLAGS += $(DX_ASFLAGS) -NO_PMLIB := 1 - -#---------------------------------------------------------------------------- -# Include definitions specific for the target system -#---------------------------------------------------------------------------- - -.IF $(USE_VXD) - -# Building for Win32 VxD (minimal PM library implementation) - -LIBNAME = pm -OBJECTS = pm$O vflat$O ztimer$O cpuinfo$O mtrr$O fileio$O pcilib$O \ - agp$O malloc$O vgastate$O gavxd$O _pm$O _mtrr$O _cpuinfo$O \ - _int64$O _pcihelp$O -DEPEND_SRC := vxd;common;codepage;tests -.SOURCE: vxd common codepage tests - -.ELIF $(USE_NTDRV) - -# Building for NT device drivers (minimal PM library implementation) - -LIBNAME = pm -OBJECTS = pm$O vflat$O ztimer$O cpuinfo$O mtrr$O mem$O irq$O int86$O \ - stdio$O stdlib$O pcilib$O agp$O malloc$O vgastate$O gantdrv$O \ - _pm$O _mtrr$O _cpuinfo$O _int64$O _pcihelp$O _irq$O -DEPEND_SRC := ntdrv;common;codepage;tests -.SOURCE: ntdrv common codepage tests - -.ELIF $(USE_WIN32) - -# Building for Win32 - -CFLAGS += -DUSE_OS_JOYSTICK -LIBNAME = pm -OBJECTS = pm$O vflat$O event$O ddraw$O ztimer$O cpuinfo$O pcilib$O \ - agp$O malloc$O vgastate$O gawin32$O ntservc$O _joy$O _cpuinfo$O \ - _int64$O _pcihelp$O -DEPEND_SRC := win32;common;codepage;tests -.SOURCE: win32 common codepage tests - -.ELIF $(USE_OS232) - -# Building for OS/2 - -.IF $(USE_OS2GUI) -LIBNAME = pm_pm -.ELSE -LIBNAME = pm -.ENDIF -OBJECTS = pm$O vflat$O event$O ztimer$O cpuinfo$O mtrr$O pcilib$O \ - agp$O malloc$O vgastate$O gaos2$O _pmos2$O _joy$O _cpuinfo$O \ - _int64$O _pcihelp$O dossctl$O -DEPEND_SRC := os2;common;codepage;tests -.SOURCE: os2 common codepage tests - -.ELIF $(USE_QNX) - -# Building for QNX - -USE_BIOS := 1 -.IF $(USE_PHOTON) -LIBNAME = pm_ph -.ELIF $(USE_X11) -LIBNAME = pm_x11 -.ELSE -LIBNAME = pm -.ENDIF -OBJECTS = pm$O vflat$O event$O ztimer$O cpuinfo$O mtrr$O pcilib$O \ - agp$O malloc$O mtrrqnx$O unixio$O vgastate$O gaqnx$O _joy$O \ - _mtrrqnx$O _cpuinfo$O _int64$O _pcihelp$O -DEPEND_SRC := qnx;common;codepage;tests -.SOURCE: qnx common codepage tests - -# Indicate that this program uses Nucleus device drivers (so needs I/O access) -USE_NUCLEUS := 1 - -.ELIF $(USE_LINUX) - -# Building for Linux - -CFLAGS += -DENABLE_MTRR -DUSE_OS_JOYSTICK -.IF $(USE_X11) -LIBNAME = pm_x11 -.ELSE -LIBNAME = pm -.ENDIF -OBJECTS = pm$O vflat$O event$O ztimer$O cpuinfo$O pcilib$O \ - agp$O malloc$O unixio$O vgastate$O galinux$O _cpuinfo$O \ - _int64$O _pcihelp$O -DEPEND_SRC := linux;common;codepage;tests;x11 -.SOURCE: linux common codepage tests x11 - -# Building a shared library -.IF $(SOFILE) -LIB := ld -LIBFLAGS := -r -o -CFLAGS += -fPIC -.ENDIF - -.ELIF $(USE_BEOS) - -# Building for BeOS GUI - -LIBNAME = pm -OBJECTS = pm$O vflat$O event$O ztimer$O cpuinfo$O pcilib$O \ - agp$O malloc$O vgastate$O gabeos$O _joy$O _cpuinfo$O \ - _int64$O _pcihelp$O -DEPEND_SRC := beos;common;codepage;tests -.SOURCE: beos common codepage tests - -.ELIF $(USE_SMX32) - -# Building for SMX - -LIBNAME = pm -OBJECTS = pm$O pmsmx$O vflat$O event$O ztimer$O cpuinfo$O mtrr$O pcilib$O \ - agp$O malloc$O vgastate$O gasmx$O _pm$O _pmsmx$O _mtrr$O _event$O \ - _joy$O _cpuinfo$O _int64$O _pcihelp$O _lztimer$O -DEPEND_SRC := smx;common;codepage;tests -.SOURCE: smx common codepage tests - -.ELIF $(USE_RTTARGET) - -# Building for RTTarget-32 - -LIBNAME = pm -OBJECTS = pm$O vflat$O event$O ztimer$O cpuinfo$O mtrr$O pcilib$O \ - agp$O malloc$O vgastate$O gartt$O _mtrr$O _joy$O _cpuinfo$O \ - _int64$O _pcihelp$O -DEPEND_SRC := rttarget;common;codepage;tests -.SOURCE: rttarget common codepage tests - -.ELSE - -# Building for MSDOS - -LIBNAME = pm -OBJECTS = pm$O pmdos$O vflat$O event$O ztimer$O cpuinfo$O mtrr$O \ - agp$O malloc$O pcilib$O vgastate$O gados$O \ - _pm$O _pmdos$O _mtrr$O _vflat$O _event$O _joy$O _pcihelp$O \ - _cpuinfo$O _int64$O _lztimer$O _dma$O -DEPEND_SRC := dos;common;codepage;tests -.SOURCE: dos common codepage tests - -.ENDIF - -# Object modules for keyboard code pages - -OBJECTS += us_eng$O - -# Common object modules - -OBJECTS += common$O -.IF $(CHECKED) -OBJECTS += debug$O -.ENDIF - -# Nucleus loader library object modules. Note that when compiling a test harness -# library we need to exclude the Nucleus loader library. - -.IF $(TEST_HARNESS) -CFLAGS += -DTEST_HARNESS -DPMLIB -LIBNAME = pm_test -.ELSE -OBJECTS += galib$O _ga_imp$O -.ENDIF - -.IF $(DEBUG_SDDPMI) -CFLAGS += -DDEBUG_SDDPMI -.ENDIF - -# AGP library object modules - -.IF $(DEBUG_AGP_DRIVER) -CFLAGS += -DDEBUG_AGP_DRIVER -OBJECTS += agplib$O -.ELSE -OBJECTS += agplib$O peloader$O libcimp$O _gatimer$O -.ENDIF - -#---------------------------------------------------------------------------- -# Name of library and generic object files required to build it -#---------------------------------------------------------------------------- - -.IF $(STKCALL) -LIBFILE = s$(LP)$(LIBNAME)$L -.ELSE -LIBFILE = $(LP)$(LIBNAME)$L -.ENDIF -LIBCLEAN = *.lib *.a - -#---------------------------------------------------------------------------- -# Change destination for library file depending the extender being used. This -# is only necessary for DOS extender since the file go into a subdirectory -# in the normal library directory, one for each supported extender. Other -# OS'es put the file into the regular library directory, since there is -# only one per OS in this case. -#---------------------------------------------------------------------------- - -MK_PMODE = 1 - -.IF $(TEST_HARNESS) -LIB_DEST := $(LIB_BASE) -.ELIF $(USE_TNT) -LIB_DEST := $(LIB_BASE)\tnt -.ELIF $(USE_DOS4GW) -LIB_DEST := $(LIB_BASE)\dos4gw -.ELIF $(USE_X32) -LIB_DEST := $(LIB_BASE)\x32 -.ELIF $(USE_DPMI16) -LIB_DEST := $(LIB_BASE)\dpmi16 -.ELIF $(USE_DPMI32) -LIB_DEST := $(LIB_BASE)\dpmi32 -.ELIF $(USE_DOSX) -LIB_DEST := $(LIB_BASE)\dosx -.END - -#---------------------------------------------------------------------------- -# Names of all executable files built -#---------------------------------------------------------------------------- - -.IF $(USE_REALDOS) -EXEFILES = memtest$E biosptr$E video$E isvesa$E callreal$E \ - mouse$E tick$E key$E key15$E brk$E altbrk$E \ - critical$E altcrit$E vftest$E rtc$E getch$E \ - cpu$E timerc$E timercpp$E showpci$E uswc$E block$E -.ELSE -EXEFILES = memtest$E video$E isvesa$E callreal$E vftest$E getch$E \ - cpu$E timerc$E timercpp$E showpci$E uswc$E block$E \ - save$E restore$E -.ENDIF - -all: $(EXEFILES) - -$(EXEFILES): $(LIBFILE) - -memtest$E: memtest$O -biosptr$E: biosptr$O -video$E: video$O -isvesa$E: isvesa$O -mouse$E: mouse$O -tick$E: tick$O -key$E: key$O -key15$E: key15$O -brk$E: brk$O -altbrk$E: altbrk$O -critical$E: critical$O -altcrit$E: altcrit$O -callreal$E: callreal$O -vftest$E: vftest$O -rtc$E: rtc$O -getch$E: getch$O -cpu$E: cpu$O -timerc$E: timerc$O -timercpp$E: timercpp$O -showpci$E: showpci$O -uswc$E: uswc$O -block$E: block$O -save$E: save$O -restore$E: restore$O -test$E: test$O _test$O - -#---------------------------------------------------------------------------- -# Define the list of object files to create dependency information for -#---------------------------------------------------------------------------- - -DEPEND_OBJ := $(OBJECTS) memtest$O biosptr$O video$O isvesa$O mouse$O \ - tick$O key$O key$O brk$O altbrk$O critical$O altcrit$O \ - callreal$O vftest$O getch$O timercpp$O - -.INCLUDE: "$(SCITECH)/makedefs/common.mk" - diff --git a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/_irq.asm b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/_irq.asm deleted file mode 100644 index 11824a0afc..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/_irq.asm +++ /dev/null @@ -1,288 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: 80386 Assembler, TASM 4.0 or NASM -;* Environment: 32-bit Windows NT device driver -;* -;* Description: Low level assembly support for the PM library specific to -;* Windows NT device drivers. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -header _irq ; Set up memory model - -begdataseg _irq - - cextern _PM_rtcHandler,CPTR - cextern _PM_prevRTC,FCPTR - -RtcInside dw 0 ; Are we still handling current interrupt -sidtBuf df 0 ; Buffer for sidt instruction - -enddataseg _irq - -begcodeseg _irq ; Start of code segment - -cpublic _PM_irqCodeStart - -; Macro to delay briefly to ensure that enough time has elapsed between -; successive I/O accesses so that the device being accessed can respond -; to both accesses even on a very fast PC. - -ifdef USE_NASM -%macro DELAY 0 - jmp short $+2 - jmp short $+2 - jmp short $+2 -%endmacro -%macro IODELAYN 1 -%rep %1 - DELAY -%endrep -%endmacro -else -macro DELAY - jmp short $+2 - jmp short $+2 - jmp short $+2 -endm -macro IODELAYN N - rept N - DELAY - endm -endm -endif - -;---------------------------------------------------------------------------- -; PM_rtcISR - Real time clock interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; Hardware interrupt handler for the timer interrupt, to dispatch control -; to high level C based subroutines. We save the state of all registers -; in this routine, and switch to a local stack. Interrupts are *off* -; when we call the user code. -; -; NOTE: This routine switches to a local stack before calling any C code, -; and hence is _not_ re-entrant. Make sure your C code executes as -; quickly as possible, since a timer overrun will simply hang the -; system. -;---------------------------------------------------------------------------- -cprocfar _PM_rtcISR - -;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -; If we enable interrupts and call into any C based interrupt handling code, -; we need to setup a bunch of important information for the NT kernel. The -; code below takes care of this housekeeping for us (see Undocumented NT for -; details). If we don't do this housekeeping and interrupts are enabled, -; the kernel will become very unstable and crash within 10 seconds or so. -;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - pushad - pushfd - push fs - - mov ebx,00000030h - mov fs,bx - sub esp,50h - mov ebp,esp - -; Setup the exception frame to NULL - - mov ebx,[DWORD cs:0FFDFF000h] - mov [DWORD ds:0FFDFF000h], 0FFFFFFFFh - mov [DWORD ebp],ebx - -; Save away the existing KSS ebp - - mov esi,[DWORD cs:0FFDFF124h] - mov ebx,[DWORD esi+00000128h] - mov [DWORD ebp+4h],ebx - mov [DWORD esi+00000128h],ebp - -; Save away the kernel time and the thread mode (kernel/user) - - mov edi,[DWORD esi+00000137h] - mov [DWORD ebp+8h],edi - -; Set the thread mode (kernel/user) based on the code selector - - mov ebx,[DWORD ebp+7Ch] - and ebx,01 - mov [BYTE esi+00000137h],bl - -;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -; End of special interrupt Prolog code -;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -; Clear priority interrupt controller and re-enable interrupts so we -; dont lock things up for long. - - mov al,20h - out 0A0h,al - out 020h,al - -; Clear real-time clock timeout - - in al,70h ; Read CMOS index register - push eax ; and save for later - IODELAYN 3 - mov al,0Ch - out 70h,al - IODELAYN 5 - in al,71h - -; Call the C interrupt handler function - - cmp [BYTE RtcInside],1 ; Check for mutual exclusion - je @@Exit - mov [BYTE RtcInside],1 - sti ; Enable interrupts - cld ; Clear direction flag for C code - call [CPTR _PM_rtcHandler] - cli ; Disable interrupts on exit! - mov [BYTE RtcInside],0 - -@@Exit: pop eax - out 70h,al ; Restore CMOS index register - -;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -; Start of special epilog code to restore stuff on exit from handler -;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -; Restore the KSS ebp - - mov esi,[DWORD cs:0FFDFF124h] - mov ebx,[DWORD ebp+4] - mov [DWORD esi+00000128h],ebx - -; Restore the exception frame - - mov ebx,[DWORD ebp] - mov [DWORD fs:00000000],ebx - -; Restore the thread mode - - mov ebx,[DWORD ebp+8h] - mov esi,[DWORD fs:00000124h] - mov [BYTE esi+00000137h],bl - add esp, 50h - pop fs - popfd - popad - -; Return from interrupt - - iret - -cprocend - -cpublic _PM_irqCodeEnd - -;---------------------------------------------------------------------------- -; void _PM_getISR(int irq,PMFARPTR *handler); -;---------------------------------------------------------------------------- -; Function to return the specific IRQ handler direct from the IDT. -;---------------------------------------------------------------------------- -cprocstart _PM_getISR - - ARG idtEntry:UINT, handler:DPTR - - enter_c 0 - mov ecx,[handler] ; Get address of handler to fill in - sidt [sidtBuf] ; Get IDTR register into sidtBuf - mov eax,[DWORD sidtBuf+2] ; Get address of IDT into EAX - mov ebx,[idtEntry] - lea eax,[eax+ebx*8] ; Get entry in the IDT - movzx edx,[WORD eax+6] ; Get high order 16-bits - shl edx,16 ; Move into top 16-bits of address - mov dx,[WORD eax] ; Get low order 16-bits - mov [DWORD ecx],edx ; Store linear address of handler - mov dx,[WORD eax+2] ; Get selector value - mov [WORD ecx+4],dx ; Store selector value - leave_c - ret - -cprocend _PM_getISR - -;---------------------------------------------------------------------------- -; void _PM_setISR(int irq,void *handler); -;---------------------------------------------------------------------------- -; Function to set the specific IRQ handler direct in the IDT. -;---------------------------------------------------------------------------- -cprocstart _PM_setISR - - ARG irq:UINT, handler:CPTR - - enter_c 0 - mov ecx,[handler] ; Get address of new handler - mov dx,cs ; Get selector for new handler - sidt [sidtBuf] ; Get IDTR register into sidtBuf - mov eax,[DWORD sidtBuf+2] ; Get address of IDT into EAX - mov ebx,[idtEntry] - lea eax,[eax+ebx*8] ; Get entry in the IDT - cli - mov [WORD eax+2],dx ; Store code segment selector - mov [WORD eax],cx ; Store low order bits of handler - shr ecx,16 - mov [WORD eax+6],cx ; Store high order bits of handler - sti - leave_c - ret - -cprocend _PM_setISR - -;---------------------------------------------------------------------------- -; void _PM_restoreISR(int irq,PMFARPTR *handler); -;---------------------------------------------------------------------------- -; Function to set the specific IRQ handler direct in the IDT. -;---------------------------------------------------------------------------- -cprocstart _PM_restoreISR - - ARG irq:UINT, handler:CPTR - - enter_c 0 - mov ecx,[handler] - mov dx,[WORD ecx+4] ; Get selector for old handler - mov ecx,[DWORD ecx] ; Get address of old handler - sidt [sidtBuf] ; Get IDTR register into sidtBuf - mov eax,[DWORD sidtBuf+2] ; Get address of IDT into EAX - mov ebx,[idtEntry] - lea eax,[eax+ebx*8] ; Get entry in the IDT - cli - mov [WORD eax+2],dx ; Store code segment selector - mov [WORD eax],cx ; Store low order bits of handler - shr ecx,16 - mov [WORD eax+6],cx ; Store high order bits of handler - sti - leave_c - ret - -cprocend _PM_restoreISR - -endcodeseg _irq - - END ; End of module - diff --git a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/_pm.asm b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/_pm.asm deleted file mode 100644 index 6cb276d25e..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/_pm.asm +++ /dev/null @@ -1,281 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: 80386 Assembler, TASM 4.0 or NASM -;* Environment: 32-bit Windows NT device driver -;* -;* Description: Low level assembly support for the PM library specific to -;* Windows NT device drivers. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -header _pm ; Set up memory model - -P586 - -begdataseg - -; Watcom C++ externals required to link when compiling floating point -; C code. They are not actually used in the code because we compile with -; inline floating point instructions, however the compiler still generates -; the references in the object modules. - -__8087 dd 0 - PUBLIC __8087 -__imthread: -__fltused: -_fltused_ dd 0 - PUBLIC __imthread - PUBLIC _fltused_ - PUBLIC __fltused - -enddataseg - -begcodeseg _pm ; Start of code segment - -;---------------------------------------------------------------------------- -; void PM_segread(PMSREGS *sregs) -;---------------------------------------------------------------------------- -; Read the current value of all segment registers -;---------------------------------------------------------------------------- -cprocstart PM_segread - - ARG sregs:DPTR - - enter_c - - mov ax,es - _les _si,[sregs] - mov [_ES _si],ax - mov [_ES _si+2],cs - mov [_ES _si+4],ss - mov [_ES _si+6],ds - mov [_ES _si+8],fs - mov [_ES _si+10],gs - - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; int PM_int386x(int intno, PMREGS *in, PMREGS *out,PMSREGS *sregs) -;---------------------------------------------------------------------------- -; Issues a software interrupt in protected mode. This routine has been -; written to allow user programs to load CS and DS with different values -; other than the default. -;---------------------------------------------------------------------------- -cprocstart PM_int386x - -; Not used for NT device drivers - - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_setBankA(int bank) -;---------------------------------------------------------------------------- -cprocstart PM_setBankA - -; Not used for NT device drivers - - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_setBankAB(int bank) -;---------------------------------------------------------------------------- -cprocstart PM_setBankAB - -; Not used for NT device drivers - - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_setCRTStart(int x,int y,int waitVRT) -;---------------------------------------------------------------------------- -cprocstart PM_setCRTStart - -; Not used for NT device drivers - - ret - -cprocend - -; Macro to delay briefly to ensure that enough time has elapsed between -; successive I/O accesses so that the device being accessed can respond -; to both accesses even on a very fast PC. - -ifdef USE_NASM -%macro DELAY 0 - jmp short $+2 - jmp short $+2 - jmp short $+2 -%endmacro -%macro IODELAYN 1 -%rep %1 - DELAY -%endrep -%endmacro -else -macro DELAY - jmp short $+2 - jmp short $+2 - jmp short $+2 -endm -macro IODELAYN N - rept N - DELAY - endm -endm -endif - -;---------------------------------------------------------------------------- -; uchar _PM_readCMOS(int index) -;---------------------------------------------------------------------------- -; Read the value of a specific CMOS register. We do this with both -; normal interrupts and NMI disabled. -;---------------------------------------------------------------------------- -cprocstart _PM_readCMOS - - ARG index:UINT - - push _bp - mov _bp,_sp - pushfd - mov al,[BYTE index] - or al,80h ; Add disable NMI flag - cli - out 70h,al - IODELAYN 5 - in al,71h - mov ah,al - xor al,al - IODELAYN 5 - out 70h,al ; Re-enable NMI - mov al,ah ; Return value in AL - popfd - pop _bp - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _PM_writeCMOS(int index,uchar value) -;---------------------------------------------------------------------------- -; Read the value of a specific CMOS register. We do this with both -; normal interrupts and NMI disabled. -;---------------------------------------------------------------------------- -cprocstart _PM_writeCMOS - - ARG index:UINT, value:UCHAR - - push _bp - mov _bp,_sp - pushfd - mov al,[BYTE index] - or al,80h ; Add disable NMI flag - cli - out 70h,al - IODELAYN 5 - mov al,[value] - out 71h,al - xor al,al - IODELAYN 5 - out 70h,al ; Re-enable NMI - popfd - pop _bp - ret - -cprocend - -;---------------------------------------------------------------------------- -; double _ftol(double f) -;---------------------------------------------------------------------------- -; Calls to __ftol are generated by the Borland C++ compiler for code -; that needs to convert a floating point type to an integral type. -; -; Input: floating point number on the top of the '87. -; -; Output: a (signed or unsigned) long in EAX -; All other registers preserved. -;----------------------------------------------------------------------- -cprocstart _ftol - - LOCAL temp1:WORD, temp2:QWORD = LocalSize - - push ebp - mov ebp,esp - sub esp,LocalSize - - fstcw [temp1] ; save the control word - fwait - mov al,[BYTE temp1+1] - or [BYTE temp1+1],0Ch ; set rounding control to chop - fldcw [temp1] - fistp [temp2] ; convert to 64-bit integer - mov [BYTE temp1+1],al - fldcw [temp1] ; restore the control word - mov eax,[DWORD temp2] ; return LS 32 bits - mov edx,[DWORD temp2+4] ; MS 32 bits - - mov esp,ebp - pop ebp - ret - -cprocend - -;---------------------------------------------------------------------------- -; _PM_getPDB - Return the Page Table Directory Base address -;---------------------------------------------------------------------------- -cprocstart _PM_getPDB - - mov eax,cr3 - and eax,0FFFFF000h - ret - -cprocend - -;---------------------------------------------------------------------------- -; Flush the Translation Lookaside buffer -;---------------------------------------------------------------------------- -cprocstart PM_flushTLB - - wbinvd ; Flush the CPU cache - mov eax,cr3 - mov cr3,eax ; Flush the TLB - ret - -cprocend - -endcodeseg _pm - - END ; End of module diff --git a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/cpuinfo.c deleted file mode 100644 index d15b07c290..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/cpuinfo.c +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit Windows VxD -* -* Description: VxD specific code for the CPU detection module. -* -****************************************************************************/ - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Do nothing for VxD's -****************************************************************************/ -#define SetMaxThreadPriority() 0 - -/**************************************************************************** -REMARKS: -Do nothing for VxD's -****************************************************************************/ -#define RestoreThreadPriority(i) (void)(i) - -/**************************************************************************** -REMARKS: -Initialise the counter and return the frequency of the counter. -****************************************************************************/ -static void GetCounterFrequency( - CPU_largeInteger *freq) -{ - KeQueryPerformanceCounter((LARGE_INTEGER*)freq); -} - -/**************************************************************************** -REMARKS: -Read the counter and return the counter value. -****************************************************************************/ -#define GetCounter(t) \ -{ \ - LARGE_INTEGER lt = KeQueryPerformanceCounter(NULL); \ - (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 deleted file mode 100644 index c82648b787..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/int86.c +++ /dev/null @@ -1,251 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit Windows NT device drivers. -* -* Description: Implementation for the real mode software interrupt -* handling functions. -* -****************************************************************************/ - -#include "pmapi.h" -#include "drvlib/os/os.h" -#include "sdd/sddhelp.h" -#include "mtrr.h" -#include "oshdr.h" - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -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; -} - -/**************************************************************************** -PARAMETERS: -len - Place to store the length of the buffer -rseg - Place to store the real mode segment of the buffer -roff - Place to store the real mode offset of the buffer - -REMARKS: -This function returns the address and length of the global VESA transfer -buffer that is used for communicating with the VESA BIOS functions from -Win16 and Win32 programs under Windows. -****************************************************************************/ -void * PMAPI PM_getVESABuf( - uint *len, - uint *rseg, - uint *roff) -{ - /* No buffers supported under Windows NT (Windows XP has them however if */ - /* we ever decide to support this!) */ - return NULL; -} - -/**************************************************************************** -REMARKS: -Issue a protected mode software interrupt. -****************************************************************************/ -int PMAPI PM_int386( - int intno, - PMREGS *in, - PMREGS *out) -{ - PMSREGS sregs; - PM_segread(&sregs); - return PM_int386x(intno,in,out,&sregs); -} - -/**************************************************************************** -REMARKS: -Map a real mode pointer to a protected mode pointer. -****************************************************************************/ -void * PMAPI PM_mapRealPointer( - uint r_seg, - uint r_off) -{ - /* Not used for Windows NT drivers! */ - return NULL; -} - -/**************************************************************************** -REMARKS: -Allocate a block of real mode memory -****************************************************************************/ -void * PMAPI PM_allocRealSeg( - uint size, - uint *r_seg, - uint *r_off) -{ - /* Not supported in NT drivers */ - (void)size; - (void)r_seg; - (void)r_off; - return NULL; -} - -/**************************************************************************** -REMARKS: -Free a block of real mode memory. -****************************************************************************/ -void PMAPI PM_freeRealSeg( - void *mem) -{ - /* Not supported in NT drivers */ - (void)mem; -} - -/**************************************************************************** -REMARKS: -Issue a real mode interrupt (parameters in DPMI compatible structure) -****************************************************************************/ -void PMAPI DPMI_int86( - int intno, - DPMI_regs *regs) -{ - /* Not used in NT drivers */ -} - -/**************************************************************************** -REMARKS: -Call a V86 real mode function with the specified register values -loaded before the call. The call returns with a far ret. -****************************************************************************/ -void PMAPI PM_callRealMode( - uint seg, - uint off, - RMREGS *regs, - RMSREGS *sregs) -{ - /* TODO!! */ -#if 0 - CLIENT_STRUCT saveRegs; - - /* Bail if we do not have BIOS access (ie: the VxD was dynamically - * loaded, and not statically loaded. - */ - if (!_PM_haveBIOS) - return; - - TRACE("SDDHELP: Entering PM_callRealMode()\n"); - Begin_Nest_V86_Exec(); - LoadV86Registers(&saveRegs,regs,sregs); - Simulate_Far_Call(seg, off); - Resume_Exec(); - ReadV86Registers(&saveRegs,regs,sregs); - End_Nest_Exec(); - TRACE("SDDHELP: Exiting PM_callRealMode()\n"); -#endif -} - -/**************************************************************************** -REMARKS: -Issue a V86 real mode interrupt with the specified register values -loaded before the interrupt. -****************************************************************************/ -int PMAPI PM_int86( - int intno, - RMREGS *in, - RMREGS *out) -{ - /* TODO!! */ -#if 0 - RMSREGS sregs = {0}; - CLIENT_STRUCT saveRegs; - ushort oldDisable; - - /* Disable pass-up to our VxD handler so we directly call BIOS */ - TRACE("SDDHELP: Entering PM_int86()\n"); - if (disableTSRFlag) { - oldDisable = *disableTSRFlag; - *disableTSRFlag = 0; - } - Begin_Nest_V86_Exec(); - LoadV86Registers(&saveRegs,in,&sregs); - Exec_Int(intno); - ReadV86Registers(&saveRegs,out,&sregs); - End_Nest_Exec(); - - /* Re-enable pass-up to our VxD handler if previously enabled */ - if (disableTSRFlag) - *disableTSRFlag = oldDisable; - - TRACE("SDDHELP: Exiting PM_int86()\n"); -#else - *out = *in; -#endif - return out->x.ax; -} - -/**************************************************************************** -REMARKS: -Issue a V86 real mode interrupt with the specified register values -loaded before the interrupt. -****************************************************************************/ -int PMAPI PM_int86x( - int intno, - RMREGS *in, - RMREGS *out, - RMSREGS *sregs) -{ - /* TODO!! */ -#if 0 - CLIENT_STRUCT saveRegs; - ushort oldDisable; - - /* Bail if we do not have BIOS access (ie: the VxD was dynamically - * loaded, and not statically loaded. - */ - if (!_PM_haveBIOS) { - *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; - } - Begin_Nest_V86_Exec(); - LoadV86Registers(&saveRegs,in,sregs); - Exec_Int(intno); - ReadV86Registers(&saveRegs,out,sregs); - End_Nest_Exec(); - - /* Re-enable pass-up to our VxD handler if previously enabled */ - if (disableTSRFlag) - *disableTSRFlag = oldDisable; - - TRACE("SDDHELP: Exiting PM_int86x()\n"); -#else - *out = *in; -#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 deleted file mode 100644 index 9cd52047b7..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/irq.c +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit Windows NT device drivers. -* -* Description: Implementation for the NT driver IRQ management functions -* for the PM library. -* -****************************************************************************/ - -#include "pmapi.h" -#include "pmint.h" -#include "drvlib/os/os.h" -#include "sdd/sddhelp.h" -#include "mtrr.h" -#include "oshdr.h" - -/*--------------------------- Global variables ----------------------------*/ - -static int globalDataStart; -static uchar _PM_oldCMOSRegA; -static uchar _PM_oldCMOSRegB; -static uchar _PM_oldRTCPIC2; -static ulong RTC_idtEntry; -PM_intHandler _PM_rtcHandler = NULL; -PMFARPTR _VARAPI _PM_prevRTC = PMNULL; - -/*----------------------------- Implementation ----------------------------*/ - -/* Functions to read and write CMOS registers */ - -uchar _ASMAPI _PM_readCMOS(int index); -void _ASMAPI _PM_writeCMOS(int index,uchar value); -void _ASMAPI _PM_rtcISR(void); -void _ASMAPI _PM_getISR(int irq,PMFARPTR *handler); -void _ASMAPI _PM_setISR(int irq,void *handler); -void _ASMAPI _PM_restoreISR(int irq,PMFARPTR *handler); -void _ASMAPI _PM_irqCodeStart(void); -void _ASMAPI _PM_irqCodeEnd(void); - -/**************************************************************************** -REMARKS: -Set the real time clock frequency (for stereo modes). -****************************************************************************/ -void PMAPI PM_setRealTimeClockFrequency( - int frequency) -{ - static short convert[] = { - 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)); - } - 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)); - } -} - -ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler th,int frequency) -{ - static ibool locked = false; - - /* Save the old CMOS real time clock values */ - _PM_oldCMOSRegA = _PM_readCMOS(0x0A); - _PM_oldCMOSRegB = _PM_readCMOS(0x0B); - - /* Install the interrupt handler */ - RTC_idtEntry = 0x38; - _PM_getISR(RTC_idtEntry, &_PM_prevRTC); - _PM_rtcHandler = th; - _PM_setISR(RTC_idtEntry, _PM_rtcISR); - - /* Program the real time clock default frequency */ - PM_setRealTimeClockFrequency(frequency); - - /* Unmask IRQ8 in the PIC2 */ - _PM_oldRTCPIC2 = PM_inpb(0xA1); - PM_outpb(0xA1,(uchar)(_PM_oldRTCPIC2 & 0xFE)); - return true; -} - -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; - } -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/mem.c b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/mem.c deleted file mode 100644 index 3128c6ae38..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/mem.c +++ /dev/null @@ -1,518 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit Windows NT device drivers. -* -* Description: Implementation for the NT driver memory management functions -* for the PM library. -* -****************************************************************************/ - -#include "pmapi.h" -#include "drvlib/os/os.h" -#include "sdd/sddhelp.h" -#include "mtrr.h" -#include "oshdr.h" - -/*--------------------------- Global variables ----------------------------*/ - -#define MAX_MEMORY_SHARED 100 -#define MAX_MEMORY_MAPPINGS 100 -#define MAX_MEMORY_LOCKED 100 - -typedef struct { - void *linear; - ulong length; - PMDL pMdl; - } memshared; - -typedef struct { - void *linear; - void *mmIoMapped; - ulong length; - PMDL pMdl; - } memlocked; - -typedef struct { - ulong physical; - ulong linear; - ulong length; - ibool isCached; - } mmapping; - -static int numMappings = 0; -static memshared shared[MAX_MEMORY_MAPPINGS] = {0}; -static mmapping maps[MAX_MEMORY_MAPPINGS]; -static memlocked locked[MAX_MEMORY_LOCKED]; - -/*----------------------------- Implementation ----------------------------*/ - -ulong PMAPI _PM_getPDB(void); - -/* Page table entry flags */ - -#define PAGE_FLAGS_PRESENT 0x00000001 -#define PAGE_FLAGS_WRITEABLE 0x00000002 -#define PAGE_FLAGS_USER 0x00000004 -#define PAGE_FLAGS_WRITE_THROUGH 0x00000008 -#define PAGE_FLAGS_CACHE_DISABLE 0x00000010 -#define PAGE_FLAGS_ACCESSED 0x00000020 -#define PAGE_FLAGS_DIRTY 0x00000040 -#define PAGE_FLAGS_4MB 0x00000080 - -/**************************************************************************** -PARAMETERS: -base - Physical base address of the memory to maps in -limit - Limit of physical memory to region to maps in - -RETURNS: -Linear address of the newly mapped memory. - -REMARKS: -Maps a physical memory range to a linear memory range. -****************************************************************************/ -static ulong _PM_mapPhysicalToLinear( - ulong base, - ulong limit, - ibool isCached) -{ - ulong length = limit+1; - PHYSICAL_ADDRESS paIoBase = {0}; - - /* NT loves large Ints */ - paIoBase = RtlConvertUlongToLargeInteger( base ); - - /* Map IO space into Kernel */ - if (isCached) - return (ULONG)MmMapIoSpace(paIoBase, length, MmCached ); - else - return (ULONG)MmMapIoSpace(paIoBase, length, MmNonCached ); -} - -/**************************************************************************** -REMARKS: -Adjust the page table caching bits directly. Requires ring 0 access and -only works with DOS4GW and compatible extenders (CauseWay also works since -it has direct support for the ring 0 instructions we need from ring 3). Will -not work in a DOS box, but we call into the ring 0 helper VxD so we should -never get here in a DOS box anyway (assuming the VxD is present). If we -do get here and we are in windows, this code will be skipped. -****************************************************************************/ -static void _PM_adjustPageTables( - ulong linear, - ulong limit, - ibool isGlobal, - ibool isCached) -{ - int startPDB,endPDB,iPDB,startPage,endPage,start,end,iPage; - ulong pageTable,*pPDB,*pPageTable; - ulong mask = 0xFFFFFFFF; - ulong bits = 0x00000000; - - /* Enable user level access for page table entry */ - if (isGlobal) { - 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); - bits |= (PAGE_FLAGS_CACHE_DISABLE | PAGE_FLAGS_WRITE_THROUGH); - } - - 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(); - } -} - -/**************************************************************************** -REMARKS: -Allocate a block of shared memory. For NT we allocate shared memory -as locked, global memory that is accessible from any memory context -(including interrupt time context), which allows us to load our important -data structure and code such that we can access it directly from a ring -0 interrupt context. -****************************************************************************/ -void * PMAPI PM_mallocShared( - long size) -{ - int i; - - /* 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 (i == MAX_MEMORY_SHARED) - return NULL; - - /* Allocate the paged pool */ - shared[i].linear = ExAllocatePool(PagedPool, size); - - /* Create a list to manage this allocation */ - shared[i].pMdl = IoAllocateMdl(shared[i].linear,size,FALSE,FALSE,(PIRP) NULL); - - /* Lock this allocation in memory */ - MmProbeAndLockPages(shared[i].pMdl,KernelMode,IoModifyAccess); - - /* Modify bits to grant user access */ - _PM_adjustPageTables((ulong)shared[i].linear, size, true, true); - return (void*)shared[i].linear; -} - -/**************************************************************************** -REMARKS: -Free a block of shared memory -****************************************************************************/ -void PMAPI PM_freeShared( - void *p) -{ - int i; - - /* 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); - - /* Free our MDL */ - IoFreeMdl(shared[i].pMdl); - - /* Free our mem */ - ExFreePool(shared[i].linear); - - /* Flag that is entry is available */ - shared[i].linear = 0; - break; - } - } -} - -/**************************************************************************** -REMARKS: -Map a physical address to a linear address in the callers process. -****************************************************************************/ -void * PMAPI PM_mapPhysicalAddr( - ulong base, - ulong limit, - ibool isCached) -{ - 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. */ - 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 (numMappings == MAX_MEMORY_MAPPINGS) - return NULL; - - /* We did not find any previously mapped memory region, so maps it in. */ - if ((linear = _PM_mapPhysicalToLinear(base,limit,isCached)) == 0xFFFFFFFF) - 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 */ - _PM_adjustPageTables((ulong)linear, length, true, isCached); - return (void*)linear; -} - -/**************************************************************************** -REMARKS: -Free a physical address mapping allocated by PM_mapPhysicalAddr. -****************************************************************************/ -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. */ -} - -/**************************************************************************** -REMARKS: -Called when the device driver unloads to free all the page table mappings! -****************************************************************************/ -void PMAPI _PM_freeMemoryMappings(void) -{ - int i; - - for (i = 0; i < numMappings; i++) - MmUnmapIoSpace((void *)maps[i].linear,maps[i].length); -} - -/**************************************************************************** -REMARKS: -Find the physical address of a linear memory address in current process. -****************************************************************************/ -ulong PMAPI PM_getPhysicalAddr( - void *p) -{ - PHYSICAL_ADDRESS paOurAddress; - - paOurAddress = MmGetPhysicalAddress(p); - return paOurAddress.LowPart; -} - -/**************************************************************************** -REMARKS: -Find the physical address of a linear memory address in current process. -****************************************************************************/ -ibool PMAPI PM_getPhysicalAddrRange( - void *p, - ulong length, - ulong *physAddress) -{ - int i; - ulong linear = (ulong)p & ~0xFFF; - - for (i = (length + 0xFFF) >> 12; i > 0; i--) { - if ((*physAddress++ = PM_getPhysicalAddr((void*)linear)) == 0xFFFFFFFF) - return false; - linear += 4096; - } - return true; -} - -/**************************************************************************** -REMARKS: -Allocates a block of locked physical memory. -****************************************************************************/ -void * PMAPI PM_allocLockedMem( - uint size, - ulong *physAddr, - ibool contiguous, - ibool below16M) -{ - int i; - PHYSICAL_ADDRESS paOurAddress; - - /* 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 (i == MAX_MEMORY_LOCKED) - 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. */ - paOurAddress.HighPart = 0; - if (below16M) - paOurAddress.LowPart = 0x00FFFFFF; - else - 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; - - /* 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. */ - - /* 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; - } - else { - /* 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); - - /* 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; - } -} - -/**************************************************************************** -REMARKS: -Frees a block of locked physical memory. -****************************************************************************/ -void PMAPI PM_freeLockedMem( - void *p, - uint size, - ibool contiguous) -{ - int i; - - /* 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; - } - } -} - -/**************************************************************************** -REMARKS: -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. */ - return ExAllocatePool( - locked ? NonPagedPoolCacheAligned : PagedPoolCacheAligned, - PAGE_SIZE); -} - -/**************************************************************************** -REMARKS: -Free a page aligned and page sized block of memory -****************************************************************************/ -void PMAPI PM_freePage( - void *p) -{ - if (p) ExFreePool(p); -} - -/**************************************************************************** -REMARKS: -Lock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_lockDataPages( - void *p, - uint len, - PM_lockHandle *lh) -{ - MDL *pMdl; - - /* Create a list to manage this allocation */ - if ((pMdl = IoAllocateMdl(p,len,FALSE,FALSE,(PIRP)NULL)) == NULL) - return false; - - /* Lock this allocation in memory */ - MmProbeAndLockPages(pMdl,KernelMode,IoModifyAccess); - *((PMDL*)(&lh->h)) = pMdl; - return true; -} - -/**************************************************************************** -REMARKS: -Unlock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_unlockDataPages( - void *p, - uint len, - PM_lockHandle *lh) -{ - if (p && lh) { - /* Unlock what we locked */ - MDL *pMdl = *((PMDL*)(&lh->h)); - MmUnlockPages(pMdl); - IoFreeMdl(pMdl); - } - return true; -} - -/**************************************************************************** -REMARKS: -Lock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_lockCodePages( - void (*p)(), - uint len, - PM_lockHandle *lh) -{ - return PM_lockDataPages((void*)p,len,lh); -} - -/**************************************************************************** -REMARKS: -Unlock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_unlockCodePages( - void (*p)(), - uint len, - PM_lockHandle *lh) -{ - 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 deleted file mode 100644 index 65b7bae23c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/oshdr.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit Windows NT drivers -* -* Description: Include file to include all OS specific header files. -* -****************************************************************************/ - -#ifndef __NTDRV_OSHDR_H -#define __NTDRV_OSHDR_H - -/*--------------------------- Macros and Typedefs -------------------------*/ - -/*---------------------------- Global variables ---------------------------*/ - -/*--------------------------- Function Prototypes -------------------------*/ - -/* Internal unicode string handling functions */ - -UNICODE_STRING * _PM_CStringToUnicodeString(const char *cstr); -void _PM_FreeUnicodeString(UNICODE_STRING *uniStr); - -#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 deleted file mode 100644 index c6606314c1..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/pm.c +++ /dev/null @@ -1,933 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit Windows NT device drivers. -* -* Description: Implementation for the OS Portability Manager Library, which -* contains functions to implement OS specific services in a -* generic, cross platform API. Porting the OS Portability -* Manager library is the first step to porting any SciTech -* products to a new platform. -* -****************************************************************************/ - -#include "pmapi.h" -#include "drvlib/os/os.h" -#include "sdd/sddhelp.h" -#include "mtrr.h" -#include "oshdr.h" - -/*--------------------------- Global variables ----------------------------*/ - -char _PM_cntPath[PM_MAX_PATH] = ""; -char _PM_nucleusPath[PM_MAX_PATH] = ""; -static void (PMAPIP fatalErrorCleanup)(void) = NULL; - -static char *szNTWindowsKey = "\\REGISTRY\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion"; -static char *szNTSystemRoot = "SystemRoot"; -static char *szMachineNameKey = "\\REGISTRY\\Machine\\System\\CurrentControlSet\\control\\ComputerName\\ComputerName"; -static char *szMachineNameKeyNT = "\\REGISTRY\\Machine\\System\\CurrentControlSet\\control\\ComputerName\\ActiveComputerName"; -static char *szMachineName = "ComputerName"; - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Initialise the PM library. -****************************************************************************/ -void PMAPI PM_init(void) -{ - /* Initialiase the MTRR module */ - MTRR_init(); -} - -/**************************************************************************** -REMARKS: -Return the operating system type identifier. -****************************************************************************/ -long PMAPI PM_getOSType(void) -{ - return _OS_WINNTDRV; -} - -/**************************************************************************** -REMARKS: -Return the runtime type identifier. -****************************************************************************/ -int PMAPI PM_getModeType(void) -{ - return PM_386; -} - -/**************************************************************************** -REMARKS: -Add a file directory separator to the end of the filename. -****************************************************************************/ -void PMAPI PM_backslash(char *s) -{ - uint pos = strlen(s); - if (s[pos-1] != '\\') { - s[pos] = '\\'; - s[pos+1] = '\0'; - } -} - -/**************************************************************************** -REMARKS: -Add a user defined PM_fatalError cleanup function. -****************************************************************************/ -void PMAPI PM_setFatalErrorCleanup( - void (PMAPIP cleanup)(void)) -{ - fatalErrorCleanup = cleanup; -} - -/**************************************************************************** -REMARKS: -Handle fatal errors internally in the driver. -****************************************************************************/ -void PMAPI PM_fatalError( - const char *msg) -{ - ULONG BugCheckCode = 0; - ULONG MoreBugCheckData[4] = {0}; - char *p; - ULONG len; - - if (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); - 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... */ - for(len = 0; len < 20; len++) - if (msg[len] == (char)0) - break; - - /* 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]; - if(len > 2) p[1] = msg[2]; - if(len > 3) p[0] = msg[3]; - - p = (char *)&MoreBugCheckData[0]; - if(len > 4) p[3] = msg[4]; - if(len > 5) p[2] = msg[5]; - if(len > 6) p[1] = msg[6]; - if(len > 7) p[0] = msg[7]; - - p = (char *)&MoreBugCheckData[1]; - if(len > 8) p[3] = msg[8]; - if(len > 9) p[2] = msg[9]; - if(len > 10) p[1] = msg[10]; - if(len > 11) p[0] = msg[11]; - - p = (char *)&MoreBugCheckData[2]; - if(len > 12) p[3] = msg[12]; - if(len > 13) p[2] = msg[13]; - if(len > 14) p[1] = msg[14]; - if(len > 15) p[0] = msg[15]; - - p = (char *)&MoreBugCheckData[3]; - if(len > 16) p[3] = msg[16]; - if(len > 17) p[2] = msg[17]; - if(len > 18) p[1] = msg[18]; - if(len > 19) p[0] = msg[19]; - - /* Halt the system! */ - KeBugCheckEx(BugCheckCode, MoreBugCheckData[0], MoreBugCheckData[1], MoreBugCheckData[2], MoreBugCheckData[3]); -} - -/**************************************************************************** -REMARKS: -Return the current operating system path or working directory. -****************************************************************************/ -char * PMAPI PM_getCurrentPath( - char *path, - int maxLen) -{ - strncpy(path,_PM_cntPath,maxLen); - path[maxLen-1] = 0; - return path; -} - -/**************************************************************************** -PARAMETERS: -szKey - Key to query (can contain version number formatting) -szValue - Value to get information for -value - Place to store the registry key data read -size - Size of the string buffer to read into - -RETURNS: -true if the key was found, false if not. -****************************************************************************/ -static ibool REG_queryString( - char *szKey, - const char *szValue, - char *value, - DWORD size) -{ - ibool status; - NTSTATUS rval; - ULONG length; - HANDLE Handle; - OBJECT_ATTRIBUTES keyAttributes; - UNICODE_STRING *uniKey = NULL; - UNICODE_STRING *uniValue = NULL; - PKEY_VALUE_FULL_INFORMATION fullInfo = NULL; - STRING stringdata; - UNICODE_STRING unidata; - - /* Convert strings to UniCode */ - status = false; - if ((uniKey = _PM_CStringToUnicodeString(szKey)) == NULL) - goto Exit; - if ((uniValue = _PM_CStringToUnicodeString(szValue)) == NULL) - goto Exit; - - /* Open the key */ - InitializeObjectAttributes( &keyAttributes, - uniKey, - OBJ_CASE_INSENSITIVE, - NULL, - NULL ); - rval = ZwOpenKey( &Handle, - KEY_ALL_ACCESS, - &keyAttributes ); - if (!NT_SUCCESS(rval)) - goto Exit; - - /* Query the value */ - length = sizeof (KEY_VALUE_FULL_INFORMATION) - + size * sizeof(WCHAR); - if ((fullInfo = ExAllocatePool (PagedPool, length)) == NULL) - goto Exit; - RtlZeroMemory(fullInfo, length); - rval = ZwQueryValueKey (Handle, - 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; - } - } - -Exit: - if (fullInfo) ExFreePool(fullInfo); - if (uniKey) _PM_FreeUnicodeString(uniKey); - if (uniValue) _PM_FreeUnicodeString(uniValue); - return status; -} - -/**************************************************************************** -REMARKS: -Return the drive letter for the boot drive. -****************************************************************************/ -char PMAPI PM_getBootDrive(void) -{ - char path[256]; - if (REG_queryString(szNTWindowsKey,szNTSystemRoot,path,sizeof(path))) - return 'c'; - return path[0]; -} - -/**************************************************************************** -REMARKS: -Return the path to the VBE/AF driver files. -****************************************************************************/ -const char * PMAPI PM_getVBEAFPath(void) -{ - return "c:\\"; -} - -/**************************************************************************** -REMARKS: -Return the path to the Nucleus driver files. -****************************************************************************/ -const char * PMAPI PM_getNucleusPath(void) -{ - static char path[256]; - - if (strlen(_PM_nucleusPath) > 0) { - strcpy(path,_PM_nucleusPath); - PM_backslash(path); - return path; - } - if (!REG_queryString(szNTWindowsKey,szNTSystemRoot,path,sizeof(path))) - strcpy(path,"c:\\winnt"); - PM_backslash(path); - strcat(path,"system32\\nucleus"); - return path; -} - -/**************************************************************************** -REMARKS: -Return the path to the Nucleus configuration files. -****************************************************************************/ -const char * PMAPI PM_getNucleusConfigPath(void) -{ - static char path[256]; - strcpy(path,PM_getNucleusPath()); - PM_backslash(path); - strcat(path,"config"); - return path; -} - -/**************************************************************************** -REMARKS: -Return a unique identifier for the machine if possible. -****************************************************************************/ -const char * PMAPI PM_getUniqueID(void) -{ - return PM_getMachineName(); -} - -/**************************************************************************** -REMARKS: -Get the name of the machine on the network. -****************************************************************************/ -const char * PMAPI PM_getMachineName(void) -{ - static char name[256]; - - if (REG_queryString(szMachineNameKey,szMachineName,name,sizeof(name))) - return name; - if (REG_queryString(szMachineNameKeyNT,szMachineName,name,sizeof(name))) - return name; - return "Unknown"; -} - -/**************************************************************************** -REMARKS: -Check if a key has been pressed. -****************************************************************************/ -int PMAPI PM_kbhit(void) -{ - /* Not used in NT drivers */ - return true; -} - -/**************************************************************************** -REMARKS: -Wait for and return the next keypress. -****************************************************************************/ -int PMAPI PM_getch(void) -{ - /* Not used in NT drivers */ - return 0xD; -} - -/**************************************************************************** -REMARKS: -Open a console for output to the screen, creating the main event handling -window if necessary. -****************************************************************************/ -PM_HWND PMAPI PM_openConsole( - PM_HWND hwndUser, - int device, - int xRes, - int yRes, - int bpp, - ibool fullScreen) -{ - /* Not used in NT drivers */ - (void)hwndUser; - (void)device; - (void)xRes; - (void)yRes; - (void)bpp; - (void)fullScreen; - return NULL; -} - -/**************************************************************************** -REMARKS: -Find the size of the console state buffer. -****************************************************************************/ -int PMAPI PM_getConsoleStateSize(void) -{ - /* Not used in NT drivers */ - return 1; -} - -/**************************************************************************** -REMARKS: -Save the state of the console. -****************************************************************************/ -void PMAPI PM_saveConsoleState( - void *stateBuf, - PM_HWND hwndConsole) -{ - /* Not used in NT drivers */ - (void)stateBuf; - (void)hwndConsole; -} - -/**************************************************************************** -REMARKS: -Set the suspend application callback for the fullscreen console. -****************************************************************************/ -void PMAPI PM_setSuspendAppCallback( - PM_saveState_cb saveState) -{ - /* Not used in NT drivers */ - (void)saveState; -} - -/**************************************************************************** -REMARKS: -Restore the console state. -****************************************************************************/ -void PMAPI PM_restoreConsoleState( - const void *stateBuf, - PM_HWND hwndConsole) -{ - /* Not used in NT drivers */ - (void)stateBuf; - (void)hwndConsole; -} - -/**************************************************************************** -REMARKS: -Close the fullscreen console. -****************************************************************************/ -void PMAPI PM_closeConsole( - PM_HWND hwndConsole) -{ - /* Not used in NT drivers */ - (void)hwndConsole; -} - -/**************************************************************************** -REMARKS: -Set the location of the OS console cursor. -****************************************************************************/ -void PMAPI PM_setOSCursorLocation( - int x, - int y) -{ - /* Nothing to do for Windows */ - (void)x; - (void)y; -} - -/**************************************************************************** -REMARKS: -Set the width of the OS console. -****************************************************************************/ -void PMAPI PM_setOSScreenWidth( - int width, - int height) -{ - /* Nothing to do for Windows */ - (void)width; - (void)height; -} - -/**************************************************************************** -REMARKS: -Maps a shared memory block into process address space. Does nothing since -the memory blocks are already globally mapped into all processes. -****************************************************************************/ -void * PMAPI PM_mapToProcess( - void *base, - ulong limit) -{ - /* Not used anymore */ - (void)base; - (void)limit; - return NULL; -} - -/**************************************************************************** -REMARKS: -Execute the POST on the secondary BIOS for a controller. -****************************************************************************/ -ibool PMAPI PM_doBIOSPOST( - ushort axVal, - ulong BIOSPhysAddr, - void *mappedBIOS, - ulong BIOSLen) -{ - /* This may not be possible in NT and should be done by the OS anyway */ - (void)axVal; - (void)BIOSPhysAddr; - (void)mappedBIOS; - (void)BIOSLen; - return false; -} - -/**************************************************************************** -REMARKS: -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! */ - return PM_mapPhysicalAddr(0x400, 0x1000, true); -} - -/**************************************************************************** -REMARKS: -Return a pointer to 0xA0000 physical VGA graphics framebuffer. -****************************************************************************/ -void * PMAPI PM_getA0000Pointer(void) -{ - return PM_mapPhysicalAddr(0xA0000,0xFFFF,false); -} - -/**************************************************************************** -REMARKS: -Sleep for the specified number of milliseconds. -****************************************************************************/ -void PMAPI PM_sleep( - ulong milliseconds) -{ - /* We never use this in NT drivers */ - (void)milliseconds; -} - -/**************************************************************************** -REMARKS: -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. */ - switch (port) { - case 0: return 0x3F8; - case 1: return 0x2F8; - case 2: return 0x3E8; - case 3: return 0x2E8; - } - return 0; -} - -/**************************************************************************** -REMARKS: -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. */ - switch (port) { - case 0: return 0x3BC; - case 1: return 0x378; - case 2: return 0x278; - } - return 0; -} - -/**************************************************************************** -REMARKS: -Returns available memory. Not possible under Windows. -****************************************************************************/ -void PMAPI PM_availableMemory( - ulong *physical, - ulong *total) -{ - *physical = *total = 0; -} - -/**************************************************************************** -REMARKS: -OS specific shared libraries not supported inside a VxD -****************************************************************************/ -PM_MODULE PMAPI PM_loadLibrary( - const char *szDLLName) -{ - /* Not used in NT drivers */ - (void)szDLLName; - return NULL; -} - -/**************************************************************************** -REMARKS: -OS specific shared libraries not supported inside a VxD -****************************************************************************/ -void * PMAPI PM_getProcAddress( - PM_MODULE hModule, - const char *szProcName) -{ - /* Not used in NT drivers */ - (void)hModule; - (void)szProcName; - return NULL; -} - -/**************************************************************************** -REMARKS: -OS specific shared libraries not supported inside a VxD -****************************************************************************/ -void PMAPI PM_freeLibrary( - PM_MODULE hModule) -{ - /* Not used in NT drivers */ - (void)hModule; -} - -/**************************************************************************** -REMARKS: -Function to find the first file matching a search criteria in a directory. -****************************************************************************/ -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. */ - (void)filename; - (void)findData; - return PM_FILE_INVALID; -} - -/**************************************************************************** -REMARKS: -Function to find the next file matching a search criteria in a directory. -****************************************************************************/ -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. */ - (void)handle; - (void)findData; - return false; -} - -/**************************************************************************** -REMARKS: -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. */ - (void)handle; -} - -/**************************************************************************** -REMARKS: -Function to determine if a drive is a valid drive or not. Under Unix this -function will return false for anything except a value of 3 (considered -the root drive, and equivalent to C: for non-Unix systems). The drive -numbering is: - - 1 - Drive A: - 2 - Drive B: - 3 - Drive C: - etc - -****************************************************************************/ -ibool PMAPI PM_driveValid( - char drive) -{ - /* Not supported in NT drivers */ - (void)drive; - return false; -} - -/**************************************************************************** -REMARKS: -Function to get the current working directory for the specififed drive. -Under Unix this will always return the current working directory regardless -of what the value of 'drive' is. -****************************************************************************/ -void PMAPI PM_getdcwd( - int drive, - char *dir, - int len) -{ - /* Not supported in NT drivers */ - (void)drive; - (void)dir; - (void)len; -} - -/**************************************************************************** -PARAMETERS: -base - The starting physical base address of the region -size - The size in bytes of the region -type - Type to place into the MTRR register - -RETURNS: -Error code describing the result. - -REMARKS: -Function to enable write combining for the specified region of memory. -****************************************************************************/ -int PMAPI PM_enableWriteCombine( - ulong base, - ulong size, - uint type) -{ - return MTRR_enableWriteCombine(base,size,type); -} - -/**************************************************************************** -REMARKS: -Function to change the file attributes for a specific file. -****************************************************************************/ -void PMAPI PM_setFileAttr( - const char *filename, - uint attrib) -{ - NTSTATUS status; - ACCESS_MASK DesiredAccess = GENERIC_READ | GENERIC_WRITE; - OBJECT_ATTRIBUTES ObjectAttributes; - ULONG ShareAccess = FILE_SHARE_READ; - ULONG CreateDisposition = FILE_OPEN; - HANDLE FileHandle = NULL; - UNICODE_STRING *uniFile = NULL; - IO_STATUS_BLOCK IoStatusBlock; - FILE_BASIC_INFORMATION FileBasic; - char kernelFilename[PM_MAX_PATH+5]; - ULONG FileAttributes = 0; - - /* Convert file attribute flags */ - if (attrib & PM_FILE_READONLY) - FileAttributes |= FILE_ATTRIBUTE_READONLY; - if (attrib & PM_FILE_ARCHIVE) - FileAttributes |= FILE_ATTRIBUTE_ARCHIVE; - if (attrib & PM_FILE_HIDDEN) - FileAttributes |= FILE_ATTRIBUTE_HIDDEN; - if (attrib & PM_FILE_SYSTEM) - FileAttributes |= FILE_ATTRIBUTE_SYSTEM; - - /* Add prefix for addressing the file system. "\??\" is short for "\DosDevices\" */ - strcpy(kernelFilename, "\\??\\"); - strcat(kernelFilename, filename); - - /* Convert filename string to ansi string */ - if ((uniFile = _PM_CStringToUnicodeString(kernelFilename)) == NULL) - goto Exit; - - /* Must open a file to query it's attributes */ - InitializeObjectAttributes (&ObjectAttributes, - 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) */ - ); - if (!NT_SUCCESS (status)) - goto Exit; - - /* Query timestamps */ - status = ZwQueryInformationFile(FileHandle, - &IoStatusBlock, - &FileBasic, - sizeof(FILE_BASIC_INFORMATION), - FileBasicInformation - ); - if (!NT_SUCCESS (status)) - goto Exit; - - /* Change the four bits we change */ - FileBasic.FileAttributes &= ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_ARCHIVE - | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM); - FileBasic.FileAttributes |= FileAttributes; - - /* Set timestamps */ - ZwSetInformationFile( FileHandle, - &IoStatusBlock, - &FileBasic, - sizeof(FILE_BASIC_INFORMATION), - FileBasicInformation - ); - -Exit: - if (FileHandle) ZwClose(FileHandle); - if (uniFile) _PM_FreeUnicodeString(uniFile); - return; -} - -/**************************************************************************** -REMARKS: -Function to get the file attributes for a specific file. -****************************************************************************/ -uint PMAPI PM_getFileAttr( - const char *filename) -{ - NTSTATUS status; - ACCESS_MASK DesiredAccess = GENERIC_READ | GENERIC_WRITE; - OBJECT_ATTRIBUTES ObjectAttributes; - ULONG ShareAccess = FILE_SHARE_READ; - ULONG CreateDisposition = FILE_OPEN; - HANDLE FileHandle = NULL; - UNICODE_STRING *uniFile = NULL; - IO_STATUS_BLOCK IoStatusBlock; - FILE_BASIC_INFORMATION FileBasic; - char kernelFilename[PM_MAX_PATH+5]; - ULONG FileAttributes = 0; - uint retval = 0; - - /* Add prefix for addressing the file system. "\??\" is short for "\DosDevices\" */ - strcpy(kernelFilename, "\\??\\"); - strcat(kernelFilename, filename); - - /* Convert filename string to ansi string */ - if ((uniFile = _PM_CStringToUnicodeString(kernelFilename)) == NULL) - goto Exit; - - /* Must open a file to query it's attributes */ - InitializeObjectAttributes (&ObjectAttributes, - 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) */ - ); - if (!NT_SUCCESS (status)) - goto Exit; - - /* Query timestamps */ - status = ZwQueryInformationFile(FileHandle, - &IoStatusBlock, - &FileBasic, - sizeof(FILE_BASIC_INFORMATION), - FileBasicInformation - ); - if (!NT_SUCCESS (status)) - goto Exit; - - /* Translate the file attributes */ - if (FileBasic.FileAttributes & FILE_ATTRIBUTE_READONLY) - retval |= PM_FILE_READONLY; - if (FileBasic.FileAttributes & FILE_ATTRIBUTE_ARCHIVE) - retval |= PM_FILE_ARCHIVE; - if (FileBasic.FileAttributes & FILE_ATTRIBUTE_HIDDEN) - retval |= PM_FILE_HIDDEN; - if (FileBasic.FileAttributes & FILE_ATTRIBUTE_SYSTEM) - retval |= PM_FILE_SYSTEM; - -Exit: - if (FileHandle) ZwClose(FileHandle); - if (uniFile) _PM_FreeUnicodeString(uniFile); - return retval; -} - -/**************************************************************************** -REMARKS: -Function to create a directory. -****************************************************************************/ -ibool PMAPI PM_mkdir( - const char *filename) -{ - /* Not supported in NT drivers */ - (void)filename; - return false; -} - -/**************************************************************************** -REMARKS: -Function to remove a directory. -****************************************************************************/ -ibool PMAPI PM_rmdir( - const char *filename) -{ - /* Not supported in NT drivers */ - (void)filename; - return false; -} - -/**************************************************************************** -REMARKS: -Function to get the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_getFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - /* Not supported in NT drivers */ - (void)filename; - (void)gmTime; - (void)time; - return false; -} - -/**************************************************************************** -REMARKS: -Function to set the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_setFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - /* 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 deleted file mode 100644 index 658f1c80ab..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdio.c +++ /dev/null @@ -1,330 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit Windows NT driver -* -* Description: C library compatible I/O functions for use within a Windows -* NT driver. -* -****************************************************************************/ - -#include "pmapi.h" -#include "oshdr.h" - -/*------------------------ Main Code Implementation -----------------------*/ - -/**************************************************************************** -REMARKS: -NT driver implementation of the ANSI C fopen function. -****************************************************************************/ -FILE * fopen( - const char *filename, - const char *mode) -{ - ACCESS_MASK DesiredAccess; /* for ZwCreateFile... */ - OBJECT_ATTRIBUTES ObjectAttributes; - ULONG ShareAccess; - ULONG CreateDisposition; - NTSTATUS status; - HANDLE FileHandle; - UNICODE_STRING *uniFile = NULL; - PWCHAR bufFile = NULL; - IO_STATUS_BLOCK IoStatusBlock; - FILE_STANDARD_INFORMATION FileInformation; - FILE_POSITION_INFORMATION FilePosition; - char kernelFilename[PM_MAX_PATH+5]; - FILE *f; - - /* 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; - 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; - } - 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; - } - 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; - } - - /* Convert filename string to ansi string and then to UniCode string */ - if ((uniFile = _PM_CStringToUnicodeString(kernelFilename)) == NULL) - return NULL; - - /* Create the file */ - InitializeObjectAttributes (&ObjectAttributes, - 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) */ - ); - if (!NT_SUCCESS (status)) - goto Error; - f->handle = (int)FileHandle; - - /* Determine size of the file */ - status = ZwQueryInformationFile( FileHandle, - &IoStatusBlock, - &FileInformation, - sizeof(FILE_STANDARD_INFORMATION), - FileStandardInformation - ); - if (!NT_SUCCESS (status)) - goto Error; - f->filesize = FileInformation.EndOfFile.LowPart; - - /* 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; - } - return f; - -Error: - if (f) PM_free(f); - if (uniFile) _PM_FreeUnicodeString(uniFile); - return NULL; -} - -/**************************************************************************** -REMARKS: -NT driver implementation of the ANSI C fread function. -****************************************************************************/ -size_t fread( - void *ptr, - size_t size, - size_t n, - FILE *f) -{ - NTSTATUS status; - IO_STATUS_BLOCK IoStatusBlock; - LARGE_INTEGER ByteOffset; - - /* 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 */ - ); - if (!NT_SUCCESS (status)) - return 0; - f->offset += IoStatusBlock.Information; - return IoStatusBlock.Information / size; -} - -/**************************************************************************** -REMARKS: -NT driver implementation of the ANSI C fwrite function. -****************************************************************************/ -size_t fwrite( - const void *ptr, - size_t size, - size_t n, - FILE *f) -{ - NTSTATUS status; - IO_STATUS_BLOCK IoStatusBlock; - LARGE_INTEGER ByteOffset; - - if (!f->writemode) - 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 */ - ); - if (!NT_SUCCESS (status)) - return 0; - f->offset += IoStatusBlock.Information; - if (f->offset > f->filesize) - f->filesize = f->offset; - return IoStatusBlock.Information / size; -} - -/**************************************************************************** -REMARKS: -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 */ - (void)f; - return 0; -} - -/**************************************************************************** -REMARKS: -NT driver implementation of the ANSI C fseek function. -****************************************************************************/ -int fseek( - FILE *f, - long int offset, - int whence) -{ - NTSTATUS status; - FILE_POSITION_INFORMATION FilePosition; - IO_STATUS_BLOCK IoStatusBlock; - - if (whence == 0) - f->offset = offset; - else if (whence == 1) - f->offset += offset; - else if (whence == 2) - 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 - ); - if (!NT_SUCCESS (status)) - return -1; - return 0; -} - -/**************************************************************************** -REMARKS: -NT driver implementation of the ANSI C ftell function. -****************************************************************************/ -long ftell( - FILE *f) -{ - return f->offset; -} - -/**************************************************************************** -REMARKS: -NT driver implementation of the ANSI C feof function. -****************************************************************************/ -int feof( - FILE *f) -{ - return (f->offset == f->filesize); -} - -/**************************************************************************** -REMARKS: -NT driver implementation of the ANSI C fgets function. -****************************************************************************/ -char *fgets( - char *s, - int n, - FILE *f) -{ - int len; - char *cs; - - /* Read the entire buffer into memory (our functions are unbuffered!) */ - if ((len = fread(s,1,n,f)) == 0) - return NULL; - - /* Search for '\n' or end of string */ - if (n > len) - n = len; - cs = s; - while (--n > 0) { - if (*cs == '\n') - break; - cs++; - } - *cs = '\0'; - return s; -} - -/**************************************************************************** -REMARKS: -NT driver implementation of the ANSI C fputs function. -****************************************************************************/ -int fputs( - const char *s, - FILE *f) -{ - return fwrite(s,1,strlen(s),f); -} - -/**************************************************************************** -REMARKS: -NT driver implementation of the ANSI C fclose function. -****************************************************************************/ -int fclose( - FILE *f) -{ - ZwClose((HANDLE)f->handle); - 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 deleted file mode 100644 index bbf0cbf4a7..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdlib.c +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit Windows NT driver -* -* Description: C library compatible stdlib.h functions for use within a -* Windows NT driver. -* -****************************************************************************/ - -#include "pmapi.h" -#include "oshdr.h" - -/*------------------------ Main Code Implementation -----------------------*/ - -/**************************************************************************** -REMARKS: -PM_malloc override function for Nucleus drivers loaded in NT drivers's. -****************************************************************************/ -void * malloc( - size_t size) -{ - return PM_mallocShared(size); -} - -/**************************************************************************** -REMARKS: -calloc library function for Nucleus drivers loaded in NT drivers's. -****************************************************************************/ -void * calloc( - size_t nelem, - size_t size) -{ - void *p = PM_mallocShared(nelem * size); - if (p) - memset(p,0,nelem * size); - return p; -} - -/**************************************************************************** -REMARKS: -PM_realloc override function for Nucleus drivers loaded in VxD's. -****************************************************************************/ -void * realloc( - void *ptr, - size_t size) -{ - void *p = PM_mallocShared(size); - if (p) { - memcpy(p,ptr,size); - PM_freeShared(ptr); - } - return p; -} - -/**************************************************************************** -REMARKS: -PM_free override function for Nucleus drivers loaded in VxD's. -****************************************************************************/ -void free( - void *p) -{ - PM_freeShared(p); -} - -/**************************************************************************** -PARAMETERS: -cstr - C style ANSI string to convert - -RETURNS: -Pointer to the UniCode string structure or NULL on failure to allocate memory - -REMARKS: -Converts a C style string to a UniCode string structure that can be passed -directly to NT kernel functions. -****************************************************************************/ -UNICODE_STRING *_PM_CStringToUnicodeString( - const char *cstr) -{ - int length; - ANSI_STRING ansiStr; - UNICODE_STRING *uniStr; - - /* Allocate memory for the string structure */ - if ((uniStr = ExAllocatePool(NonPagedPool, sizeof(UNICODE_STRING))) == NULL) - return NULL; - - /* 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; - } - RtlZeroMemory(uniStr->Buffer, length); - uniStr->Length = 0; - uniStr->MaximumLength = (USHORT)length; - - /* Convert filename string to ansi string and then to UniCode string */ - RtlInitAnsiString(&ansiStr, cstr); - RtlAnsiStringToUnicodeString(uniStr, &ansiStr, FALSE); - return uniStr; -} - -/**************************************************************************** -PARAMETERS: -uniStr - UniCode string structure to free - -REMARKS: -Frees a string allocated by the above _PM_CStringToUnicodeString function. -****************************************************************************/ -void _PM_FreeUnicodeString( - UNICODE_STRING *uniStr) -{ - if (uniStr) { - ExFreePool(uniStr->Buffer); - ExFreePool(uniStr); - } -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/vflat.c b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/vflat.c deleted file mode 100644 index 901ce1cf03..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/vflat.c +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Dummy module; no virtual framebuffer for this OS -* -****************************************************************************/ - -#include "pmapi.h" - -ibool PMAPI VF_available(void) -{ - return false; -} - -void * PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) -{ - return NULL; -} - -void PMAPI VF_exit(void) -{ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/ztimer.c deleted file mode 100644 index f4c4bd41b2..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/ztimer.c +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit Windows VxD -* -* Description: OS specific implementation for the Zen Timer functions. -* -****************************************************************************/ - -/*---------------------------- Global variables ---------------------------*/ - -static CPU_largeInteger countFreq; -static ulong start,finish; - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Initialise the Zen Timer module internals. -****************************************************************************/ -static void __ZTimerInit(void) -{ - KeQueryPerformanceCounter((LARGE_INTEGER*)&countFreq); -} - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -static void __LZTimerOn( - LZTimerObject *tm) -{ - LARGE_INTEGER lt = KeQueryPerformanceCounter(NULL); - tm->start.low = lt.LowPart; - tm->start.high = lt.HighPart; -} - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -static ulong __LZTimerLap( - LZTimerObject *tm) -{ - LARGE_INTEGER tmLap = KeQueryPerformanceCounter(NULL); - CPU_largeInteger tmCount; - - _CPU_diffTime64(&tm->start,(CPU_largeInteger*)&tmLap,&tmCount); - return _CPU_calcMicroSec(&tmCount,countFreq.low); -} - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -static void __LZTimerOff( - LZTimerObject *tm) -{ - LARGE_INTEGER lt = KeQueryPerformanceCounter(NULL); - tm->end.low = lt.LowPart; - tm->end.high = lt.HighPart; -} - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -static ulong __LZTimerCount( - LZTimerObject *tm) -{ - CPU_largeInteger tmCount; - - _CPU_diffTime64(&tm->start,&tm->end,&tmCount); - return _CPU_calcMicroSec(&tmCount,countFreq.low); -} - -/**************************************************************************** -REMARKS: -Define the resolution of the long period timer as microseconds per timer tick. -****************************************************************************/ -#define ULZTIMER_RESOLUTION 1 - -/**************************************************************************** -REMARKS: -Read the Long Period timer value from the BIOS timer tick. -****************************************************************************/ -static ulong __ULZReadTime(void) -{ - LARGE_INTEGER count; - KeQuerySystemTime(&count); - return (ulong)(*((_int64*)&count) / 10); -} - -/**************************************************************************** -REMARKS: -Compute the elapsed time from the BIOS timer tick. Note that we check to see -whether a midnight boundary has passed, and if so adjust the finish time to -account for this. We cannot detect if more that one midnight boundary has -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/_pmos2.asm b/board/MAI/bios_emulator/scitech/src/pm/os2/_pmos2.asm deleted file mode 100644 index 761f0f42e1..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/os2/_pmos2.asm +++ /dev/null @@ -1,180 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: 80386 Assembler, TASM 4.0 or NASM -;* Environment: OS/2 32 bit protected mode -;* -;* Description: Low level assembly support for the PM library specific -;* to OS/2 -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -header _pmos2 ; Set up memory model - -begdataseg _pmos2 - - cglobal _PM_ioentry - cglobal _PM_gdt -_PM_ioentry dd 0 ; Offset to call gate -_PM_gdt dw 0 ; Selector to call gate - -enddataseg _pmos2 - -begcodeseg _pmos2 ; Start of code segment - -;---------------------------------------------------------------------------- -; int PM_setIOPL(int iopl) -;---------------------------------------------------------------------------- -; Change the IOPL level for the 32-bit task. Returns the previous level -; so it can be restored for the task correctly. -;---------------------------------------------------------------------------- -cprocstart PM_setIOPL - - ARG iopl:UINT - - enter_c - pushfd ; Save the old EFLAGS for later - mov ecx,[iopl] ; ECX := IOPL level - xor ebx,ebx ; Change IOPL level function code (0) -ifdef USE_NASM - call far dword [_PM_ioentry] -else - call [FWORD _PM_ioentry] -endif - pop eax - and eax,0011000000000000b - shr eax,12 - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _PM_setGDTSelLimit(ushort selector, ulong limit); -;---------------------------------------------------------------------------- -; Change the GDT selector limit to given value. Used to change selector -; limits to address the entire system address space. -;---------------------------------------------------------------------------- -cprocstart _PM_setGDTSelLimit - - ARG selector:USHORT, limit:UINT - - enter_c - sub esp,20 ; Make room for selector data on stack - mov ecx,esp ; ECX := selector data structure - mov bx,[selector] ; Fill out the data structure - and bx,0FFF8h ; Kick out the LDT/GDT and DPL bits - mov [WORD ecx],bx - mov ebx,[limit] - mov [DWORD ecx+4],ebx - mov ebx,5 ; Set GDT selector limit function code -ifdef USE_NASM - call far dword [_PM_ioentry] -else - call [FWORD _PM_ioentry] -endif - add esp,20 - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; uchar _MTRR_getCx86(uchar reg); -;---------------------------------------------------------------------------- -; Read a Cyrix CPU indexed register -;---------------------------------------------------------------------------- -cprocstart _MTRR_getCx86 - - ARG reg:UCHAR - - enter_c - mov al,[reg] - out 22h,al - in al,23h - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; uchar _MTRR_setCx86(uchar reg,uchar val); -;---------------------------------------------------------------------------- -; Write a Cyrix CPU indexed register -;---------------------------------------------------------------------------- -cprocstart _MTRR_setCx86 - - ARG reg:UCHAR, val:UCHAR - - enter_c - mov al,[reg] - out 22h,al - mov al,[val] - out 23h,al - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; ulong _MTRR_disableInt(void); -;---------------------------------------------------------------------------- -; Return processor interrupt status and disable interrupts. -;---------------------------------------------------------------------------- -cprocstart _MTRR_disableInt - -; Do nothing! - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _MTRR_restoreInt(ulong ps); -;---------------------------------------------------------------------------- -; Restore processor interrupt status. -;---------------------------------------------------------------------------- -cprocstart _MTRR_restoreInt - -; Do nothing! - ret - -cprocend - -;---------------------------------------------------------------------------- -; void DebugInt(void) -;---------------------------------------------------------------------------- -cprocstart DebugInt - - int 3 - ret - -cprocend - -endcodeseg _pmos2 - - END ; End of module - diff --git a/board/MAI/bios_emulator/scitech/src/pm/os2/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/os2/cpuinfo.c deleted file mode 100644 index 7de400d067..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/os2/cpuinfo.c +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: OS/2 -* -* Description: OS/2 specific code for the CPU detection module. -* -****************************************************************************/ - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -TODO: This should be implemented for OS/2! -****************************************************************************/ -#define SetMaxThreadPriority() 0 - -/**************************************************************************** -REMARKS: -TODO: This should be implemented for OS/2! -****************************************************************************/ -#define RestoreThreadPriority(i) - -/**************************************************************************** -REMARKS: -Initialise the counter and return the frequency of the counter. -****************************************************************************/ -static void GetCounterFrequency( - CPU_largeInteger *freq) -{ - freq->low = 100000; - freq->high = 0; -} - -/**************************************************************************** -REMARKS: -Read the counter and return the counter value. -****************************************************************************/ -#define GetCounter(t) \ -{ \ - ULONG count; \ - DosQuerySysInfo( QSV_MS_COUNT, QSV_MS_COUNT, &count, sizeof(ULONG) ); \ - (t)->low = count * 100; \ - (t)->high = 0; \ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/os2/event.c b/board/MAI/bios_emulator/scitech/src/pm/os2/event.c deleted file mode 100644 index 91cc19b915..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/os2/event.c +++ /dev/null @@ -1,565 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: IBM PC (OS/2) -* -* Description: OS/2 implementation for the SciTech cross platform -* event library. -* -****************************************************************************/ - -/*---------------------------- Global Variables ---------------------------*/ - -/* Define generous keyboard monitor circular buffer size to minimize - * the danger of losing keystrokes - */ -#define KEYBUFSIZE (EVENTQSIZE + 10) - -static int oldMouseState; /* Old mouse state */ -static ulong oldKeyMessage; /* Old keyboard state */ -static ushort keyUpMsg[256] = {0}; /* Table of key up messages */ -static int rangeX,rangeY; /* Range of mouse coordinates */ -HMOU _EVT_hMouse; /* Handle to the mouse driver */ -HMONITOR _EVT_hKbdMon; /* Handle to the keyboard driver */ -TID kbdMonTID = 0; /* Keyboard monitor thread ID */ -HEV hevStart; /* Start event semaphore handle */ -BOOL bMonRunning; /* Flag set if monitor thread OK */ -HMTX hmtxKeyBuf; /* Mutex protecting key buffer */ -KEYPACKET keyMonPkts[KEYBUFSIZE]; /* Array of monitor key packets */ -int kpHead = 0; /* Key packet buffer head */ -int kpTail = 0; /* Key packet buffer tail */ - -/*---------------------------- Implementation -----------------------------*/ - -/* These are not used under OS/2 */ -#define _EVT_disableInt() 1 -#define _EVT_restoreInt(flags) - -/**************************************************************************** -PARAMETERS: -scanCode - Scan code to test - -REMARKS: -This macro determines if a specified key is currently down at the -time that the call is made. -****************************************************************************/ -#define _EVT_isKeyDown(scanCode) (keyUpMsg[scanCode] != 0) - -/**************************************************************************** -REMARKS: -This function is used to return the number of ticks since system -startup in milliseconds. This should be the same value that is placed into -the time stamp fields of events, and is used to implement auto mouse down -events. -****************************************************************************/ -ulong _EVT_getTicks(void) -{ - ULONG count; - DosQuerySysInfo( QSV_MS_COUNT, QSV_MS_COUNT, &count, sizeof(ULONG) ); - return count; -} - -/**************************************************************************** -REMARKS: -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. */ - return mickey; -} - -/* Some useful defines any typedefs used in the keyboard handling */ -#define KEY_RELEASE 0x40 - -/**************************************************************************** -REMARKS: -Pumps all messages in the message queue from OS/2 into our event queue. -****************************************************************************/ -static void _EVT_pumpMessages(void) -{ - KBDINFO keyInfo; /* Must not cross a 64K boundary */ - KBDKEYINFO key; /* Must not cross a 64K boundary */ - MOUQUEINFO mqueue; /* Must not cross a 64K boundary */ - MOUEVENTINFO mouse; /* Must not cross a 64K boundary */ - ushort mWait; /* Must not cross a 64K boundary */ - KEYPACKET kp; /* Must not cross a 64K boundary */ - event_t evt; - int scan; - ibool noInput = TRUE; /* Flag to determine if any input was available */ - - /* First of all, check if we should do any session switch work */ - __PM_checkConsoleSwitch(); - - /* 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); - } - - /* Don't just flush because that terminally confuses the monitor */ - do { - 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; - } - - /* 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); -} - -/**************************************************************************** -REMARKS: -This macro/function is used to converts the scan codes reported by the -keyboard to our event libraries normalised format. We only have one scan -code for the 'A' key, and use shift modifiers to determine if it is a -Ctrl-F1, Alt-F1 etc. The raw scan codes from the keyboard work this way, -but the OS gives us 'cooked' scan codes, we have to translate them back -to the raw format. -****************************************************************************/ -#define _EVT_maskKeyCode(evt) - -/**************************************************************************** -REMARKS: -Keyboard monitor thread. Needed to catch both keyup and keydown events. -****************************************************************************/ -static void _kbdMonThread( - void *params) -{ - APIRET rc; - KEYPACKET kp; - USHORT count = sizeof(KEYPACKET); - MONBUF monInbuf; - MONBUF monOutbuf; - int kpNew; - - /* Raise thread priority for higher responsiveness */ - DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0); - monInbuf.cb = sizeof(monInbuf) - sizeof(monInbuf.cb); - monOutbuf.cb = sizeof(monOutbuf) - sizeof(monOutbuf.cb); - bMonRunning = FALSE; - - /* 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; - } - - /* 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) { -#ifdef CHECKED - if (bMonRunning) - printf("Error in DosMonRead, rc = %ld\n", rc); -#endif - bMonRunning = FALSE; - return; - } - - /* Pass FLUSH packets immediately */ - if (kp.MonFlagWord & 4) { -#ifdef CHECKED - 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) { -#ifdef CHECKED - 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) { -#ifdef CHECKED - if (bMonRunning) - printf("Error in DosMonWrite, rc = %ld\n", rc); -#endif - bMonRunning = FALSE; - return; - } - } - (void)params; -} - -/**************************************************************************** -REMARKS: -Safely abort the event module upon catching a fatal error. -****************************************************************************/ -void _EVT_abort( - int signal) -{ - EVT_exit(); - PM_fatalError("Unhandled exception!"); -} - -/**************************************************************************** -PARAMETERS: -mouseMove - Callback function to call wheneve the mouse needs to be moved - -REMARKS: -Initiliase the event handling module. Here we install our mouse handling ISR -to be called whenever any button's are pressed or released. We also build -the free list of events in the event queue. - -We use handler number 2 of the mouse libraries interrupt handlers for our -event handling routines. -****************************************************************************/ -void EVTAPI EVT_init( - _EVT_mouseMoveHandler mouseMove) -{ - ushort stat; - - /* Initialise the event queue */ - PM_init(); - EVT.mouseMove = mouseMove; - initEventQueue(); - oldMouseState = 0; - oldKeyMessage = 0; - memset(keyUpMsg,0,sizeof(keyUpMsg)); - - /* Open the mouse driver, and set it up to report events in mickeys */ - MouOpen(NULL,&_EVT_hMouse); - stat = 0x7F; - MouSetEventMask(&stat,_EVT_hMouse); - stat = (MOU_NODRAW | MOU_MICKEYS) << 8; - MouSetDevStatus(&stat,_EVT_hMouse); - - /* Open the keyboard monitor */ - if (DosMonOpen((PSZ)"KBD$", &_EVT_hKbdMon)) - 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!"); - - /* Create mutex semaphore protecting the keypacket buffer */ - if (DosCreateMutexSem(NULL, &hmtxKeyBuf, 0, FALSE)) - PM_fatalError("Unable to create mutex semaphore!"); - - /* Start keyboard monitor thread, use 32K stack */ - kbdMonTID = _beginthread(_kbdMonThread, NULL, 0x8000, NULL); - - /* Now block until the monitor thread is up and running */ - /* 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!"); - } - - /* Catch program termination signals so we can clean up properly */ - signal(SIGABRT, _EVT_abort); - signal(SIGFPE, _EVT_abort); - signal(SIGINT, _EVT_abort); -} - -/**************************************************************************** -REMARKS -Changes the range of coordinates returned by the mouse functions to the -specified range of values. This is used when changing between graphics -modes set the range of mouse coordinates for the new display mode. -****************************************************************************/ -void EVTAPI EVT_setMouseRange( - int xRes, - int yRes) -{ - rangeX = xRes; - rangeY = yRes; -} - -/**************************************************************************** -REMARKS -Modifes the mouse coordinates as necessary if scaling to OS coordinates, -and sets the OS mouse cursor position. -****************************************************************************/ -#define _EVT_setMousePos(x,y) - -/**************************************************************************** -REMARKS: -Initiailises the internal event handling modules. The EVT_suspend function -can be called to suspend event handling (such as when shelling out to DOS), -and this function can be used to resume it again later. -****************************************************************************/ -void EVT_resume(void) -{ - /* Do nothing for OS/2 */ -} - -/**************************************************************************** -REMARKS -Suspends all of our event handling operations. This is also used to -de-install the event handling code. -****************************************************************************/ -void EVT_suspend(void) -{ - /* Do nothing for OS/2 */ -} - -/**************************************************************************** -REMARKS -Exits the event module for program terminatation. -****************************************************************************/ -void EVT_exit(void) -{ - APIRET rc; - - /* Restore signal handlers */ - signal(SIGABRT, SIG_DFL); - signal(SIGFPE, SIG_DFL); - signal(SIGINT, SIG_DFL); - - /* Close the mouse driver */ - MouClose(_EVT_hMouse); - - /* Stop the keyboard monitor thread and close the monitor */ - bMonRunning = FALSE; - rc = DosKillThread(kbdMonTID); -#ifdef CHECKED - if (rc) - printf("DosKillThread failed, rc = %ld\n", rc); -#endif - rc = DosMonClose(_EVT_hKbdMon); -#ifdef CHECKED - if (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 deleted file mode 100644 index 28d39fba4b..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/os2/mon.h +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit OS/2 -* -* Description: Include file to include all OS/2 keyboard monitor stuff. -* -****************************************************************************/ - -/* Monitors stuff */ - -#define MONITOR_DEFAULT 0x0000 -#define MONITOR_BEGIN 1 -#define MONITOR_END 2 - -typedef SHANDLE HMONITOR; -typedef HMONITOR *PHMONITOR; - -typedef struct _KEYPACKET { - USHORT MonFlagWord; - UCHAR XlatedChar; - UCHAR XlatedScan; - UCHAR DBCSStatus; - UCHAR DBCSShift; - - union - { - USHORT ShiftState; - USHORT LayerIndex; - } u; - - ULONG Milliseconds; - USHORT KbdDDFlagWord; -} KEYPACKET; - -typedef struct _MLNPACKET { - USHORT MonFlagWord; - USHORT IOCTL; - USHORT CPId; - USHORT CPIndex; - ULONG Reserved; - 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 */ - - -typedef struct _MONBUF { - USHORT cb; - KEYPACKET Buffer; - 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 */ - - -/* DosMon* prototypes */ -#ifdef __EMX__ - #define APIRET16 USHORT - #define APIENTRY16 -#else - #define DosMonOpen DOS16MONOPEN - #define DosMonClose DOS16MONCLOSE - #define DosMonReg DOS16MONREG - #define DosMonRead DOS16MONREAD - #define DosMonWrite DOS16MONWRITE - #define DosGetInfoSeg DOS16GETINFOSEG -#endif - -APIRET16 APIENTRY16 DosMonOpen (PSZ pszDevName, PHMONITOR phmon); -APIRET16 APIENTRY16 DosMonClose (HMONITOR hmon); -APIRET16 APIENTRY16 DosMonReg (HMONITOR hmon, MONBUF *pbInBuf, /*MONBUF*/ULONG *pbOutBuf, USHORT fPosition, USHORT usIndex); -APIRET16 APIENTRY16 DosMonRead (PBYTE pbInBuf, USHORT fWait, PBYTE pbDataBuf, PUSHORT pcbData); -APIRET16 APIENTRY16 DosMonWrite (PBYTE pbOutBuf, PBYTE pbDataBuf, USHORT cbData); diff --git a/board/MAI/bios_emulator/scitech/src/pm/os2/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/os2/oshdr.h deleted file mode 100644 index e7aa1c6764..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/os2/oshdr.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit OS/2 -* -* Description: Include file to include all OS specific header files. -* -****************************************************************************/ - -#define INCL_DOSPROFILE -#define INCL_DOSERRORS -#define INCL_DOS -#define INCL_SUB -#define INCL_VIO -#define INCL_KBD -#include -#include -#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 deleted file mode 100644 index 756eead1dd..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/os2/pm.c +++ /dev/null @@ -1,2008 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit OS/2 -* -* Description: Implementation for the OS Portability Manager Library, which -* contains functions to implement OS specific services in a -* generic, cross platform API. Porting the OS Portability -* Manager library is the first step to porting any SciTech -* products to a new platform. -* -****************************************************************************/ - -#include "pmapi.h" -#include "drvlib/os/os.h" -#include "pm_help.h" -#include "mtrr.h" -#include -#include -#include -#include -#ifndef __EMX__ -#include -#endif -#define INCL_DOSERRORS -#define INCL_DOS -#define INCL_SUB -#define INCL_VIO -#define INCL_KBD -#include - -/* Semaphore for communication with our background daemon */ -#define SHAREDSEM ((PSZ)"\\SEM32\\SDD\\DAEMON") -#define DAEMON_NAME "SDDDAEMN.EXE" - -/*--------------------------- Global variables ----------------------------*/ - -/* Public structures used to communicate with VIDEOPMI for implementing - * the ability to call the real mode BIOS functions. - */ - -typedef struct _VIDEOMODEINFO { - ULONG miModeId; - USHORT usType; - USHORT usInt10ModeSet; - USHORT usXResolution; - USHORT usYResolution; - ULONG ulBufferAddress; - ULONG ulApertureSize; - BYTE bBitsPerPixel; - BYTE bBitPlanes; - BYTE bXCharSize; - BYTE bYCharSize; - USHORT usBytesPerScanLine; - USHORT usTextRows; - ULONG ulPageLength; - ULONG ulSaveSize; - BYTE bVrtRefresh; - BYTE bHrtRefresh; - BYTE bVrtPolPos; - BYTE bHrtPolPos; - CHAR bRedMaskSize; - CHAR bRedFieldPosition; - CHAR bGreenMaskSize; - CHAR bGreenFieldPosition; - CHAR bBlueMaskSize; - CHAR bBlueFieldPosition; - CHAR bRsvdMaskSize; - CHAR bRsvdFieldPosition; - ULONG ulColors; - ULONG ulReserved[3]; - } VIDEOMODEINFO, FAR *PVIDEOMODEINFO; - -typedef struct _ADAPTERINFO { - ULONG ulAdapterID; - CHAR szOEMString[128]; - CHAR szDACString[128]; - CHAR szRevision[128]; - ULONG ulTotalMemory; - ULONG ulMMIOBaseAddress; - ULONG ulPIOBaseAddress; - BYTE bBusType; - BYTE bEndian; - USHORT usDeviceBusID; - USHORT usVendorBusID; - USHORT SlotID; - } ADAPTERINFO, FAR *PADAPTERINFO; - -typedef struct _VIDEO_ADAPTER { - void *hvideo; - ADAPTERINFO Adapter; - VIDEOMODEINFO ModeInfo; - } VIDEO_ADAPTER, FAR *PVIDEO_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 */ - }INITVDM; - -typedef struct { - BYTE bBufferType; -#define BUFFER_NONE 0 -#define INPUT_BUFFER 1 -#define OUTPUT_BUFFER 2 - BYTE bReserved; - BYTE bSelCRF; - BYTE bOffCRF; - PVOID pAddress; - ULONG ulSize; - } BUFFER, *PBUFFER; - -typedef struct vcrf_s { - ULONG reg_eax; - ULONG reg_ebx; - ULONG reg_ecx; - ULONG reg_edx; - ULONG reg_ebp; - ULONG reg_esi; - ULONG reg_edi; - ULONG reg_ds; - ULONG reg_es; - ULONG reg_fs; - ULONG reg_gs; - ULONG reg_cs; - ULONG reg_eip; - ULONG reg_eflag; - ULONG reg_ss; - ULONG reg_esp; - } VCRF; - -typedef struct { - ULONG ulBIOSIntNo; - VCRF aCRF; - BUFFER pB[2]; - } INTCRF; - -#define PMIREQUEST_LOADPMIFILE 21 -#define PMIREQUEST_IDENTIFYADAPTER 22 -#define PMIREQUEST_SOFTWAREINT 23 - -#ifdef PTR_DECL_IN_FRONT -#define EXPENTRYP * EXPENTRY -#else -#define EXPENTRYP EXPENTRY * -#endif - -/* Entry point to VIDEOPMI32Request. This may be overridden by external - * code that has already loaded VIDEOPMI to avoid loading it twice. - */ - -APIRET (EXPENTRYP PM_VIDEOPMI32Request)(PVIDEO_ADAPTER, ULONG, PVOID, PVOID) = NULL; -static ibool haveInt10 = -1; /* True if we have Int 10 support */ -static ibool useVPMI = true; /* False if VIDEOPMI unavailable */ -static VIDEO_ADAPTER Adapter; /* Video adapter for VIDEOPMI */ -static uchar RMBuf[1024]; /* Fake real mode transfer buffer */ -static uint VESABuf_len = 1024;/* Length of the VESABuf buffer */ -static void *VESABuf_ptr = NULL;/* Near pointer to VESABuf */ -static uint VESABuf_rseg; /* Real mode segment of VESABuf */ -static uint VESABuf_roff; /* Real mode offset of VESABuf */ -static uchar * lowMem = NULL; -static ibool isSessionSwitching = false; -static ulong parmsIn[4]; /* Must not cross 64Kb boundary! */ -static ulong parmsOut[4]; /* Must not cross 64Kb boundary! */ -extern ushort _PM_gdt; -static void (PMAPIP fatalErrorCleanup)(void) = NULL; - -/* DosSysCtl prototype. It is not declared in the headers but it is in the - * standard import libraries (DOSCALLS.876). Funny. - */ -APIRET APIENTRY DosSysCtl(ULONG ulFunction, PVOID pvData); - -/* This is the stack size for the threads that track the session switch event */ -#define SESSION_SWITCH_STACK_SIZE 32768 - -typedef struct { - VIOMODEINFO vmi; - USHORT CursorX; - USHORT CursorY; - UCHAR FrameBuffer[1]; - } CONSOLE_SAVE; - -typedef struct _SESWITCHREC { - /* The following variable is volatile because of PM_SUSPEND_APP */ - volatile int Flags; /* -1 or PM_DEACTIVATE or PM_REACTIVATE */ - PM_saveState_cb Callback; /* Save/restore context callback */ - HMTX Mutex; /* Exclusive access mutex */ - HEV Event; /* Posted after callback is called */ - } SESWITCHREC; - -/* 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)) -#define FREELIST_NEXT(p) (*(void**)(p)) -typedef struct pageblock { - struct pageblock *next; - struct pageblock *prev; - void *freeListStart; - void *freeList; - void *freeListEnd; - int freeCount; - PM_lockHandle lockHandle; - } pageblock; - -static pageblock *pageBlocks = NULL; - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -PARAMETERS: -func - Helper device driver function to call - -RETURNS: -First return value from the device driver in parmsOut[0] - -REMARKS: -Function to open our helper device driver, call it and close the file -handle. Note that we have to open the device driver for every call because -of two problems: - - 1. We cannot open a single file handle in a DLL that is shared amongst - programs, since every process must have it's own open file handle. - - 2. For some reason there appears to be a limit of about 12 open file - handles on a device driver in the system. Hence when we open more - than about 12 file handles things start to go very strange. - -Hence we simply open the file handle every time that we need to call the -device driver to work around these problems. -****************************************************************************/ -static ulong CallSDDHelp( - int func) -{ - static ulong inLen; /* Must not cross 64Kb boundary! */ - static ulong outLen; /* Must not cross 64Kb boundary! */ - HFILE hSDDHelp; - ULONG rc; - 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!"); - } - 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!"); - DosClose(hSDDHelp); - return parmsOut[0]; -} - -/**************************************************************************** -REMARKS: -Determine if we're running on a DBCS system. -****************************************************************************/ -ibool __IsDBCSSystem(void) -{ - CHAR achDBCSInfo[12]; - COUNTRYCODE ccStruct = {0, 0}; - - memset(achDBCSInfo, 0, 12); - - /* Get the DBCS vector - if it's not empty, we're on DBCS */ - DosQueryDBCSEnv(sizeof(achDBCSInfo), &ccStruct, achDBCSInfo); - if (achDBCSInfo[0] != 0) - return true; - else - return false; -} - -/**************************************************************************** -REMARKS: -Determine if PMSHELL is running - if it isn't, we can't use certain calls -****************************************************************************/ -ibool __isShellLoaded(void) -{ - PVOID ptr; - - if (DosGetNamedSharedMem(&ptr, (PSZ)"\\SHAREMEM\\PMGLOBAL.MEM", PAG_READ) == NO_ERROR) { - DosFreeMem(ptr); - return true; - } - return false; -} - -/**************************************************************************** -REMARKS: -Initialise the PM library and connect to our helper device driver. If we -cannot connect to our helper device driver, we bail out with an error -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!"); - - 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!"); - - /* Initialise the MTRR interface functions */ - MTRR_init(); - } -} - -/**************************************************************************** -REMARKS: -Initialise the PM library for BIOS access via VIDEOPMI. This should work -with any GRADD driver, including SDD/2. -****************************************************************************/ -static ibool InitInt10(void) -{ - HMODULE hModGENPMI,hModSDDPMI,hModVideoPMI; - CHAR buf[80],path[_MAX_PATH]; - HEV hevDaemon = NULLHANDLE; - 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; - } - } - } - } - } - } - return haveInt10; -} - -/**************************************************************************** -REMARKS: -We "probably" have BIOS access under OS/2 but we have to verify/initialize it -first. -****************************************************************************/ -ibool PMAPI PM_haveBIOSAccess(void) -{ - return InitInt10(); -} - -/**************************************************************************** -REMARKS: -Return the operating system type identifier. -****************************************************************************/ -long PMAPI PM_getOSType(void) -{ - return _OS_OS2; -} - -/**************************************************************************** -REMARKS: -Return the runtime type identifier. -****************************************************************************/ -int PMAPI PM_getModeType(void) -{ - return PM_386; -} - -/**************************************************************************** -REMARKS: -Add a file directory separator to the end of the filename. -****************************************************************************/ -void PMAPI PM_backslash( - char *s) -{ - uint pos = strlen(s); - if (s[pos-1] != '\\') { - s[pos] = '\\'; - s[pos+1] = '\0'; - } -} - -/**************************************************************************** -REMARKS: -Add a user defined PM_fatalError cleanup function. -****************************************************************************/ -void PMAPI PM_setFatalErrorCleanup( - void (PMAPIP cleanup)(void)) -{ - fatalErrorCleanup = cleanup; -} - -/**************************************************************************** -REMARKS: -Report a fatal error condition and halt the program. -****************************************************************************/ -void PMAPI PM_fatalError( - const char *msg) -{ - /* Be prepare to be called recursively (failed to fail situation :-) */ - static int fatalErrorCount = 0; - if (fatalErrorCount++ == 0) { - if (fatalErrorCleanup) - fatalErrorCleanup(); - } - fprintf(stderr,"%s\n", msg); - exit(1); -} - -/**************************************************************************** -REMARKS: -Allocate the real mode VESA transfer buffer for communicating with the BIOS. -****************************************************************************/ -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; - } - *len = VESABuf_len; - *rseg = VESABuf_rseg; - *roff = VESABuf_roff; - return VESABuf_ptr; -} - -/**************************************************************************** -REMARKS: -Check if a key has been pressed. -****************************************************************************/ -int PMAPI PM_kbhit(void) -{ - KBDKEYINFO key; /* Must not cross a 64K boundary */ - - KbdPeek(&key, 0); - return (key.fbStatus & KBDTRF_FINAL_CHAR_IN); -} - -/**************************************************************************** -REMARKS: -Wait for and return the next keypress. -****************************************************************************/ -int PMAPI PM_getch(void) -{ - KBDKEYINFO key; /* Must not cross a 64K boundary */ - - KbdCharIn(&key,IO_WAIT,0); - return key.chChar; -} - -/**************************************************************************** -REMARKS: -Open a fullscreen console for output to the screen. This requires that -the application be a fullscreen VIO program. -****************************************************************************/ -PM_HWND PMAPI PM_openConsole( - PM_HWND hwndUser, - int device, - int xRes, - int yRes, - int bpp, - ibool fullScreen) -{ - (void)hwndUser; - (void)device; - (void)xRes; - (void)yRes; - (void)bpp; - (void)fullScreen; - return 0; -} - -/**************************************************************************** -REMARKS: -Find the size of the console state buffer. -****************************************************************************/ -int PMAPI PM_getConsoleStateSize(void) -{ - VIOMODEINFO vmi; - vmi.cb = sizeof (VIOMODEINFO); - VioGetMode (&vmi, (HVIO)0); - return sizeof (CONSOLE_SAVE) - 1 + vmi.col * vmi.row * 2; -} - -/**************************************************************************** -REMARKS: -Save the state of the console. -****************************************************************************/ -void PMAPI PM_saveConsoleState( - void *stateBuf, - PM_HWND hwndConsole) -{ - USHORT fblen; - CONSOLE_SAVE *cs = (CONSOLE_SAVE*)stateBuf; - VIOMODEINFO vmi; - - /* The reason for the VIOMODEINFO juggling is 16-bit code. Because the user - * allocates the state buffer, cd->vmi might be crossing the 64K boundary and - * the 16-bit API would fail. If we create another copy on stack, the compiler - * should ensure that the 64K boundary will not be crossed (it adjusts the stack - * if it should cross). - */ - vmi.cb = sizeof(VIOMODEINFO); - VioGetMode(&vmi,(HVIO)0); - memcpy(&cs->vmi, &vmi, sizeof(VIOMODEINFO)); - VioGetCurPos(&cs->CursorY, &cs->CursorX, (HVIO)0); - fblen = cs->vmi.col * cs->vmi.row * 2; - VioReadCellStr((PCH)cs->FrameBuffer, &fblen, 0, 0, (HVIO)0); -} - -/* Global variable to communicate between threads */ -static SESWITCHREC SesSwitchRec = { -1 }; - -/**************************************************************************** -REMARKS: -Called by external routines at least once per frame to check whenever a -session save/restore should be performed. Since we receive such notifications -asyncronously, we can't perform all required operations at that time. -****************************************************************************/ -void __PM_checkConsoleSwitch(void) -{ - int Flags, Mode; - PM_saveState_cb Callback; - - /* Quick optimized path for most common case */ - if (SesSwitchRec.Flags == -1) - return; - -again: - if (DosRequestMutexSem(SesSwitchRec.Mutex, 100)) - return; - Flags = SesSwitchRec.Flags; - Callback = SesSwitchRec.Callback; - SesSwitchRec.Flags = -1; - DosReleaseMutexSem(SesSwitchRec.Mutex); - - isSessionSwitching = true; /* Prevent VIO calls */ - Mode = Callback(Flags); - 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; - } -} - -/**************************************************************************** -REMARKS: -Waits until main thread processes the session switch event. -****************************************************************************/ -static void _PM_SessionSwitchEvent( - PM_saveState_cb saveState, - int flags) -{ - ULONG Count; - - if (DosRequestMutexSem(SesSwitchRec.Mutex, 10000)) - return; - - /* We're going to wait on that semaphore */ - DosResetEventSem(SesSwitchRec.Event, &Count); - SesSwitchRec.Callback = saveState; - SesSwitchRec.Flags = flags; - DosReleaseMutexSem(SesSwitchRec.Mutex); - - /* Now wait until all required operations are complete */ - DosWaitEventSem (SesSwitchRec.Event, 10000); -} - -/**************************************************************************** -REMARKS: -This is the thread responsible for tracking switches back to our -fullscreen session. -****************************************************************************/ -static void _PM_ConsoleSwitch( - PM_saveState_cb saveState) -{ - USHORT NotifyType; - - for (;;) { - if (VioModeWait(VMWR_POPUP, &NotifyType, 0) != 0) - break; - _PM_SessionSwitchEvent(saveState, PM_REACTIVATE); - } - VioModeUndo(UNDOI_RELEASEOWNER, UNDOK_ERRORCODE, (HVIO)0); -} - -/**************************************************************************** -REMARKS: -This is the thread responsible for tracking screen popups (usually fatal -error handler uses them). -****************************************************************************/ -static void _PM_ConsolePopup( - PM_saveState_cb saveState) -{ - 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); - } - VioSavRedrawUndo(UNDOI_RELEASEOWNER, UNDOK_ERRORCODE, (HVIO)0); -} - -/**************************************************************************** -REMARKS: -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 (__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); - } - } -} - -/**************************************************************************** -REMARKS: -Restore the console state. -****************************************************************************/ -void PMAPI PM_restoreConsoleState( - const void *stateBuf, - PM_HWND hwndConsole) -{ - CONSOLE_SAVE *cs = (CONSOLE_SAVE *)stateBuf; - VIOMODEINFO vmi; - - if (!cs) - return; - - memcpy(&vmi, &cs->vmi, sizeof (VIOMODEINFO)); - VioSetMode(&vmi, (HVIO)0); - VioSetCurPos(cs->CursorY, cs->CursorX, (HVIO)0); - VioWrtCellStr((PCH)cs->FrameBuffer, cs->vmi.col * cs->vmi.row * 2,0, 0, (HVIO)0); -} - -/**************************************************************************** -REMARKS: -Close the fullscreen console. -****************************************************************************/ -void PMAPI PM_closeConsole( - PM_HWND hwndConsole) -{ - /* Kill the threads responsible for tracking console switches */ - PM_setSuspendAppCallback(NULL); - (void)hwndConsole; -} - -/**************************************************************************** -REMARKS: -Set the location of the OS console cursor. -****************************************************************************/ -void PM_setOSCursorLocation( - int x, - int y) -{ - /* 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); -} - -/**************************************************************************** -REMARKS: -Set the width of the OS console. -****************************************************************************/ -void PM_setOSScreenWidth( - int width, - int height) -{ - /* Nothing to do in here */ - (void)width; - (void)height; -} - -/**************************************************************************** -REMARKS: -Set the real time clock handler (used for software stereo modes). -****************************************************************************/ -ibool PMAPI PM_setRealTimeClockHandler( - PM_intHandler ih, - int frequency) -{ - /* TODO: Implement this! */ - (void)ih; - (void)frequency; - return false; -} - -/**************************************************************************** -REMARKS: -Set the real time clock frequency (for stereo modes). -****************************************************************************/ -void PMAPI PM_setRealTimeClockFrequency( - int frequency) -{ - /* TODO: Implement this! */ - (void)frequency; -} - -/**************************************************************************** -REMARKS: -Restore the original real time clock handler. -****************************************************************************/ -void PMAPI PM_restoreRealTimeClockHandler(void) -{ - /* TODO: Implement this! */ -} - -/**************************************************************************** -REMARKS: -Return the current operating system path or working directory. -****************************************************************************/ -char * PMAPI PM_getCurrentPath( - char *path, - int maxLen) -{ - return getcwd(path,maxLen); -} - -/**************************************************************************** -REMARKS: -Return the drive letter for the boot drive. -****************************************************************************/ -char PMAPI PM_getBootDrive(void) -{ - ulong boot = 3; - DosQuerySysInfo(QSV_BOOT_DRIVE,QSV_BOOT_DRIVE,&boot,sizeof(boot)); - return (char)('a' + boot - 1); -} - -/**************************************************************************** -REMARKS: -Return the path to the VBE/AF driver files. -****************************************************************************/ -const char * PMAPI PM_getVBEAFPath(void) -{ - static char path[CCHMAXPATH]; - strcpy(path,"x:\\"); - path[0] = PM_getBootDrive(); - return path; -} - -/**************************************************************************** -REMARKS: -Return the path to the Nucleus driver files. -****************************************************************************/ -const char * PMAPI PM_getNucleusPath(void) -{ - static char path[CCHMAXPATH]; - if (getenv("NUCLEUS_PATH") != NULL) - return getenv("NUCLEUS_PATH"); - strcpy(path,"x:\\os2\\drivers"); - path[0] = PM_getBootDrive(); - PM_backslash(path); - strcat(path,"nucleus"); - return path; -} - -/**************************************************************************** -REMARKS: -Return the path to the Nucleus configuration files. -****************************************************************************/ -const char * PMAPI PM_getNucleusConfigPath(void) -{ - static char path[CCHMAXPATH]; - strcpy(path,PM_getNucleusPath()); - PM_backslash(path); - strcat(path,"config"); - return path; -} - -/**************************************************************************** -REMARKS: -Return a unique identifier for the machine if possible. -****************************************************************************/ -const char * PMAPI PM_getUniqueID(void) -{ - return PM_getMachineName(); -} - -/**************************************************************************** -REMARKS: -Get the name of the machine on the network. -****************************************************************************/ -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; - } - return "OS2"; -} - -/**************************************************************************** -REMARKS: -Return a pointer to the real mode BIOS data area. -****************************************************************************/ -void * PMAPI PM_getBIOSPointer(void) -{ - PM_init(); - return lowMem + 0x400; -} - -/**************************************************************************** -REMARKS: -Return a pointer to 0xA0000 physical VGA graphics framebuffer. -****************************************************************************/ -void * PMAPI PM_getA0000Pointer(void) -{ - PM_init(); - return lowMem + 0xA0000; -} - -/**************************************************************************** -REMARKS: -Map a physical address to a linear address in the callers process. -****************************************************************************/ -void * PMAPI PM_mapPhysicalAddr( - ulong base, - ulong limit, - ibool isCached) -{ - ulong baseAddr,baseOfs,linear; - - /* 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 - * physical address, then we also add an extra offset into the address - * that we return. - */ - baseOfs = base & 4095; - baseAddr = base & ~4095; - limit = ((limit+baseOfs+1+4095) & ~4095)-1; - parmsIn[0] = baseAddr; - parmsIn[1] = limit; - parmsIn[2] = isCached; - if ((linear = CallSDDHelp(PMHELP_MAPPHYS)) == 0) - return NULL; - return (void*)(linear + baseOfs); -} - -/**************************************************************************** -REMARKS: -Free a physical address mapping allocated by PM_mapPhysicalAddr. -****************************************************************************/ -void PMAPI PM_freePhysicalAddr( - void *ptr, - ulong limit) -{ - parmsIn[0] = (ulong)ptr; - parmsIn[1] = limit; - CallSDDHelp(PMHELP_FREEPHYS); -} - -/**************************************************************************** -REMARKS: -Find the physical address of a linear memory address in current process. -****************************************************************************/ -ulong PMAPI PM_getPhysicalAddr( - void *p) -{ - parmsIn[0] = (ulong)p; - return CallSDDHelp(PMHELP_GETPHYSICALADDR); -} - -/**************************************************************************** -REMARKS: -Find the physical address of a linear memory address in current process. -****************************************************************************/ -ibool PMAPI PM_getPhysicalAddrRange( - void *p, - ulong length, - ulong *physAddress) -{ - parmsIn[0] = (ulong)p; - parmsIn[1] = (ulong)length; - parmsIn[2] = (ulong)physAddress; - return CallSDDHelp(PMHELP_GETPHYSICALADDRRANGE); -} - -/**************************************************************************** -REMARKS: -Sleep for the specified number of milliseconds. -****************************************************************************/ -void PMAPI PM_sleep( - ulong milliseconds) -{ - DosSleep(milliseconds); -} - -/**************************************************************************** -REMARKS: -Return the base I/O port for the specified COM port. -****************************************************************************/ -int PMAPI PM_getCOMPort( - int port) -{ - switch (port) { - case 0: return 0x3F8; - case 1: return 0x2F8; - } - return 0; -} - -/**************************************************************************** -REMARKS: -Return the base I/O port for the specified LPT port. -****************************************************************************/ -int PMAPI PM_getLPTPort( - int port) -{ - switch (port) { - case 0: return 0x3BC; - case 1: return 0x378; - case 2: return 0x278; - } - return 0; -} - -/**************************************************************************** -REMARKS: -Allocate a block of shared memory. For Win9x we allocate shared memory -as locked, global memory that is accessible from any memory context -(including interrupt time context), which allows us to load our important -data structure and code such that we can access it directly from a ring -0 interrupt context. -****************************************************************************/ -void * PMAPI PM_mallocShared( - long size) -{ - parmsIn[0] = size; - return (void*)CallSDDHelp(PMHELP_MALLOCSHARED); -} - -/**************************************************************************** -REMARKS: -Free a block of shared memory. -****************************************************************************/ -void PMAPI PM_freeShared( - void *ptr) -{ - parmsIn[0] = (ulong)ptr; - CallSDDHelp(PMHELP_FREESHARED); -} - -/**************************************************************************** -REMARKS: -Map a linear memory address to the calling process address space. The -address will have been allocated in another process using the -PM_mapPhysicalAddr function. -****************************************************************************/ -void * PMAPI PM_mapToProcess( - void *base, - ulong limit) -{ - ulong baseAddr,baseOfs; - - /* 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 - * physical address, then we also add an extra offset into the address - * that we return. - */ - baseOfs = (ulong)base & 4095; - baseAddr = (ulong)base & ~4095; - limit = ((limit+baseOfs+1+4095) & ~4095)-1; - parmsIn[0] = (ulong)baseAddr; - parmsIn[1] = limit; - return (void*)(CallSDDHelp(PMHELP_MAPTOPROCESS)+baseOfs); -} - -/**************************************************************************** -REMARKS: -Map a real mode pointer to a protected mode pointer. -****************************************************************************/ -void * PMAPI PM_mapRealPointer( - uint r_seg, - uint r_off) -{ - if (r_seg == 0xFFFF) - return &RMBuf[r_off]; - return lowMem + MK_PHYS(r_seg,r_off); -} - -/**************************************************************************** -REMARKS: -Allocate a block of real mode memory -****************************************************************************/ -void * PMAPI PM_allocRealSeg( - uint size, - uint *r_seg, - uint *r_off) -{ - if (size > sizeof(RMBuf)) - return NULL; - *r_seg = 0xFFFF; - *r_off = 0x0000; - return &RMBuf; -} - -/**************************************************************************** -REMARKS: -Free a block of real mode memory. -****************************************************************************/ -void PMAPI PM_freeRealSeg( - void *mem) -{ - /* Nothing to do in here */ - (void)mem; -} - -#define INDPMI(reg) rmregs.aCRF.reg_##reg = regs->reg -#define OUTDPMI(reg) regs->reg = rmregs.aCRF.reg_##reg - -#define REG_OFFSET(field) (((ULONG)&(((VCRF*)0)->field)) / sizeof(ULONG)) - -/**************************************************************************** -REMARKS: -Issue a real mode interrupt (parameters in DPMI compatible structure) -****************************************************************************/ -void PMAPI DPMI_int86( - int intno, - DPMI_regs *regs) -{ - INTCRF rmregs; - ulong eax = 0; - - if (!InitInt10()) - 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; - } - } - if (useVPMI) - PM_VIDEOPMI32Request(&Adapter,PMIREQUEST_SOFTWAREINT,NULL,&rmregs); - else { - 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); - } - regs->ds = rmregs.aCRF.reg_ds; - regs->es = rmregs.aCRF.reg_es; - regs->flags = rmregs.aCRF.reg_eflag; -} - -#define IN(reg) rmregs.reg = in->e.reg -#define OUT(reg) out->e.reg = rmregs.reg - -/**************************************************************************** -REMARKS: -Issue a real mode interrupt. -****************************************************************************/ -int PMAPI PM_int86( - int intno, - RMREGS *in, - RMREGS *out) -{ - DPMI_regs rmregs; - - memset(&rmregs, 0, sizeof(rmregs)); - IN(eax); IN(ebx); IN(ecx); IN(edx); IN(esi); IN(edi); - DPMI_int86(intno,&rmregs); - OUT(eax); OUT(ebx); OUT(ecx); OUT(edx); OUT(esi); OUT(edi); - out->x.cflag = rmregs.flags & 0x1; - return out->x.ax; -} - -/**************************************************************************** -REMARKS: -Issue a real mode interrupt. -****************************************************************************/ -int PMAPI PM_int86x( - int intno, - RMREGS *in, - RMREGS *out, - RMSREGS *sregs) -{ - DPMI_regs rmregs; - - memset(&rmregs, 0, sizeof(rmregs)); - IN(eax); IN(ebx); IN(ecx); IN(edx); IN(esi); IN(edi); - rmregs.es = sregs->es; - rmregs.ds = sregs->ds; - DPMI_int86(intno,&rmregs); - OUT(eax); OUT(ebx); OUT(ecx); OUT(edx); OUT(esi); OUT(edi); - sregs->es = rmregs.es; - sregs->cs = rmregs.cs; - sregs->ss = rmregs.ss; - sregs->ds = rmregs.ds; - out->x.cflag = rmregs.flags & 0x1; - return out->x.ax; -} - -/**************************************************************************** -REMARKS: -Call a real mode far function. -****************************************************************************/ -void PMAPI PM_callRealMode( - uint seg, - uint off, - RMREGS *in, - RMSREGS *sregs) -{ - PM_fatalError("PM_callRealMode not supported on OS/2!"); -} - -/**************************************************************************** -REMARKS: -Return the amount of available memory. -****************************************************************************/ -void PMAPI PM_availableMemory( - ulong *physical, - ulong *total) -{ - /* Unable to get reliable values from OS/2 for this */ - *physical = *total = 0; -} - -/**************************************************************************** -REMARKS: -Allocate a block of locked, physical memory for DMA operations. -****************************************************************************/ -void * PMAPI PM_allocLockedMem( - uint size, - ulong *physAddr, - ibool contiguous, - ibool below16M) -{ - parmsIn[0] = size; - parmsIn[1] = contiguous; - parmsIn[2] = below16M; - CallSDDHelp(PMHELP_ALLOCLOCKED); - *physAddr = parmsOut[1]; - return (void*)parmsOut[0]; -} - -/**************************************************************************** -REMARKS: -Free a block of locked physical memory. -****************************************************************************/ -void PMAPI PM_freeLockedMem( - void *p, - uint size, - ibool contiguous) -{ - parmsIn[0] = (ulong)p; - CallSDDHelp(PMHELP_FREELOCKED); -} - -/**************************************************************************** -REMARKS: -Allocates a new block of pages for the page block manager. -****************************************************************************/ -static pageblock *PM_addNewPageBlock(void) -{ - int i; - pageblock *newBlock; - char *p,*next; - - /* 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; - if (!PM_lockDataPages(newBlock,PAGE_BLOCK_SIZE,&newBlock->lockHandle)) - return NULL; - newBlock->prev = NULL; - newBlock->next = pageBlocks; - if (pageBlocks) - pageBlocks->prev = newBlock; - pageBlocks = newBlock; - - /* Initialise the page aligned free list for the page block */ - newBlock->freeCount = PAGES_PER_BLOCK; - newBlock->freeList = p = (char*)(((ulong)(newBlock + 1) + (PM_PAGE_SIZE-1)) & ~(PM_PAGE_SIZE-1)); - 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 - PM_PAGE_SIZE) = NULL; - return newBlock; -} - -/**************************************************************************** -REMARKS: -Allocates a page aligned and page sized block of memory -****************************************************************************/ -void * PMAPI PM_allocPage( - ibool locked) -{ - pageblock *block; - void *p; - - /* 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 == NULL && (block = PM_addNewPageBlock()) == NULL) - return NULL; - block->freeCount--; - p = block->freeList; - block->freeList = FREELIST_NEXT(p); - (void)locked; - return p; -} - -/**************************************************************************** -REMARKS: -Free a page aligned and page sized block of memory -****************************************************************************/ -void PMAPI PM_freePage( - void *p) -{ - pageblock *block; - - /* 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; - } - 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); - } -} - -/**************************************************************************** -REMARKS: -Map in all the shared memory blocks for managing the memory pages above. -****************************************************************************/ -void PMAPI PM_mapSharedPages(void) -{ - pageblock *block; - - /* 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); - } -} - -/**************************************************************************** -REMARKS: -Lock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_lockDataPages( - void *p, - uint len, - PM_lockHandle *lockHandle) -{ - parmsIn[0] = (ulong)p; - parmsIn[1] = len; - CallSDDHelp(PMHELP_LOCKPAGES); - lockHandle->h[0] = parmsOut[1]; - lockHandle->h[1] = parmsOut[2]; - lockHandle->h[2] = parmsOut[3]; - return parmsOut[0]; -} - -/**************************************************************************** -REMARKS: -Unlock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_unlockDataPages( - void *p, - uint len, - PM_lockHandle *lockHandle) -{ - parmsIn[0] = lockHandle->h[0]; - parmsIn[1] = lockHandle->h[1]; - parmsIn[2] = lockHandle->h[2]; - return CallSDDHelp(PMHELP_UNLOCKPAGES); -} - -/**************************************************************************** -REMARKS: -Lock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_lockCodePages( - void (*p)(), - uint len, - PM_lockHandle *lockHandle) -{ - parmsIn[0] = (ulong)p; - parmsIn[1] = len; - CallSDDHelp(PMHELP_LOCKPAGES); - lockHandle->h[0] = parmsOut[1]; - lockHandle->h[1] = parmsOut[2]; - lockHandle->h[2] = parmsOut[3]; - return parmsOut[0]; -} - -/**************************************************************************** -REMARKS: -Unlock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_unlockCodePages( - void (*p)(), - uint len, - PM_lockHandle *lockHandle) -{ - parmsIn[0] = lockHandle->h[0]; - parmsIn[1] = lockHandle->h[1]; - parmsIn[2] = lockHandle->h[2]; - return CallSDDHelp(PMHELP_UNLOCKPAGES); -} - -/**************************************************************************** -REMARKS: -Call the VBE/Core software interrupt to change display banks. -****************************************************************************/ -void PMAPI PM_setBankA( - int bank) -{ - INTCRF rmregs; - - if (!InitInt10()) - return; - memset(&rmregs, 0, sizeof(rmregs)); - rmregs.ulBIOSIntNo = 0x10; - rmregs.aCRF.reg_eax = 0x4F05; - rmregs.aCRF.reg_ebx = 0x0000; - rmregs.aCRF.reg_edx = bank; - PM_VIDEOPMI32Request(&Adapter,PMIREQUEST_SOFTWAREINT,&rmregs,NULL); -} - -/**************************************************************************** -REMARKS: -Call the VBE/Core software interrupt to change display banks. -****************************************************************************/ -void PMAPI PM_setBankAB( - int bank) -{ - INTCRF rmregs; - - if (!InitInt10()) - return; - memset(&rmregs, 0, sizeof(rmregs)); - rmregs.ulBIOSIntNo = 0x10; - rmregs.aCRF.reg_eax = 0x4F05; - rmregs.aCRF.reg_ebx = 0x0000; - rmregs.aCRF.reg_edx = bank; - PM_VIDEOPMI32Request(&Adapter,PMIREQUEST_SOFTWAREINT,&rmregs,NULL); - rmregs.ulBIOSIntNo = 0x10; - rmregs.aCRF.reg_eax = 0x4F05; - rmregs.aCRF.reg_ebx = 0x0001; - rmregs.aCRF.reg_edx = bank; - PM_VIDEOPMI32Request(&Adapter,PMIREQUEST_SOFTWAREINT,&rmregs,NULL); -} - -/**************************************************************************** -REMARKS: -Call the VBE/Core software interrupt to change display start address. -****************************************************************************/ -void PMAPI PM_setCRTStart( - int x, - int y, - int waitVRT) -{ - INTCRF rmregs; - - if (!InitInt10()) - return; - memset(&rmregs, 0, sizeof(rmregs)); - rmregs.ulBIOSIntNo = 0x10; - rmregs.aCRF.reg_eax = 0x4F07; - rmregs.aCRF.reg_ebx = waitVRT; - rmregs.aCRF.reg_ecx = x; - rmregs.aCRF.reg_edx = y; - PM_VIDEOPMI32Request(&Adapter,PMIREQUEST_SOFTWAREINT,&rmregs,NULL); -} - -/**************************************************************************** -REMARKS: -Execute the POST on the secondary BIOS for a controller. -****************************************************************************/ -ibool PMAPI PM_doBIOSPOST( - ushort axVal, - ulong BIOSPhysAddr, - void *mappedBIOS, - ulong BIOSLen) -{ - (void)axVal; - (void)BIOSPhysAddr; - (void)mappedBIOS; - (void)BIOSLen; - return false; -} - -/**************************************************************************** -PARAMETERS: -base - The starting physical base address of the region -size - The size in bytes of the region -type - Type to place into the MTRR register - -RETURNS: -Error code describing the result. - -REMARKS: -Function to enable write combining for the specified region of memory. -****************************************************************************/ -int PMAPI PM_enableWriteCombine( - ulong base, - ulong size, - uint type) -{ - 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!! */ - -/* 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 - * helper device driver rather than the entire MTRR module. This makes - * it easier to maintain the MTRR support since we don't need to deal - * with 16-bit ring 0 code in the MTRR library. - */ - -/**************************************************************************** -REMARKS: -Flush the translation lookaside buffer. -****************************************************************************/ -void PMAPI PM_flushTLB(void) -{ - CallSDDHelp(PMHELP_FLUSHTLB); -} - -/**************************************************************************** -REMARKS: -Return true if ring 0 (or if we can call the helpers functions at ring 0) -****************************************************************************/ -ibool _ASMAPI _MTRR_isRing0(void) -{ - return true; -} - -/**************************************************************************** -REMARKS: -Read and return the value of the CR4 register -****************************************************************************/ -ulong _ASMAPI _MTRR_saveCR4(void) -{ - return CallSDDHelp(PMHELP_SAVECR4); -} - -/**************************************************************************** -REMARKS: -Restore the value of the CR4 register -****************************************************************************/ -void _ASMAPI _MTRR_restoreCR4(ulong cr4Val) -{ - parmsIn[0] = cr4Val; - CallSDDHelp(PMHELP_RESTORECR4); -} - -/**************************************************************************** -REMARKS: -Read a machine status register for the CPU. -****************************************************************************/ -void _ASMAPI _MTRR_readMSR( - ulong reg, - ulong *eax, - ulong *edx) -{ - parmsIn[0] = reg; - CallSDDHelp(PMHELP_READMSR); - *eax = parmsOut[0]; - *edx = parmsOut[1]; -} - -/**************************************************************************** -REMARKS: -Write a machine status register for the CPU. -****************************************************************************/ -void _ASMAPI _MTRR_writeMSR( - ulong reg, - ulong eax, - ulong edx) -{ - parmsIn[0] = reg; - parmsIn[1] = eax; - parmsIn[2] = edx; - CallSDDHelp(PMHELP_WRITEMSR); -} - -PM_MODULE PMAPI PM_loadLibrary( - const char *szDLLName) -{ - /* TODO: Implement this to load shared libraries! */ - (void)szDLLName; - return NULL; -} - -void * PMAPI PM_getProcAddress( - PM_MODULE hModule, - const char *szProcName) -{ - /* TODO: Implement this! */ - (void)hModule; - (void)szProcName; - return NULL; -} - -void PMAPI PM_freeLibrary( - PM_MODULE hModule) -{ - /* TODO: Implement this! */ - (void)hModule; -} - -/**************************************************************************** -REMARKS: -Internal function to convert the find data to the generic interface. -****************************************************************************/ -static void convertFindData( - PM_findData *findData, - FILEFINDBUF3 *blk) -{ - ulong dwSize = findData->dwSize; - - memset(findData,0,findData->dwSize); - findData->dwSize = dwSize; - if (blk->attrFile & FILE_READONLY) - findData->attrib |= PM_FILE_READONLY; - if (blk->attrFile & FILE_DIRECTORY) - findData->attrib |= PM_FILE_DIRECTORY; - if (blk->attrFile & FILE_ARCHIVED) - findData->attrib |= PM_FILE_ARCHIVE; - if (blk->attrFile & FILE_HIDDEN) - findData->attrib |= PM_FILE_HIDDEN; - if (blk->attrFile & FILE_SYSTEM) - findData->attrib |= PM_FILE_SYSTEM; - findData->sizeLo = blk->cbFile; - findData->sizeHi = 0; - strncpy(findData->name,blk->achName,PM_MAX_PATH); - findData->name[PM_MAX_PATH-1] = 0; -} - -#define FIND_MASK (FILE_ARCHIVED | FILE_DIRECTORY | FILE_SYSTEM | FILE_HIDDEN | FILE_READONLY) - -/**************************************************************************** -REMARKS: -Function to find the first file matching a search criteria in a directory. -****************************************************************************/ -void *PMAPI PM_findFirstFile( - const char *filename, - PM_findData *findData) -{ - FILEFINDBUF3 blk; - HDIR hdir = HDIR_CREATE; - ulong count = 1; - - if (DosFindFirst((PSZ)filename,&hdir,FIND_MASK,&blk,sizeof(blk),&count,FIL_STANDARD) == NO_ERROR) { - convertFindData(findData,&blk); - return (void*)hdir; - } - return PM_FILE_INVALID; -} - -/**************************************************************************** -REMARKS: -Function to find the next file matching a search criteria in a directory. -****************************************************************************/ -ibool PMAPI PM_findNextFile( - void *handle, - PM_findData *findData) -{ - FILEFINDBUF3 blk; - ulong count = 1; - - if (DosFindNext((HDIR)handle,&blk,sizeof(blk),&count) == NO_ERROR) { - convertFindData(findData,&blk); - return true; - } - return false; -} - -/**************************************************************************** -REMARKS: -Function to close the find process -****************************************************************************/ -void PMAPI PM_findClose( - void *handle) -{ - DosFindClose((HDIR)handle); -} - -/**************************************************************************** -REMARKS: -Function to determine if a drive is a valid drive or not. Under Unix this -function will return false for anything except a value of 3 (considered -the root drive, and equivalent to C: for non-Unix systems). The drive -numbering is: - - 0 - Current drive - 1 - Drive A: - 2 - Drive B: - 3 - Drive C: - etc - -****************************************************************************/ -ibool PMAPI PM_driveValid( - char drive) -{ - ulong cntDisk,cntDriveMap; - ibool valid; - - DosQueryCurrentDisk(&cntDisk,&cntDriveMap); - valid = (DosSetDefaultDisk(drive) == NO_ERROR); - DosSetDefaultDisk(cntDisk); - return valid; -} - -/**************************************************************************** -REMARKS: -Function to get the current working directory for the specififed drive. -Under Unix this will always return the current working directory regardless -of what the value of 'drive' is. -****************************************************************************/ -void PMAPI PM_getdcwd( - int drive, - char *dir, - int len) -{ - ulong length = len; - - DosQueryCurrentDir(drive, (PSZ)dir, &length); -} - -/**************************************************************************** -REMARKS: -Function to change the file attributes for a specific file. -****************************************************************************/ -void PMAPI PM_setFileAttr( - const char *filename, - uint attrib) -{ - FILESTATUS3 s; - - if (DosQueryPathInfo((PSZ)filename,FIL_STANDARD,(PVOID)&s,sizeof(s))) - return; - s.attrFile = 0; - if (attrib & PM_FILE_READONLY) - s.attrFile |= FILE_READONLY; - if (attrib & PM_FILE_ARCHIVE) - s.attrFile |= FILE_ARCHIVED; - if (attrib & PM_FILE_HIDDEN) - s.attrFile |= FILE_HIDDEN; - if (attrib & PM_FILE_SYSTEM) - s.attrFile |= FILE_SYSTEM; - DosSetPathInfo((PSZ)filename,FIL_STANDARD,(PVOID)&s,sizeof(s),0L); -} - -/**************************************************************************** -REMARKS: -Function to get the file attributes for a specific file. -****************************************************************************/ -uint PMAPI PM_getFileAttr( - const char *filename) -{ - FILESTATUS3 fs3; - uint retval = 0; - - if (DosQueryPathInfo((PSZ)filename, FIL_STANDARD, &fs3, sizeof(FILESTATUS3))) - return 0; - if (fs3.attrFile & FILE_READONLY) - retval |= PM_FILE_READONLY; - if (fs3.attrFile & FILE_ARCHIVED) - retval |= PM_FILE_ARCHIVE; - if (fs3.attrFile & FILE_HIDDEN) - retval |= PM_FILE_HIDDEN; - if (fs3.attrFile & FILE_SYSTEM) - retval |= PM_FILE_SYSTEM; - return retval; -} - -/**************************************************************************** -REMARKS: -Function to create a directory. -****************************************************************************/ -ibool PMAPI PM_mkdir( - const char *filename) -{ - return DosCreateDir((PSZ)filename,NULL) == NO_ERROR; -} - -/**************************************************************************** -REMARKS: -Function to remove a directory. -****************************************************************************/ -ibool PMAPI PM_rmdir( - const char *filename) -{ - return DosDeleteDir((PSZ)filename) == NO_ERROR; -} - -/**************************************************************************** -REMARKS: -Function to get the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_getFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - FILESTATUS3 fs3; - struct tm tc; - struct tm *ret; - time_t tt; - - if (DosQueryPathInfo((PSZ)filename, FIL_STANDARD, &fs3, sizeof(FILESTATUS3))) - 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; - } - 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; - } - return true; -} - -/**************************************************************************** -REMARKS: -Function to set the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_setFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - FILESTATUS3 fs3; - struct tm tc; - struct tm *ret; - time_t tt; - - if (DosQueryPathInfo((PSZ)filename,FIL_STANDARD,(PVOID)&fs3,sizeof(fs3))) - 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; - } - 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; - } - memcpy(&fs3.fdateLastAccess, &fs3.fdateLastWrite, sizeof(FDATE)); - memcpy(&fs3.fdateCreation, &fs3.fdateLastWrite, sizeof(FDATE)); - memcpy(&fs3.ftimeLastAccess, &fs3.ftimeLastWrite, sizeof(FTIME)); - memcpy(&fs3.ftimeCreation, &fs3.ftimeLastWrite, sizeof(FTIME)); - DosSetPathInfo((PSZ)filename,FIL_STANDARD,(PVOID)&fs3,sizeof(FILESTATUS3),0L); - return true; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/os2/vflat.c b/board/MAI/bios_emulator/scitech/src/pm/os2/vflat.c deleted file mode 100644 index 579ef2c95c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/os2/vflat.c +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Dummy module; no virtual framebuffer for this OS -* -****************************************************************************/ - -#include "pmapi.h" - -ibool PMAPI VF_available(void) -{ - return false; -} - -void * PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) -{ - baseAddr = baseAddr; - bankSize = bankSize; - codeLen = codeLen; - bankFunc = bankFunc; - return NULL; -} - -void PMAPI VF_exit(void) -{ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/os2/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/os2/ztimer.c deleted file mode 100644 index 30ffe4340b..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/os2/ztimer.c +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: OS/2 -* -* Description: OS specific implementation for the Zen Timer functions. -* -****************************************************************************/ - -/*---------------------------- Global variables ---------------------------*/ - -static ulong frequency; - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Initialise the Zen Timer module internals. -****************************************************************************/ -void __ZTimerInit(void) -{ - DosTmrQueryFreq(&frequency); -} - -/**************************************************************************** -REMARKS: -Start the Zen Timer counting. -****************************************************************************/ -#define __LZTimerOn(tm) DosTmrQueryTime((QWORD*)&tm->start) - -/**************************************************************************** -REMARKS: -Compute the lap time since the timer was started. -****************************************************************************/ -static ulong __LZTimerLap( - LZTimerObject *tm) -{ - CPU_largeInteger tmLap,tmCount; - - DosTmrQueryTime((QWORD*)&tmLap); - _CPU_diffTime64(&tm->start,&tmLap,&tmCount); - return _CPU_calcMicroSec(&tmCount,frequency); -} - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerOff(tm) DosTmrQueryTime((QWORD*)&tm->end) - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -static ulong __LZTimerCount( - LZTimerObject *tm) -{ - CPU_largeInteger tmCount; - - _CPU_diffTime64(&tm->start,&tm->end,&tmCount); - return _CPU_calcMicroSec(&tmCount,frequency); -} - -/**************************************************************************** -REMARKS: -Define the resolution of the long period timer as microseconds per timer tick. -****************************************************************************/ -#define ULZTIMER_RESOLUTION 1000 - -/**************************************************************************** -REMARKS: -Read the Long Period timer value from the BIOS timer tick. -****************************************************************************/ -static ulong __ULZReadTime(void) -{ - ULONG count; - DosQuerySysInfo( QSV_MS_COUNT, QSV_MS_COUNT, &count, sizeof(ULONG) ); - return count; -} - -/**************************************************************************** -REMARKS: -Compute the elapsed time from the BIOS timer tick. Note that we check to see -whether a midnight boundary has passed, and if so adjust the finish time to -account for this. We cannot detect if more that one midnight boundary has -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/os2pm/event.c b/board/MAI/bios_emulator/scitech/src/pm/os2pm/event.c deleted file mode 100644 index 7af20a9568..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/os2pm/event.c +++ /dev/null @@ -1,170 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: IBM PC (OS/2) -* -* Description: OS/2 implementation for the SciTech cross platform -* event library. -* -****************************************************************************/ - -/*---------------------------- Global Variables ---------------------------*/ - -static int oldMouseState; /* Old mouse state */ -static ulong oldKeyMessage; /* Old keyboard state */ -static ushort keyUpMsg[256] = {0};/* Table of key up messages */ -static int rangeX,rangeY; /* Range of mouse coordinates */ -HMOU _EVT_hMouse; /* Handle to the mouse driver */ - -/*---------------------------- Implementation -----------------------------*/ - -/* These are not used under OS/2 */ -#define _EVT_disableInt() 1 -#define _EVT_restoreInt(flags) - -/**************************************************************************** -PARAMETERS: -scanCode - Scan code to test - -REMARKS: -This macro determines if a specified key is currently down at the -time that the call is made. -****************************************************************************/ -#define _EVT_isKeyDown(scanCode) (keyUpMsg[scanCode] != 0) - -/**************************************************************************** -REMARKS: -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! */ -} - -/**************************************************************************** -REMARKS: -This macro/function is used to converts the scan codes reported by the -keyboard to our event libraries normalised format. We only have one scan -code for the 'A' key, and use shift modifiers to determine if it is a -Ctrl-F1, Alt-F1 etc. The raw scan codes from the keyboard work this way, -but the OS gives us 'cooked' scan codes, we have to translate them back -to the raw format. -****************************************************************************/ -#define _EVT_maskKeyCode(evt) - -/**************************************************************************** -REMARKS: -Safely abort the event module upon catching a fatal error. -****************************************************************************/ -void _EVT_abort() -{ - EVT_exit(); - PM_fatalError("Unhandled exception!"); -} - -/**************************************************************************** -PARAMETERS: -mouseMove - Callback function to call wheneve the mouse needs to be moved - -REMARKS: -Initiliase the event handling module. Here we install our mouse handling ISR -to be called whenever any button's are pressed or released. We also build -the free list of events in the event queue. - -We use handler number 2 of the mouse libraries interrupt handlers for our -event handling routines. -****************************************************************************/ -void EVTAPI EVT_init( - _EVT_mouseMoveHandler mouseMove) -{ - /* Initialise the event queue */ - EVT.mouseMove = mouseMove; - initEventQueue(); - oldMouseState = 0; - oldKeyMessage = 0; - memset(keyUpMsg,0,sizeof(keyUpMsg)); - - /* TODO: OS/2 PM specific initialisation code! */ - - /* Catch program termination signals so we can clean up properly */ - signal(SIGABRT, _EVT_abort); - signal(SIGFPE, _EVT_abort); - signal(SIGINT, _EVT_abort); -} - -/**************************************************************************** -REMARKS -Changes the range of coordinates returned by the mouse functions to the -specified range of values. This is used when changing between graphics -modes set the range of mouse coordinates for the new display mode. -****************************************************************************/ -void EVTAPI EVT_setMouseRange( - int xRes, - int yRes) -{ - rangeX = xRes; - rangeY = yRes; -} - -/**************************************************************************** -REMARKS: -Initiailises the internal event handling modules. The EVT_suspend function -can be called to suspend event handling (such as when shelling out to DOS), -and this function can be used to resume it again later. -****************************************************************************/ -void EVT_resume(void) -{ - /* Do nothing for OS/2 */ -} - -/**************************************************************************** -REMARKS -Suspends all of our event handling operations. This is also used to -de-install the event handling code. -****************************************************************************/ -void EVT_suspend(void) -{ - /* Do nothing for OS/2 */ -} - -/**************************************************************************** -REMARKS -Exits the event module for program terminatation. -****************************************************************************/ -void EVT_exit(void) -{ - /* Restore signal handlers */ - signal(SIGABRT, SIG_DFL); - signal(SIGFPE, SIG_DFL); - signal(SIGINT, SIG_DFL); - - /* TODO: OS/2 PM specific exit code */ -} - -/**************************************************************************** -REMARKS -Modifes the mouse coordinates as necessary if scaling to OS coordinates, -and sets the OS mouse cursor position. -****************************************************************************/ -#define _EVT_setMousePos(x,y) diff --git a/board/MAI/bios_emulator/scitech/src/pm/os2pm/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/os2pm/oshdr.h deleted file mode 100644 index 0b69f8222c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/os2pm/oshdr.h +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit OS/2 -* -* Description: Include file to include all OS specific header files. -* -****************************************************************************/ - -#define INCL_DOSERRORS -#define INCL_DOS -#define INCL_SUB -#define INCL_VIO -#define INCL_KBD -#include diff --git a/board/MAI/bios_emulator/scitech/src/pm/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/oshdr.h deleted file mode 100644 index 404e5c93c5..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/oshdr.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Header file to pull in OS specific headers for the target -* OS environment. -* -****************************************************************************/ - -#if defined(__SMX32__) -#include "smx/oshdr.h" -#elif defined(__RTTARGET__) -#include "rttarget/oshdr.h" -#elif defined(__REALDOS__) -#include "dos/oshdr.h" -#elif defined(__WIN32_VXD__) -#include "vxd/oshdr.h" -#elif defined(__NT_DRIVER__) -#include "ntdrv/oshdr.h" -#elif defined(__WINDOWS32__) -#include "win32/oshdr.h" -#elif defined(__OS2_VDD__) -#include "vxd/oshdr.h" -#elif defined(__OS2__) -#if defined(__OS2_PM__) -#include "os2pm/oshdr.h" -#else -#include "os2/oshdr.h" -#endif -#elif defined(__LINUX__) -#if defined(__USE_X11__) -#include "x11/oshdr.h" -#else -#include "linux/oshdr.h" -#endif -#elif defined(__QNX__) -#if defined(__USE_PHOTON__) -#include "photon/oshdr.h" -#elif defined(__USE_X11__) -#include "x11/oshdr.h" -#else -#include "qnx/oshdr.h" -#endif -#elif defined(__BEOS__) -#include "beos/oshdr.h" -#else -#error PM library not ported to this platform yet! -#endif diff --git a/board/MAI/bios_emulator/scitech/src/pm/photon/event.c b/board/MAI/bios_emulator/scitech/src/pm/photon/event.c deleted file mode 100644 index 581da16fdf..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/photon/event.c +++ /dev/null @@ -1,268 +0,0 @@ -/**************************************************************************** -* -* SciTech Multi-platform Graphics Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: QNX Photon GUI -* -* Description: QNX fullscreen console implementation for the SciTech -* cross platform event library. -* -****************************************************************************/ - -/*--------------------------- Global variables ----------------------------*/ - -static ushort keyUpMsg[256] = {0};/* Table of key up messages */ - -/*---------------------------- Implementation -----------------------------*/ - -/* These are not used under Linux */ -#define _EVT_disableInt() 1 -#define _EVT_restoreInt(flags) - -/**************************************************************************** -PARAMETERS: -scanCode - Scan code to test - -REMARKS: -This macro determines if a specified key is currently down at the -time that the call is made. -****************************************************************************/ -static ibool _EVT_isKeyDown( - uchar scancode) -{ - return (KeyState[(scancode & 0xf8) >> 3] & (1 << (scancode & 0x7)) ? - true : false); -} - -/**************************************************************************** -REMARKS: -Retrieves all events from the mouse/keyboard event queue and stuffs them -into the MGL event queue for further processing. -****************************************************************************/ -static void _EVT_pumpMessages(void) -{ - int pid; - uint msg, but_stat, message; - uchar evt[sizeof (PhEvent_t) + 1024]; - PhEvent_t *event = (void *)evt; - PhKeyEvent_t *key; - PhPointerEvent_t *mouse; - static int extended; - event_t _evt; - - while (count < EVENTQSIZE) { - uint mods = 0, keyp = 0; - - pid = Creceive(0, &msg, sizeof (msg)); - - 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 (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); - - _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); - - 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_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; - } -} - -/**************************************************************************** -REMARKS: -This macro/function is used to converts the scan codes reported by the -keyboard to our event libraries normalised format. We only have one scan -code for the 'A' key, and use shift modifiers to determine if it is a -Ctrl-F1, Alt-F1 etc. The raw scan codes from the keyboard work this way, -but the OS gives us 'cooked' scan codes, we have to translate them back -to the raw format. -****************************************************************************/ -#define _EVT_maskKeyCode(evt) - -/**************************************************************************** -REMARKS: -Safely abort the event module upon catching a fatal error. -****************************************************************************/ -void _EVT_abort( - int signo) -{ - char buf[80]; - - EVT_exit(); - sprintf(buf,"Terminating on signal %d",signo); - PM_fatalError(buf); -} - -/**************************************************************************** -PARAMETERS: -mouseMove - Callback function to call wheneve the mouse needs to be moved - -REMARKS: -Initiliase the event handling module. Here we install our mouse handling ISR -to be called whenever any button's are pressed or released. We also build -the free list of events in the event queue. - -We use handler number 2 of the mouse libraries interrupt handlers for our -event handling routines. -****************************************************************************/ -void EVTAPI EVT_init( - _EVT_mouseMoveHandler mouseMove) -{ - int i; - - /* Initialise the event queue */ - _mouseMove = mouseMove; - initEventQueue(); - memset((void *)KeyState, 0, sizeof (KeyState)); - - /* Catch program termination signals so we can clean up properly */ - signal(SIGABRT, _EVT_abort); - signal(SIGFPE, _EVT_abort); - signal(SIGINT, _EVT_abort); -} - -/**************************************************************************** -REMARKS -Changes the range of coordinates returned by the mouse functions to the -specified range of values. This is used when changing between graphics -modes set the range of mouse coordinates for the new display mode. -****************************************************************************/ -void EVTAPI EVT_setMouseRange( - int xRes, - int yRes) -{ - /* TODO: Need to call Input to change the coordinates that it returns */ - /* for mouse events!! */ -} - -/**************************************************************************** -REMARKS: -Initiailises the internal event handling modules. The EVT_suspend function -can be called to suspend event handling (such as when shelling out to DOS), -and this function can be used to resume it again later. -****************************************************************************/ -void EVT_resume(void) -{ - /* Do nothing for Photon */ -} - -/**************************************************************************** -REMARKS -Suspends all of our event handling operations. This is also used to -de-install the event handling code. -****************************************************************************/ -void EVT_suspend(void) -{ - /* Do nothing for Photon */ -} - -/**************************************************************************** -REMARKS -Exits the event module for program terminatation. -****************************************************************************/ -void EVT_exit(void) -{ - /* Restore signal handlers */ - signal(SIGABRT, SIG_DFL); - signal(SIGFPE, SIG_DFL); - signal(SIGINT, SIG_DFL); -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/photon/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/photon/oshdr.h deleted file mode 100644 index 3c72563de2..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/photon/oshdr.h +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************** -* -* SciTech Multi-platform Graphics Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: QNX Photon GUI -* -* Description: Include file to include all OS specific header files. -* -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include diff --git a/board/MAI/bios_emulator/scitech/src/pm/pm.vpw b/board/MAI/bios_emulator/scitech/src/pm/pm.vpw deleted file mode 100644 index 26e68a7a3a..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/pm.vpw +++ /dev/null @@ -1,43 +0,0 @@ -[Dependencies] -[CurrentProject] -curproj=pmlinux.vpj -[ProjectFiles] -pmcommon.vpj -pmdos.vpj -pmlinux.vpj -pmqnx.vpj -pmvxd.vpj -pmwin32.vpj -z_samples.vpj -..\a-global includes.vpj -[TreeExpansion] -"..\a-global includes.vpj" 0 -pmcommon.vpj 0 -pmdos.vpj 0 -pmlinux.vpj 0 -pmqnx.vpj 0 -pmvxd.vpj 0 -pmwin32.vpj 0 -z_samples.vpj 1 1 -[State] -SCREEN: 1280 1024 0 0 960 746 0 0 M 0 0 0 0 977 631 -CWD: C:\scitech\src\pm -FILEHIST: 9 -C:\scitech\makedefs\gcc_win32.mk -C:\scitech\bin\gcc2-w32.bat -C:\scitech\bin\gcc2-c32.bat -C:\scitech\bin\gcc2-linux.bat -C:\scitech\makedefs\gcc_linux.mk -C:\scitech\src\pm\linux\event.c -C:\scitech\src\pm\linux\oshdr.h -C:\scitech\src\pm\event.c -C:\scitech\src\pm\pmlinux.vpj -[ProjectDates] -pmcommon.vpj=20010517164335290 -pmdos.vpj=20010517164335290 -pmlinux.vpj=20010620175829812 -pmqnx.vpj=20010517164335290 -pmvxd.vpj=20010517164335306 -pmwin32.vpj=20010517164335306 -z_samples.vpj=20010517164335306 -..\a-global includes.vpj=20010517164334978 diff --git a/board/MAI/bios_emulator/scitech/src/pm/pmcommon.vpj b/board/MAI/bios_emulator/scitech/src/pm/pmcommon.vpj deleted file mode 100644 index 48b872d981..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/pmcommon.vpj +++ /dev/null @@ -1,45 +0,0 @@ -[COMPILER] -version=5.0b -MACRO=\n -activeconfig=,wc10-d32 -FILTERNAME=Source Files\nInclude Files\nAssembler Files\nOther Files\n -FILTERPATTERN=*.c;*.cpp;*.cxx;*.prg;*.pas;*.dpr;*.bas;*.java;*.sc;*.e;*.cob;*.html;*.rc\n*.h\n*.asm\n*.*\n -FILTERASSOCIATEFILETYPES=0 0 0 0 -FILTERAPPCOMMAND=\n\n\n\n -vcsproject=SCC:Perforce SCM://depot -vcslocalpath=SCC:Perforce SCM:c:\ -compile=concur|capture|hide|:Compile:&Compile, -make=concur|capture|hide|clear|saveall|:Build:&Build, -rebuild=concur|capture|hide|clear|saveall|:Rebuild:&Rebuild, -debug=concur|capture|hide|savenone|:Debug:&Debug, -execute=hide|savenone|:Execute:E&xecute, -user1=hide|:User 1:User 1, -user2=hide|:User 2:User 2, -workingdir=. -includedirs=%(SCITECH)\include;%(PRIVATE)\include -reffile= -[FILES] -common.c -cpuinfo.c -debug.c -event.c -makefile -oshdr.h -ztimer.c -..\common\agplib.c -codepage\us_eng.c -common\_cpuinfo.asm -common\_dma.asm -common\_int64.asm -common\_joy.asm -common\_mtrr.asm -common\_pcilib.asm -common\agp.c -common\keyboard.c -common\malloc.c -common\mtrr.c -common\pcilib.c -common\unixio.c -common\vgastate.c -[ASSOCIATION] -[CONFIGURATIONS] diff --git a/board/MAI/bios_emulator/scitech/src/pm/pmdos.vpj b/board/MAI/bios_emulator/scitech/src/pm/pmdos.vpj deleted file mode 100644 index 1157513b30..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/pmdos.vpj +++ /dev/null @@ -1,41 +0,0 @@ -[SciTech] -compiler=wc10- -targetos=d32 -[COMPILER] -version=5.0b -MACRO=enable_current_compiler\n -activeconfig=,TEST_HARNESS=1 -FILTERNAME=Source Files\nInclude Files\nAssembler Files\n -FILTERPATTERN=*.c;*.cpp;*.cxx;*.prg;*.pas;*.dpr;*.bas;*.java;*.sc;*.e;*.cob;*.html;*.rc\n*.h\n*.asm\n -FILTERASSOCIATEFILETYPES=0 0 0 -FILTERAPPCOMMAND=\n\n\n -vcsproject=SCC:Perforce SCM://depot -vcslocalpath=SCC:Perforce SCM:c:\ -compile=concur|capture|clear|:Compile:&Compile,dmake %n.obj -u %b -make=concur|capture|clear|saveall|:Build:&Build,dmake install %b -rebuild=concur|capture|clear|saveall|:Rebuild:&Rebuild,dmake cleanexe & dmake install -u %b -debug=concur|capture|hide|savenone|:Debug:&Debug, -execute=hide|savenone|nochangedir|:Execute:E&xecute, -user1=hide|:User 1:User 1, -user2=hide|:User 2:User 2, -usertool_clean_directory=concur|capture|hide|savenone|nochangedir|:Clean Directory:C&lean Directory,dmake cleanexe -workingdir=. -includedirs=%(SCITECH)\include;%(PRIVATE)\include -reffile= -[FILES] -dos\_event.asm -dos\_lztimer.asm -dos\_pm.asm -dos\_pmdos.asm -dos\_vflat.asm -dos\cpuinfo.c -dos\event.c -dos\oshdr.h -dos\pm.c -dos\pmdos.c -dos\vflat.c -dos\ztimer.c -[ASSOCIATION] -[CONFIGURATIONS] -config=,NORMAL_BUILD=1 -config=,TEST_HARNESS=1 diff --git a/board/MAI/bios_emulator/scitech/src/pm/pmlinux.vpj b/board/MAI/bios_emulator/scitech/src/pm/pmlinux.vpj deleted file mode 100644 index 0bfbf8446a..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/pmlinux.vpj +++ /dev/null @@ -1,35 +0,0 @@ -[SciTech] -compiler=gcc2- -targetos=linux -[COMPILER] -version=5.0b -MACRO=enable_current_compiler\n -FILTERNAME=Source Files\nInclude Files\nAssembler Files\n -FILTERPATTERN=*.c;*.cpp;*.cxx;*.prg;*.pas;*.dpr;*.bas;*.java;*.sc;*.e;*.cob;*.html;*.rc\n*.h\n*.asm\n -FILTERASSOCIATEFILETYPES=0 0 0 -FILTERAPPCOMMAND=\n\n\n -vcsproject=SCC:Perforce SCM://depot -vcslocalpath=SCC:Perforce SCM:c:\ -activeconfig=,install BUILD_DLL=1 -compile=concur|capture|clear|:Compile:&Compile,dmake %n.o -u -make=concur|capture|clear|saveall|:Build:&Build,dmake %b -rebuild=concur|capture|clear|saveall|:Rebuild:&Rebuild,dmake cleanexe & dmake -u %b -debug=concur|capture|hide|savenone|:Debug:&Debug, -execute=hide|savenone|nochangedir|:Execute:E&xecute, -user1=hide|:User 1:User 1, -user2=hide|:User 2:User 2, -usertool_clean_directory=concur|capture|hide|savenone|nochangedir|:Clean Directory:C&lean Directory,dmake cleanexe -workingdir=. -includedirs=%(SCITECH)\include;%(PRIVATE)\include -reffile= -[FILES] -linux\cpuinfo.c -linux\event.c -linux\oshdr.h -linux\pm.c -linux\vflat.c -linux\ztimer.c -[ASSOCIATION] -[CONFIGURATIONS] -config=,install BUILD_DLL=1 -config=,install diff --git a/board/MAI/bios_emulator/scitech/src/pm/pmntdrv.vpj b/board/MAI/bios_emulator/scitech/src/pm/pmntdrv.vpj deleted file mode 100644 index 3ec35a76e4..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/pmntdrv.vpj +++ /dev/null @@ -1,39 +0,0 @@ -[SciTech] -compiler=vc60- -targetos=drvw2k -[COMPILER] -version=5.0b -MACRO=enable_current_compiler\n -activeconfig=,wc10-d32 -FILTERNAME=Source Files\nInclude Files\nAssembler Files\n -FILTERPATTERN=*.c;*.cpp;*.cxx;*.prg;*.pas;*.dpr;*.bas;*.java;*.sc;*.e;*.cob;*.html;*.rc\n*.h\n*.asm\n -FILTERASSOCIATEFILETYPES=0 0 0 -FILTERAPPCOMMAND=\n\n\n -vcsproject=SCC:Perforce SCM://depot -vcslocalpath=SCC:Perforce SCM:c:\ -compile=concur|capture|:Compile:&Compile,dmake %n.obj -make=concur|capture|clear|saveall|:Build:&Build,dmake install -rebuild=concur|capture|clear|saveall|:Rebuild:&Rebuild,dmake cleanexe & dmake install -u -debug=concur|capture|hide|savenone|:Debug:&Debug, -execute=hide|savenone|nochangedir|:Execute:E&xecute, -user1=hide|:User 1:User 1, -user2=hide|:User 2:User 2, -usertool_clean_directory=concur|capture|hide|savenone|:Clean Directory:&Clean Directory,dmake cleanexe -workingdir=. -includedirs=%(SCITECH)\include;%(PRIVATE)\include -reffile= -[FILES] -..\..\include\ntdriver.h -ntdrv\_pm.asm -ntdrv\cpuinfo.c -ntdrv\int86.c -ntdrv\irq.c -ntdrv\mem.c -ntdrv\oshdr.h -ntdrv\pm.c -ntdrv\stdio.c -ntdrv\stdlib.c -ntdrv\vflat.c -ntdrv\ztimer.c -[ASSOCIATION] -[CONFIGURATIONS] diff --git a/board/MAI/bios_emulator/scitech/src/pm/pmqnx.vpj b/board/MAI/bios_emulator/scitech/src/pm/pmqnx.vpj deleted file mode 100644 index d54170252c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/pmqnx.vpj +++ /dev/null @@ -1,35 +0,0 @@ -[SciTech] -compiler=wc10- -targetos=qnx -[COMPILER] -version=5.0b -MACRO=enable_current_compiler\n -activeconfig=,wc10-d32 -FILTERNAME=Source Files\nInclude Files\nAssembler Files\n -FILTERPATTERN=*.c;*.cpp;*.cxx;*.prg;*.pas;*.dpr;*.bas;*.java;*.sc;*.e;*.cob;*.html;*.rc\n*.h\n*.asm\n -FILTERASSOCIATEFILETYPES=0 0 0 -FILTERAPPCOMMAND=\n\n\n -vcsproject=SCC:Perforce SCM://depot -vcslocalpath=SCC:Perforce SCM:c:\ -compile=concur|capture|clear|:Compile:&Compile,dmake %n.obj -make=concur|capture|clear|saveall|:Build:&Build,dmake install -rebuild=concur|capture|clear|saveall|:Rebuild:&Rebuild,dmake cleanexe & dmake install -u -debug=concur|capture|hide|savenone|:Debug:&Debug, -execute=hide|savenone|nochangedir|:Execute:E&xecute, -user1=hide|:User 1:User 1, -user2=hide|:User 2:User 2, -usertool_clean_directory=concur|capture|hide|savenone|nochangedir|:Clean Directory:C&lean Directory,dmake cleanexe -workingdir=. -includedirs=%(SCITECH)\include;%(PRIVATE)\include -reffile= -[FILES] -qnx\_mtrrqnx.asm -qnx\cpuinfo.c -qnx\event.c -qnx\mtrrqnx.c -qnx\oshdr.h -qnx\pm.c -qnx\vflat.c -qnx\ztimer.c -[ASSOCIATION] -[CONFIGURATIONS] diff --git a/board/MAI/bios_emulator/scitech/src/pm/pmvxd.vpj b/board/MAI/bios_emulator/scitech/src/pm/pmvxd.vpj deleted file mode 100644 index 1fcf911769..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/pmvxd.vpj +++ /dev/null @@ -1,34 +0,0 @@ -[SciTech] -compiler=bc50- -targetos=vxd -[COMPILER] -version=5.0b -MACRO=enable_current_compiler\n -activeconfig=,wc10-d32 -FILTERNAME=Source Files\nInclude Files\nAssembler Files\n -FILTERPATTERN=*.c;*.cpp;*.cxx;*.prg;*.pas;*.dpr;*.bas;*.java;*.sc;*.e;*.cob;*.html;*.rc\n*.h\n*.asm\n -FILTERASSOCIATEFILETYPES=0 0 0 -FILTERAPPCOMMAND=\n\n\n -vcsproject=SCC:Perforce SCM://depot -vcslocalpath=SCC:Perforce SCM:c:\ -compile=concur|capture|nochangedir|:Compile:&Compile,dmake %n.obj -make=concur|capture|clear|saveall|nochangedir|:Build:&Build,dmake install -rebuild=concur|capture|clear|saveall|nochangedir|:Rebuild:&Rebuild,dmake cleanexe & dmake install -u -debug=concur|capture|hide|savenone|nochangedir|:Debug:&Debug, -execute=hide|savenone|nochangedir|:Execute:E&xecute, -user1=hide|:User 1:User 1, -user2=hide|:User 2:User 2, -usertool_clean_directory=concur|capture|hide|savenone|nochangedir|:Clean Directory:&Clean Directory,dmake cleanexe -workingdir=. -includedirs=%(SCITECH)\include;%(PRIVATE)\include -reffile= -[FILES] -vxd\_pm.asm -vxd\cpuinfo.c -vxd\fileio.c -vxd\oshdr.h -vxd\pm.c -vxd\vflat.c -vxd\ztimer.c -[ASSOCIATION] -[CONFIGURATIONS] diff --git a/board/MAI/bios_emulator/scitech/src/pm/pmwin32.vpj b/board/MAI/bios_emulator/scitech/src/pm/pmwin32.vpj deleted file mode 100644 index ace682208c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/pmwin32.vpj +++ /dev/null @@ -1,35 +0,0 @@ -[SciTech] -compiler=vc60- -targetos=c32 -[COMPILER] -version=5.0b -MACRO=enable_current_compiler\n -activeconfig=,wc10-d32 -FILTERNAME=Source Files\nInclude Files\nAssembler Files\n -FILTERPATTERN=*.c;*.cpp;*.cxx;*.prg;*.pas;*.dpr;*.bas;*.java;*.sc;*.e;*.cob;*.html;*.rc\n*.h\n*.asm\n -FILTERASSOCIATEFILETYPES=0 0 0 -FILTERAPPCOMMAND=\n\n\n -vcsproject=SCC:Perforce SCM://depot -vcslocalpath=SCC:Perforce SCM:c:\ -compile=concur|capture|:Compile:&Compile,dmake %n.obj -make=concur|capture|clear|saveall|:Build:&Build,dmake install -rebuild=concur|capture|clear|saveall|:Rebuild:&Rebuild,dmake cleanexe & dmake install -u -debug=concur|capture|hide|savenone|:Debug:&Debug, -execute=hide|savenone|nochangedir|:Execute:E&xecute, -user1=hide|:User 1:User 1, -user2=hide|:User 2:User 2, -usertool_clean_directory=concur|capture|savenone|:Clean Directory:&Clean Directory,dmake cleanexe -workingdir=. -includedirs=%(SCITECH)\include;%(PRIVATE)\include -reffile= -[FILES] -win32\_pmwin32.asm -win32\cpuinfo.c -win32\ddraw.c -win32\event.c -win32\oshdr.h -win32\pm.c -win32\vflat.c -win32\ztimer.c -[ASSOCIATION] -[CONFIGURATIONS] diff --git a/board/MAI/bios_emulator/scitech/src/pm/qnx/_mtrrqnx.asm b/board/MAI/bios_emulator/scitech/src/pm/qnx/_mtrrqnx.asm deleted file mode 100644 index 5a3fe105ec..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/qnx/_mtrrqnx.asm +++ /dev/null @@ -1,226 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: NASM -;* Environment: QNX -;* -;* Description: Assembler support routines for the Memory Type Range Register -;* (MTRR) module for QNX. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -header _mtrrqnx ; Set up memory model - -begdataseg _mtrrqnx ; Start of code segment - -ifdef USE_NASM -%define R0_FLUSH_TLB 0 -%define R0_SAVE_CR4 1 -%define R0_RESTORE_CR4 2 -%define R0_READ_MSR 3 -%define R0_WRITE_MSR 4 -else -R0_FLUSH_TLB EQU 0 -R0_SAVE_CR4 EQU 1 -R0_RESTORE_CR4 EQU 2 -R0_READ_MSR EQU 3 -R0_WRITE_MSR EQU 4 -endif - -cpublic _PM_R0 -_PM_R0_service dd 0 -_PM_R0_reg dd 0 -_PM_R0_eax dd 0 -_PM_R0_edx dd 0 - -enddataseg _mtrrqnx ; Start of code segment - -begcodeseg _mtrrqnx ; Start of code segment - -P586 - -;---------------------------------------------------------------------------- -; ulong _MTRR_disableInt(void); -;---------------------------------------------------------------------------- -; Return processor interrupt status and disable interrupts. -;---------------------------------------------------------------------------- -cprocstart _MTRR_disableInt - - pushfd ; Put flag word on stack -; cli ; Disable interrupts! - pop eax ; deposit flag word in return register - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _MTRR_restoreInt(ulong ps); -;---------------------------------------------------------------------------- -; Restore processor interrupt status. -;---------------------------------------------------------------------------- -cprocstart _MTRR_restoreInt - - ARG ps:ULONG - - push ebp - mov ebp,esp ; Set up stack frame - push [ULONG ps] - popfd ; Restore processor status (and interrupts) - pop ebp - ret - -cprocend - -;---------------------------------------------------------------------------- -; uchar _MTRR_getCx86(uchar reg); -;---------------------------------------------------------------------------- -; Read a Cyrix CPU indexed register -;---------------------------------------------------------------------------- -cprocstart _MTRR_getCx86 - - ARG reg:UCHAR - - enter_c - mov al,[reg] - out 22h,al - in al,23h - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; uchar _MTRR_setCx86(uchar reg,uchar val); -;---------------------------------------------------------------------------- -; Write a Cyrix CPU indexed register -;---------------------------------------------------------------------------- -cprocstart _MTRR_setCx86 - - ARG reg:UCHAR, val:UCHAR - - enter_c - mov al,[reg] - out 22h,al - mov al,[val] - out 23h,al - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; ulong _PM_ring0_isr(void); -;---------------------------------------------------------------------------- -; Ring 0 clock interrupt handler that we use to execute the MTRR support -; code. -;---------------------------------------------------------------------------- -cprocnear _PM_ring0_isr - -;-------------------------------------------------------- -; void PM_flushTLB(void); -;-------------------------------------------------------- - pushad - cmp [DWORD _PM_R0_service],R0_FLUSH_TLB - jne @@1 - wbinvd ; Flush the CPU cache - mov eax,cr3 - mov cr3,eax ; Flush the TLB - jmp @@Exit - -;-------------------------------------------------------- -; ulong _MTRR_saveCR4(void); -;-------------------------------------------------------- -@@1: cmp [DWORD _PM_R0_service],R0_SAVE_CR4 - jne @@2 - -; Save value of CR4 and clear Page Global Enable (bit 7) - - mov ebx,cr4 - mov eax,ebx - and al,7Fh - mov cr4,eax - -; Disable and flush caches - - mov eax,cr0 - or eax,40000000h - wbinvd - mov cr0,eax - wbinvd - -; Return value from CR4 - - mov [_PM_R0_reg],ebx - jmp @@Exit - -;-------------------------------------------------------- -; void _MTRR_restoreCR4(ulong cr4Val) -;-------------------------------------------------------- -@@2: cmp [DWORD _PM_R0_service],R0_RESTORE_CR4 - jne @@3 - - mov eax,cr0 - and eax,0BFFFFFFFh - mov cr0,eax - mov eax,[_PM_R0_reg] - mov cr4,eax - jmp @@Exit - -;-------------------------------------------------------- -; void _MTRR_readMSR(int reg, ulong FAR *eax, ulong FAR *edx); -;-------------------------------------------------------- -@@3: cmp [DWORD _PM_R0_service],R0_READ_MSR - jne @@4 - - mov ecx,[_PM_R0_reg] - rdmsr - mov [_PM_R0_eax],eax - mov [_PM_R0_edx],edx - jmp @@Exit - -;-------------------------------------------------------- -; void _MTRR_writeMSR(int reg, ulong eax, ulong edx); -;-------------------------------------------------------- -@@4: cmp [DWORD _PM_R0_service],R0_WRITE_MSR - jne @@Exit - - mov ecx,[_PM_R0_reg] - mov eax,[_PM_R0_eax] - mov edx,[_PM_R0_edx] - wrmsr - jmp @@Exit - -@@Exit: mov [DWORD _PM_R0_service],-1 - popad - mov eax,0 - retf - -cprocend - -endcodeseg _mtrrqnx - - END ; End of module diff --git a/board/MAI/bios_emulator/scitech/src/pm/qnx/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/qnx/cpuinfo.c deleted file mode 100644 index a8782542b2..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/qnx/cpuinfo.c +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: QNX -* -* Description: QNX specific code for the CPU detection module. -* -****************************************************************************/ - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -TODO: We should implement this for QNX! -****************************************************************************/ -#define SetMaxThreadPriority() 0 - -/**************************************************************************** -REMARKS: -TODO: We should implement this for QNX! -****************************************************************************/ -#define RestoreThreadPriority(i) - -/**************************************************************************** -REMARKS: -Initialise the counter and return the frequency of the counter. -****************************************************************************/ -static void GetCounterFrequency( - CPU_largeInteger *freq) -{ - freq->low = CLOCKS_PER_SEC * 1000; - freq->high = 0; -} - -/**************************************************************************** -REMARKS: -Read the counter and return the counter value. -****************************************************************************/ -#define GetCounter(t) \ -{ \ - (t)->low = clock() * 1000; \ - (t)->high = 0; \ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/qnx/event.c b/board/MAI/bios_emulator/scitech/src/pm/qnx/event.c deleted file mode 100644 index 45cd514454..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/qnx/event.c +++ /dev/null @@ -1,601 +0,0 @@ -/**************************************************************************** -* -* SciTech Multi-platform Graphics Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: QNX -* -* Description: QNX fullscreen console implementation for the SciTech -* cross platform event library. -* -****************************************************************************/ - -#include -#include - -/*--------------------------- Global variables ----------------------------*/ - -#ifndef __QNXNTO__ -static struct _mouse_ctrl *_PM_mouse_ctl; -static int _PM_keyboard_fd = -1; -/*static int _PM_modifiers, _PM_leds; */ -#else -static int kbd_fd = -1, mouse_fd = -1; -#endif -static int kill_pid = 0; -static ushort keyUpMsg[256] = {0};/* Table of key up messages */ -static int rangeX,rangeY; /* Range of mouse coordinates */ - -#define TIME_TO_MSEC(__t) ((__t).tv_nsec / 1000000 + (__t).tv_sec * 1000) - -#define LED_NUM 1 -#define LED_CAP 2 -#define LED_SCR 4 - -/* Scancode mappings on QNX for special keys */ - -typedef struct { - int scan; - int map; - } keymap; - -/* TODO: Fix this and set it up so we can do a binary search! */ - -keymap keymaps[] = { - {96, KB_padEnter}, - {74, KB_padMinus}, - {78, KB_padPlus}, - {55, KB_padTimes}, - {98, KB_padDivide}, - {71, KB_padHome}, - {72, KB_padUp}, - {73, KB_padPageUp}, - {75, KB_padLeft}, - {76, KB_padCenter}, - {77, KB_padRight}, - {79, KB_padEnd}, - {80, KB_padDown}, - {81, KB_padPageDown}, - {82, KB_padInsert}, - {83, KB_padDelete}, - {105,KB_left}, - {108,KB_down}, - {106,KB_right}, - {103,KB_up}, - {110,KB_insert}, - {102,KB_home}, - {104,KB_pageUp}, - {111,KB_delete}, - {107,KB_end}, - {109,KB_pageDown}, - {125,KB_leftWindows}, - {126,KB_rightWindows}, - {127,KB_menu}, - {100,KB_rightAlt}, - {97,KB_rightCtrl}, - }; - -/* And the keypad with num lock turned on (changes the ASCII code only) */ - -keymap keypad[] = { - {71, ASCII_7}, - {72, ASCII_8}, - {73, ASCII_9}, - {75, ASCII_4}, - {76, ASCII_5}, - {77, ASCII_6}, - {79, ASCII_1}, - {80, ASCII_2}, - {81, ASCII_3}, - {82, ASCII_0}, - {83, ASCII_period}, - }; - -#define NB_KEYMAPS (sizeof(keymaps)/sizeof(keymaps[0])) -#define NB_KEYPAD (sizeof(keypad)/sizeof(keypad[0])) - -/*---------------------------- Implementation -----------------------------*/ - -/**************************************************************************** -REMARKS: -Include generic raw scancode keyboard module. -****************************************************************************/ -#include "common/keyboard.c" - -/* These are not used under QNX */ -#define _EVT_disableInt() 1 -#define _EVT_restoreInt(flags) - -/**************************************************************************** -REMARKS: -This function is used to return the number of ticks since system -startup in milliseconds. This should be the same value that is placed into -the time stamp fields of events, and is used to implement auto mouse down -events. -****************************************************************************/ -ulong _EVT_getTicks(void) -{ - struct timespec t; - clock_gettime(CLOCK_REALTIME,&t); - return (t.tv_nsec / 1000000 + t.tv_sec * 1000); -} - -/**************************************************************************** -REMARKS: -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. */ - return mickey; -} - -#ifdef __QNXNTO__ -/**************************************************************************** -REMARKS: -Retrieves all events from the mouse/keyboard event queue and stuffs them -into the MGL event queue for further processing. -****************************************************************************/ -static void _EVT_pumpMessages(void) -{ - int rc1, rc2; - struct _keyboard_packet key; - struct _mouse_packet ms; - static long old_buttons = 0; - uint message = 0, but_stat = 0, mods = 0; - 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; - } -} -#else -/**************************************************************************** -REMARKS: -Retrieves all events from the mouse/keyboard event queue and stuffs them -into the MGL event queue for further processing. -****************************************************************************/ -static void _EVT_pumpMessages(void) -{ - struct mouse_event ev; - int rc; - static long old_buttons = 0; - uint message = 0, but_stat = 0; - event_t evt; - char buf[32]; - int numkeys, i; - - /* Poll keyboard events */ - while ((numkeys = read(_PM_keyboard_fd, buf, sizeof buf)) > 0) { - for (i = 0; i < numkeys; i++) { - processRawScanCode(buf[i]); - } - } - - if (_PM_mouse_ctl == NULL) - 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; - } - } -} -#endif /* __QNXNTO__ */ - -/**************************************************************************** -REMARKS: -This macro/function is used to converts the scan codes reported by the -keyboard to our event libraries normalised format. We only have one scan -code for the 'A' key, and use shift modifiers to determine if it is a -Ctrl-F1, Alt-F1 etc. The raw scan codes from the keyboard work this way, -but the OS gives us 'cooked' scan codes, we have to translate them back -to the raw format. -****************************************************************************/ -#define _EVT_maskKeyCode(evt) - -/**************************************************************************** -REMARKS: -Safely abort the event module upon catching a fatal error. -****************************************************************************/ -void _EVT_abort( - int signo) -{ - char buf[80]; - - EVT_exit(); - sprintf(buf,"Terminating on signal %d",signo); - PM_fatalError(buf); -} - -/**************************************************************************** -PARAMETERS: -mouseMove - Callback function to call wheneve the mouse needs to be moved - -REMARKS: -Initiliase the event handling module. Here we install our mouse handling ISR -to be called whenever any button's are pressed or released. We also build -the free list of events in the event queue. - -We use handler number 2 of the mouse libraries interrupt handlers for our -event handling routines. -****************************************************************************/ -void EVTAPI EVT_init( - _EVT_mouseMoveHandler mouseMove) -{ - int i; - struct stat st; - char *iarg[16]; -#ifdef __QNXNTO__ - char buf[128]; - FILE *p; - int argno,len; -#endif - -#ifdef __QNXNTO__ - ThreadCtl(_NTO_TCTL_IO, 0); /* So joystick code won't blow up */ -#endif - - /* Initialise the event queue */ - EVT.mouseMove = mouseMove; - initEventQueue(); - memset(keyUpMsg,0,sizeof(keyUpMsg)); - -#ifdef __QNXNTO__ - /* - * User may already have input running with the right parameters. - * Thus they could start input at boot time, using the output of - * inputtrap, passing the the -r flag to make it run as a resource - * 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"); - } - } - if ((kbd_fd = open("/dev/keyboard0", O_RDONLY|O_NONBLOCK)) < 0) { - 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); - } - } - } - if (_PM_keyboard_fd == -1) - _PM_keyboard_fd = open("/dev/kbd", O_RDONLY|O_NONBLOCK); -#endif - - /* Catch program termination signals so we can clean up properly */ - signal(SIGABRT, _EVT_abort); - signal(SIGFPE, _EVT_abort); - signal(SIGINT, _EVT_abort); -} - -/**************************************************************************** -REMARKS -Changes the range of coordinates returned by the mouse functions to the -specified range of values. This is used when changing between graphics -modes set the range of mouse coordinates for the new display mode. -****************************************************************************/ -void EVTAPI EVT_setMouseRange( - int xRes, - int yRes) -{ - rangeX = xRes; - rangeY = yRes; -} - -/**************************************************************************** -REMARKS -Modifes the mouse coordinates as necessary if scaling to OS coordinates, -and sets the OS mouse cursor position. -****************************************************************************/ -#define _EVT_setMousePos(x,y) - -/**************************************************************************** -REMARKS: -Initiailises the internal event handling modules. The EVT_suspend function -can be called to suspend event handling (such as when shelling out to DOS), -and this function can be used to resume it again later. -****************************************************************************/ -void EVT_resume(void) -{ - /* Do nothing for QNX */ -} - -/**************************************************************************** -REMARKS -Suspends all of our event handling operations. This is also used to -de-install the event handling code. -****************************************************************************/ -void EVT_suspend(void) -{ - /* Do nothing for QNX */ -} - -/**************************************************************************** -REMARKS -Exits the event module for program terminatation. -****************************************************************************/ -void EVT_exit(void) -{ -#ifdef __QNXNTO__ - char c; - int flags; - - if (kbd_fd != -1) { - close(kbd_fd); - kbd_fd = -1; - } - if (mouse_fd != -1) { - close(mouse_fd); - mouse_fd = -1; - } -#endif - - /* Restore signal handlers */ - signal(SIGABRT, SIG_DFL); - signal(SIGFPE, SIG_DFL); - signal(SIGINT, SIG_DFL); - -#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; - } - } -#endif - if (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 deleted file mode 100644 index f960c75714..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/qnx/mtrrqnx.c +++ /dev/null @@ -1,182 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: QNX -* -* Description: MTRR helper functions module. To make it easier to implement -* the MTRR support under QNX, we simply put our ring 0 helper -* functions into stubs that run them at ring 0 using whatever -* mechanism is available. -* -****************************************************************************/ - -#include "pmapi.h" -#include -#include -#include -#ifdef __QNXNTO__ -#include -#include -#else -#include -#include -#endif - -/*--------------------------- Global variables ----------------------------*/ - -#define R0_FLUSH_TLB 0 -#define R0_SAVE_CR4 1 -#define R0_RESTORE_CR4 2 -#define R0_READ_MSR 3 -#define R0_WRITE_MSR 4 - -typedef struct { - int service; - int reg; - ulong eax; - ulong edx; - } R0_data; - -extern volatile R0_data _PM_R0; - -/*----------------------------- Implementation ----------------------------*/ - -#ifdef __QNXNTO__ -const struct sigevent * _ASMAPI _PM_ring0_isr(void *arg, int id); -#else -pid_t far _ASMAPI _PM_ring0_isr(); -#endif - -/**************************************************************************** -REMARKS: -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! */ -#else - return true; -#endif -} - -/**************************************************************************** -REMARKS: -Function to execute a service at ring 0. This is done using the clock -interrupt handler since the code we attach to it will always run at ring 0. -****************************************************************************/ -static void CallRing0(void) -{ -#ifdef __QNXNTO__ - uint clock_intno = SYSPAGE_ENTRY(qtime)->intr; -#else - uint clock_intno = 0; /* clock irq */ -#endif - int intrid; - -#ifdef __QNXNTO__ - mlock((void*)&_PM_R0, sizeof(_PM_R0)); - ThreadCtl(_NTO_TCTL_IO, 0); -#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) { -#else - if ((intrid = qnx_hint_attach(clock_intno, _PM_ring0_isr, FP_SEG(&_PM_R0))) == -1) { -#endif - perror("Attach"); - exit(-1); - } - while (_PM_R0.service != -1) - ; -#ifdef __QNXNTO__ - InterruptDetachId(intrid); -#else - qnx_hint_detach(intrid); -#endif -} - -/**************************************************************************** -REMARKS: -Flush the translation lookaside buffer. -****************************************************************************/ -void PMAPI PM_flushTLB(void) -{ - _PM_R0.service = R0_FLUSH_TLB; - CallRing0(); -} - -/**************************************************************************** -REMARKS: -Read and return the value of the CR4 register -****************************************************************************/ -ulong _ASMAPI _MTRR_saveCR4(void) -{ - _PM_R0.service = R0_SAVE_CR4; - CallRing0(); - return _PM_R0.reg; -} - -/**************************************************************************** -REMARKS: -Restore the value of the CR4 register -****************************************************************************/ -void _ASMAPI _MTRR_restoreCR4(ulong cr4Val) -{ - _PM_R0.service = R0_RESTORE_CR4; - _PM_R0.reg = cr4Val; - CallRing0(); -} - -/**************************************************************************** -REMARKS: -Read a machine status register for the CPU. -****************************************************************************/ -void _ASMAPI _MTRR_readMSR( - int reg, - ulong *eax, - ulong *edx) -{ - _PM_R0.service = R0_READ_MSR; - _PM_R0.reg = reg; - CallRing0(); - *eax = _PM_R0.eax; - *edx = _PM_R0.edx; -} - -/**************************************************************************** -REMARKS: -Write a machine status register for the CPU. -****************************************************************************/ -void _ASMAPI _MTRR_writeMSR( - int reg, - ulong eax, - ulong edx) -{ - _PM_R0.service = R0_WRITE_MSR; - _PM_R0.reg = reg; - _PM_R0.eax = eax; - _PM_R0.edx = edx; - CallRing0(); -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/qnx/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/qnx/oshdr.h deleted file mode 100644 index 0961193049..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/qnx/oshdr.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -* -* SciTech Multi-platform Graphics Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: QNX -* -* Description: Include file to include all OS specific header files. -* -****************************************************************************/ - -#include -#include -#include -#include -#ifndef __QNXNTO__ -#include -#include -#include -#include -#else -#include - -/* Things 'borrowed' from photon/keycodes.h */ - -/* - * Keyboard modifiers - */ -#define KEYMODBIT_SHIFT 0 -#define KEYMODBIT_CTRL 1 -#define KEYMODBIT_ALT 2 -#define KEYMODBIT_ALTGR 3 -#define KEYMODBIT_SHL3 4 -#define KEYMODBIT_MOD6 5 -#define KEYMODBIT_MOD7 6 -#define KEYMODBIT_MOD8 7 - -#define KEYMODBIT_SHIFT_LOCK 8 -#define KEYMODBIT_CTRL_LOCK 9 -#define KEYMODBIT_ALT_LOCK 10 -#define KEYMODBIT_ALTGR_LOCK 11 -#define KEYMODBIT_SHL3_LOCK 12 -#define KEYMODBIT_MOD6_LOCK 13 -#define KEYMODBIT_MOD7_LOCK 14 -#define KEYMODBIT_MOD8_LOCK 15 - -#define KEYMODBIT_CAPS_LOCK 16 -#define KEYMODBIT_NUM_LOCK 17 -#define KEYMODBIT_SCROLL_LOCK 18 - -#define KEYMOD_SHIFT (1 << KEYMODBIT_SHIFT) -#define KEYMOD_CTRL (1 << KEYMODBIT_CTRL) -#define KEYMOD_ALT (1 << KEYMODBIT_ALT) -#define KEYMOD_ALTGR (1 << KEYMODBIT_ALTGR) -#define KEYMOD_SHL3 (1 << KEYMODBIT_SHL3) -#define KEYMOD_MOD6 (1 << KEYMODBIT_MOD6) -#define KEYMOD_MOD7 (1 << KEYMODBIT_MOD7) -#define KEYMOD_MOD8 (1 << KEYMODBIT_MOD8) - -#define KEYMOD_SHIFT_LOCK (1 << KEYMODBIT_SHIFT_LOCK) -#define KEYMOD_CTRL_LOCK (1 << KEYMODBIT_CTRL_LOCK) -#define KEYMOD_ALT_LOCK (1 << KEYMODBIT_ALT_LOCK) -#define KEYMOD_ALTGR_LOCK (1 << KEYMODBIT_ALTGR_LOCK) -#define KEYMOD_SHL3_LOCK (1 << KEYMODBIT_SHL3_LOCK) -#define KEYMOD_MOD6_LOCK (1 << KEYMODBIT_MOD6_LOCK) -#define KEYMOD_MOD7_LOCK (1 << KEYMODBIT_MOD7_LOCK) -#define KEYMOD_MOD8_LOCK (1 << KEYMODBIT_MOD8_LOCK) - -#define KEYMOD_CAPS_LOCK (1 << KEYMODBIT_CAPS_LOCK) -#define KEYMOD_NUM_LOCK (1 << KEYMODBIT_NUM_LOCK) -#define KEYMOD_SCROLL_LOCK (1 << KEYMODBIT_SCROLL_LOCK) - -/* - * Keyboard flags - */ -#define KEY_DOWN 0x00000001 /* Key was pressed down */ -#define KEY_REPEAT 0x00000002 /* Key was repeated */ -#define KEY_SCAN_VALID 0x00000020 /* Scancode is valid */ -#define KEY_SYM_VALID 0x00000040 /* Key symbol is valid */ -#define KEY_CAP_VALID 0x00000080 /* Key cap is valid */ -#define KEY_DEAD 0x40000000 /* Key symbol is a DEAD key */ -#define KEY_OEM_CAP 0x80000000 /* Key cap is an OEM scan code from keyboard */ - -#endif /* __QNXNTO__ */ diff --git a/board/MAI/bios_emulator/scitech/src/pm/qnx/pm.c b/board/MAI/bios_emulator/scitech/src/pm/qnx/pm.c deleted file mode 100644 index c993ee0837..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/qnx/pm.c +++ /dev/null @@ -1,891 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: QNX -* -* Description: Implementation for the OS Portability Manager Library, which -* contains functions to implement OS specific services in a -* generic, cross platform API. Porting the OS Portability -* Manager library is the first step to porting any SciTech -* products to a new platform. -* -****************************************************************************/ - -#include "pmapi.h" -#include "drvlib/os/os.h" -#include "mtrr.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "qnx/vbios.h" -#ifndef __QNXNTO__ -#include -#include -#include -#include -#else -#include -#include -#endif - -/*--------------------------- Global variables ----------------------------*/ - -static uint VESABuf_len = 1024; /* Length of the VESABuf buffer */ -static void *VESABuf_ptr = NULL; /* Near pointer to VESABuf */ -static uint VESABuf_rseg; /* Real mode segment of VESABuf */ -static uint VESABuf_roff; /* Real mode offset of VESABuf */ -static VBIOSregs_t *VRegs = NULL; /* Pointer to VBIOS registers */ -static int raw_count = 0; -static struct _console_ctrl *cc = NULL; -static int console_count = 0; -static int rmbuf_inuse = 0; - -static void (PMAPIP fatalErrorCleanup)(void) = NULL; - -/*----------------------------- Implementation ----------------------------*/ - -void PMAPI PM_init(void) -{ - char *force; - - if (VRegs == NULL) { -#ifdef __QNXNTO__ - ThreadCtl(_NTO_TCTL_IO, 0); /* Get IO privilidge */ -#endif - force = getenv("VBIOS_METHOD"); - VRegs = VBIOSinit(force ? atoi(force) : 0); - } -#ifndef __QNXNTO__ - MTRR_init(); -#endif -} - -ibool PMAPI PM_haveBIOSAccess(void) -{ return VRegs != NULL; } - -long PMAPI PM_getOSType(void) -{ return _OS_QNX; } - -int PMAPI PM_getModeType(void) -{ return PM_386; } - -void PMAPI PM_backslash(char *s) -{ - uint pos = strlen(s); - if (s[pos-1] != '/') { - s[pos] = '/'; - s[pos+1] = '\0'; - } -} - -void PMAPI PM_setFatalErrorCleanup( - void (PMAPIP cleanup)(void)) -{ - fatalErrorCleanup = cleanup; -} - -void PMAPI PM_fatalError(const char *msg) -{ - if (fatalErrorCleanup) - fatalErrorCleanup(); - fprintf(stderr,"%s\n", msg); - exit(1); -} - -static void ExitVBEBuf(void) -{ - if (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); - } - *len = VESABuf_len; - *rseg = VESABuf_rseg; - *roff = VESABuf_roff; - return VESABuf_ptr; -} - -static int term_raw(void) -{ - struct termios termios_p; - - if (raw_count++ > 0) - return 0; - - /* Go into "raw" input mode */ - if (tcgetattr(STDIN_FILENO, &termios_p)) - return -1; - - termios_p.c_cc[VMIN] = 1; - termios_p.c_cc[VTIME] = 0; - termios_p.c_lflag &= ~( ECHO|ICANON|ISIG|ECHOE|ECHOK|ECHONL); - tcsetattr(STDIN_FILENO, TCSADRAIN, &termios_p); - return 0; -} - -static void term_restore(void) -{ - struct termios termios_p; - - if (raw_count-- != 1) - return; - - tcgetattr(STDIN_FILENO, &termios_p); - termios_p.c_lflag |= (ECHO|ICANON|ISIG|ECHOE|ECHOK|ECHONL); - termios_p.c_oflag |= (OPOST); - tcsetattr(STDIN_FILENO, TCSADRAIN, &termios_p); -} - -int PMAPI PM_kbhit(void) -{ - int blocking, c; - - if (term_raw() == -1) - return 0; - - /* Go into non blocking mode */ - blocking = fcntl(STDIN_FILENO, F_GETFL) | O_NONBLOCK; - fcntl(STDIN_FILENO, F_SETFL, blocking); - c = getc(stdin); - - /* restore blocking mode */ - fcntl(STDIN_FILENO, F_SETFL, blocking & ~O_NONBLOCK); - term_restore(); - if (c != EOF) { - ungetc(c, stdin); - return c; - } - clearerr(stdin); - return 0; -} - -int PMAPI PM_getch(void) -{ - int c; - - if (term_raw() == -1) - return (0); - c = getc(stdin); -#if defined(__QNX__) && !defined(__QNXNTO__) - if (c == 0xA) - c = 0x0D; - else if (c == 0x7F) - c = 0x08; -#endif - term_restore(); - return c; -} - -PM_HWND PMAPI PM_openConsole( - PM_HWND hwndUser, - int device, - int xRes, - int yRes, - int bpp, - ibool fullScreen) -{ -#ifndef __QNXNTO__ - int fd; - - if (console_count++) - return 0; - if ((fd = open("/dev/con1", O_RDWR)) == -1) - return -1; - cc = console_open(fd, O_RDWR); - close(fd); - if (cc == NULL) - return -1; -#endif - return 1; -} - -int PMAPI PM_getConsoleStateSize(void) -{ - return PM_getVGAStateSize() + sizeof(int) * 3; -} - -void PMAPI PM_saveConsoleState(void *stateBuf,int console_id) -{ -#ifdef __QNXNTO__ - int fd; - int flags; - - if ((fd = open("/dev/con1", O_RDWR)) == -1) - return; - flags = _CONCTL_INVISIBLE_CHG | _CONCTL_INVISIBLE; - devctl(fd, DCMD_CHR_SERCTL, &flags, sizeof flags, 0); - close(fd); -#else - uchar *buf = &((uchar*)stateBuf)[PM_getVGAStateSize()]; - - /* Save QNX 4 console state */ - console_read(cc, -1, 0, NULL, 0, - (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); - - /* Save state of VGA registers */ - PM_saveVGAState(stateBuf); -#endif -} - -void PMAPI PM_setSuspendAppCallback(int (_ASMAPIP saveState)(int flags)) -{ - /* TODO: Implement support for console switching if possible */ -} - -void PMAPI PM_restoreConsoleState(const void *stateBuf,PM_HWND hwndConsole) -{ -#ifdef __QNXNTO__ - int fd; - int flags; - - if ((fd = open("/dev/con1", O_RDWR)) == -1) - return; - flags = _CONCTL_INVISIBLE_CHG; - devctl(fd, DCMD_CHR_SERCTL, &flags, sizeof flags, 0); - close(fd); -#else - uchar *buf = &((uchar*)stateBuf)[PM_getVGAStateSize()]; - - /* Restore the state of the VGA compatible registers */ - PM_restoreVGAState(stateBuf); - - /* Restore QNX 4 console state */ - console_ctrl(cc, -1, *(int *)buf, - CONSOLE_NORESIZE | CONSOLE_NOSWITCH | CONSOLE_INVISIBLE); - console_write(cc, -1, 0, NULL, 0, - (int *)buf+1, (int *)buf+2, NULL); -#endif -} - -void PMAPI PM_closeConsole(PM_HWND hwndConsole) -{ -#ifndef __QNXNTO__ - if (--console_count == 0) { - console_close(cc); - cc = NULL; - } -#endif -} - -void PM_setOSCursorLocation(int x,int y) -{ - if (!cc) - return; -#ifndef __QNXNTO__ - console_write(cc, -1, 0, NULL, 0, &y, &x, NULL); -#endif -} - -void PM_setOSScreenWidth(int width,int height) -{ -} - -ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler ih, int frequency) -{ - /* TODO: Implement this for QNX */ - return false; -} - -void PMAPI PM_setRealTimeClockFrequency(int frequency) -{ - /* TODO: Implement this for QNX */ -} - -void PMAPI PM_restoreRealTimeClockHandler(void) -{ - /* TODO: Implement this for QNX */ -} - -char * PMAPI PM_getCurrentPath( - char *path, - int maxLen) -{ - return getcwd(path,maxLen); -} - -char PMAPI PM_getBootDrive(void) -{ return '/'; } - -const char * PMAPI PM_getVBEAFPath(void) -{ return PM_getNucleusConfigPath(); } - -const char * PMAPI PM_getNucleusPath(void) -{ - char *env = getenv("NUCLEUS_PATH"); -#ifdef __QNXNTO__ -#ifdef __X86__ - return env ? env : "/nto/scitech/x86/bin"; -#elif defined (__PPC__) - return env ? env : "/nto/scitech/ppcbe/bin"; -#elif defined (__MIPS__) -#ifdef __BIGENDIAN__ - return env ? env : "/nto/scitech/mipsbe/bin"; -#else - return env ? env : "/nto/scitech/mipsle/bin"; -#endif -#elif defined (__SH__) -#ifdef __BIGENDIAN__ - return env ? env : "/nto/scitech/shbe/bin"; -#else - return env ? env : "/nto/scitech/shle/bin"; -#endif -#elif defined (__ARM__) - return env ? env : "/nto/scitech/armle/bin"; -#endif -#else /* QNX 4 */ - return env ? env : "/qnx4/scitech/bin"; -#endif -} - -const char * PMAPI PM_getNucleusConfigPath(void) -{ - static char path[512]; - char *env; -#ifdef __QNXNTO__ - char temp[64]; - gethostname(temp, sizeof (temp)); - temp[sizeof (temp) - 1] = '\0'; /* Paranoid */ - sprintf(path,"/etc/config/scitech/%s/config", temp); -#else - sprintf(path,"/etc/config/scitech/%d/config", getnid()); -#endif - if ((env = getenv("NUCLEUS_PATH")) != NULL) { - strcpy(path,env); - PM_backslash(path); - strcat(path,"config"); - } - return path; -} - -const char * PMAPI PM_getUniqueID(void) -{ - static char buf[128]; -#ifdef __QNXNTO__ - gethostname(buf, sizeof (buf)); -#else - sprintf(buf,"node%d", getnid()); -#endif - return buf; -} - -const char * PMAPI PM_getMachineName(void) -{ - static char buf[128]; -#ifdef __QNXNTO__ - gethostname(buf, sizeof (buf)); -#else - sprintf(buf,"node%d", getnid()); -#endif - return buf; -} - -void * PMAPI PM_getBIOSPointer(void) -{ - return PM_mapRealPointer(0, 0x400); -} - -void * PMAPI PM_getA0000Pointer(void) -{ - static void *ptr = NULL; - void *freeptr; - unsigned offset, i, maplen; - - if (ptr != NULL) - 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); - } - if (i == 5) { - printf("Could not get a 64K aligned linear address for A0000 region\n"); - exit(1); - } - return ptr; -} - -void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) -{ - uchar_t *p; - unsigned o; - unsigned prot = PROT_READ|PROT_WRITE|(isCached?0:PROT_NOCACHE); -#ifdef __PAGESIZE - int pagesize = __PAGESIZE; -#else - int pagesize = 4096; -#endif - int rounddown = base % pagesize; -#ifndef __QNXNTO__ - static int __VidFD = -1; -#endif - - if (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); - } - } - o = base & 0xFFF; - limit = (limit + o + 0xFFF) & ~0xFFF; - if ((int)(p = mmap( 0, limit, prot, MAP_SHARED, - __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; - } -#endif - return (p + rounddown); -} - -void PMAPI PM_freePhysicalAddr(void *ptr,ulong limit) -{ - munmap(ptr,limit+1); -} - -ulong PMAPI PM_getPhysicalAddr(void *p) -{ - /* 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: Implement this! */ - return false; -} - -void PMAPI PM_sleep(ulong 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. */ - switch (port) { - 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. */ - switch (port) { - case 0: return 0x3BC; - case 1: return 0x378; - case 2: return 0x278; - } - return 0; -} - -void * PMAPI PM_mallocShared(long size) -{ - return PM_malloc(size); -} - -void PMAPI PM_freeShared(void *ptr) -{ - PM_free(ptr); -} - -void * PMAPI PM_mapToProcess(void *base,ulong limit) -{ return (void*)base; } - -void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) -{ - void *p; - - PM_init(); - - if ((p = VBIOSgetmemptr(r_seg, r_off, VRegs)) == (void *)-1) - 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; - } - if (rmbuf_inuse != 0) { - printf("PM_allocRealSeg: transfer area already in use\n"); - return 0; - } - PM_init(); - rmbuf_inuse = 1; - *r_seg = VBIOS_TransBufVSeg(VRegs); - *r_off = VBIOS_TransBufVOff(VRegs); - return (void*)VBIOS_TransBufPtr(VRegs); -} - -void PMAPI PM_freeRealSeg(void *mem) -{ - if (rmbuf_inuse == 0) { - printf("PM_freeRealSeg: nothing was allocated\n"); - return; - } - rmbuf_inuse = 0; -} - -void PMAPI DPMI_int86(int intno, DPMI_regs *regs) -{ - PM_init(); - if (VRegs == NULL) - return; - - VRegs->l.eax = regs->eax; - VRegs->l.ebx = regs->ebx; - VRegs->l.ecx = regs->ecx; - VRegs->l.edx = regs->edx; - VRegs->l.esi = regs->esi; - VRegs->l.edi = regs->edi; - - VBIOSint(intno, VRegs, 1024); - - regs->eax = VRegs->l.eax; - regs->ebx = VRegs->l.ebx; - regs->ecx = VRegs->l.ecx; - regs->edx = VRegs->l.edx; - regs->esi = VRegs->l.esi; - regs->edi = VRegs->l.edi; - regs->flags = VRegs->w.flags & 0x1; -} - -int PMAPI PM_int86(int intno, RMREGS *in, RMREGS *out) -{ - PM_init(); - if (VRegs == NULL) - return 0; - - 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; - - 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; - - return out->x.ax; -} - -int PMAPI PM_int86x(int intno, RMREGS *in, RMREGS *out, - RMSREGS *sregs) -{ - PM_init(); - if (VRegs == NULL) - 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; - } - 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; - } -} - -void PMAPI PM_callRealMode(uint seg,uint off, RMREGS *in, - RMSREGS *sregs) -{ - PM_init(); - if (VRegs == NULL) - return; - - 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; - - VBIOScall(seg, off, VRegs, 1024); - - in->e.eax = VRegs->l.eax; - in->e.ebx = VRegs->l.ebx; - in->e.ecx = VRegs->l.ecx; - in->e.edx = VRegs->l.edx; - in->e.esi = VRegs->l.esi; - in->e.edi = VRegs->l.edi; - in->x.cflag = VRegs->w.flags & 0x1; - sregs->es = VRegs->w.es; - sregs->ds = VRegs->w.ds; -} - -void PMAPI PM_availableMemory(ulong *physical,ulong *total) -{ -#ifndef __QNXNTO__ - *physical = *total = _memavl(); -#endif -} - -void * PMAPI PM_allocLockedMem( - uint size, - ulong *physAddr, - ibool contiguous, - ibool below16M) -{ - /* TODO: Implement this on QNX */ - return NULL; -} - -void PMAPI PM_freeLockedMem( - void *p, - uint size, - ibool contiguous) -{ - /* TODO: Implement this on QNX */ -} - -void * PMAPI PM_allocPage( - ibool locked) -{ - /* TODO: Implement this on QNX */ - return NULL; -} - -void PMAPI PM_freePage( - void *p) -{ - /* TODO: Implement this on QNX */ -} - -void PMAPI PM_setBankA(int bank) -{ - PM_init(); - if (VRegs == NULL) - return; - - VRegs->l.eax = 0x4F05; - VRegs->l.ebx = 0x0000; - VRegs->l.edx = bank; - VBIOSint(0x10, VRegs, 1024); -} - -void PMAPI PM_setBankAB(int bank) -{ - PM_init(); - if (VRegs == NULL) - return; - - VRegs->l.eax = 0x4F05; - VRegs->l.ebx = 0x0000; - VRegs->l.edx = bank; - VBIOSint(0x10, VRegs, 1024); - - VRegs->l.eax = 0x4F05; - VRegs->l.ebx = 0x0001; - VRegs->l.edx = bank; - VBIOSint(0x10, VRegs, 1024); -} - -void PMAPI PM_setCRTStart(int x,int y,int waitVRT) -{ - PM_init(); - if (VRegs == NULL) - return; - - VRegs->l.eax = 0x4F07; - VRegs->l.ebx = waitVRT; - VRegs->l.ecx = x; - VRegs->l.edx = y; - VBIOSint(0x10, VRegs, 1024); -} - -ibool PMAPI PM_doBIOSPOST( - ushort axVal, - ulong BIOSPhysAddr, - void *copyOfBIOS, - ulong BIOSLen) -{ - (void)axVal; - (void)BIOSPhysAddr; - (void)copyOfBIOS; - (void)BIOSLen; - return false; -} - -int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - p = p; len = len; - return 1; -} - -int PMAPI PM_unlockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - p = p; len = len; - return 1; -} - -int PMAPI PM_lockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - p = p; len = len; - return 1; -} - -int PMAPI PM_unlockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - p = p; len = len; - return 1; -} - -PM_MODULE PMAPI PM_loadLibrary( - const char *szDLLName) -{ - /* TODO: Implement this to load shared libraries! */ - (void)szDLLName; - return NULL; -} - -void * PMAPI PM_getProcAddress( - PM_MODULE hModule, - const char *szProcName) -{ - /* TODO: Implement this! */ - (void)hModule; - (void)szProcName; - return NULL; -} - -void PMAPI PM_freeLibrary( - PM_MODULE hModule) -{ - /* TODO: Implement this! */ - (void)hModule; -} - -int PMAPI PM_setIOPL( - int level) -{ - /* QNX handles IOPL selection at the program link level. */ - return level; -} - -/**************************************************************************** -PARAMETERS: -base - The starting physical base address of the region -size - The size in bytes of the region -type - Type to place into the MTRR register - -RETURNS: -Error code describing the result. - -REMARKS: -Function to enable write combining for the specified region of memory. -****************************************************************************/ -int PMAPI PM_enableWriteCombine( - ulong base, - ulong size, - uint type) -{ -#ifndef __QNXNTO__ - return MTRR_enableWriteCombine(base,size,type); -#else - return PM_MTRR_NOT_SUPPORTED; -#endif -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/qnx/vflat.c b/board/MAI/bios_emulator/scitech/src/pm/qnx/vflat.c deleted file mode 100644 index 579ef2c95c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/qnx/vflat.c +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Dummy module; no virtual framebuffer for this OS -* -****************************************************************************/ - -#include "pmapi.h" - -ibool PMAPI VF_available(void) -{ - return false; -} - -void * PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) -{ - baseAddr = baseAddr; - bankSize = bankSize; - codeLen = codeLen; - bankFunc = bankFunc; - return NULL; -} - -void PMAPI VF_exit(void) -{ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/qnx/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/qnx/ztimer.c deleted file mode 100644 index d2740971f9..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/qnx/ztimer.c +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: QNX -* -* Description: QNX specific implementation for the Zen Timer functions. -* -****************************************************************************/ - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Initialise the Zen Timer module internals. -****************************************************************************/ -void __ZTimerInit(void) -{ -} - -/**************************************************************************** -REMARKS: -Use the gettimeofday() function to get microsecond precision (probably less -though) -****************************************************************************/ -static ulong __ULZReadTime(void) -{ - struct timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); - return (ts.tv_nsec / 1000 + ts.tv_sec * 1000000); -} - -/**************************************************************************** -REMARKS: -Start the Zen Timer counting. -****************************************************************************/ -#define __LZTimerOn(tm) tm->start.low = __ULZReadTime() - -/**************************************************************************** -REMARKS: -Compute the lap time since the timer was started. -****************************************************************************/ -#define __LZTimerLap(tm) (__ULZReadTime() - tm->start.low) - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerOff(tm) tm->end.low = __ULZReadTime() - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerCount(tm) (tm->end.low - tm->start.low) - -/**************************************************************************** -REMARKS: -Define the resolution of the long period timer as microseconds per timer tick. -****************************************************************************/ -#define ULZTIMER_RESOLUTION 1 - -/**************************************************************************** -REMARKS: -Compute the elapsed time from the BIOS timer tick. Note that we check to see -whether a midnight boundary has passed, and if so adjust the finish time to -account for this. We cannot detect if more that one midnight boundary has -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/rttarget/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/rttarget/cpuinfo.c deleted file mode 100644 index 4f32c3e887..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/rttarget/cpuinfo.c +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: RTTarget-32 -* -* Description: Module to implement OS specific services to measure the -* CPU frequency. -* -****************************************************************************/ - -/*---------------------------- Global variables ---------------------------*/ - -static ibool havePerformanceCounter; - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Increase the thread priority to maximum, if possible. -****************************************************************************/ -static int SetMaxThreadPriority(void) -{ - int oldPriority; - HANDLE hThread = GetCurrentThread(); - - oldPriority = GetThreadPriority(hThread); - if (oldPriority != THREAD_PRIORITY_ERROR_RETURN) - SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); - return oldPriority; -} - -/**************************************************************************** -REMARKS: -Restore the original thread priority. -****************************************************************************/ -static void RestoreThreadPriority( - int oldPriority) -{ - HANDLE hThread = GetCurrentThread(); - - if (oldPriority != THREAD_PRIORITY_ERROR_RETURN) - SetThreadPriority(hThread, oldPriority); -} - -/**************************************************************************** -REMARKS: -Initialise the counter and return the frequency of the counter. -****************************************************************************/ -static void GetCounterFrequency( - CPU_largeInteger *freq) -{ - if (!QueryPerformanceFrequency((LARGE_INTEGER*)freq)) { - havePerformanceCounter = false; - freq->low = 100000; - freq->high = 0; - } - else - havePerformanceCounter = true; -} - -/**************************************************************************** -REMARKS: -Read the counter and return the counter value. -****************************************************************************/ -#define GetCounter(t) \ -{ \ - if (havePerformanceCounter) \ - QueryPerformanceCounter((LARGE_INTEGER*)t); \ - else { \ - (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 deleted file mode 100644 index 962a14a3c1..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/rttarget/event.c +++ /dev/null @@ -1,287 +0,0 @@ -/**************************************************************************** -* -* SciTech Multi-platform Graphics Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: RTTarget-32 -* -* Description: Win32 implementation for the SciTech cross platform -* event library. -* -****************************************************************************/ - -/*---------------------------- Global Variables ---------------------------*/ - -static ushort keyUpMsg[256] = {0}; /* Table of key up messages */ -static int rangeX,rangeY; /* Range of mouse coordinates */ - -/*---------------------------- Implementation -----------------------------*/ - -/* These are not used under Win32 */ -#define _EVT_disableInt() 1 -#define _EVT_restoreInt(flags) - -/**************************************************************************** -PARAMETERS: -scanCode - Scan code to test - -REMARKS: -This macro determines if a specified key is currently down at the -time that the call is made. -****************************************************************************/ -#define _EVT_isKeyDown(scanCode) (keyUpMsg[scanCode] != 0) - -/**************************************************************************** -REMARKS: -This function is used to return the number of ticks since system -startup in milliseconds. This should be the same value that is placed into -the time stamp fields of events, and is used to implement auto mouse down -events. -****************************************************************************/ -ulong _EVT_getTicks(void) -{ return timeGetTime(); } - -/**************************************************************************** -REMARKS: -Pumps all messages in the message queue from Win32 into our event queue. -****************************************************************************/ -void _EVT_pumpMessages(void) -{ - MSG msg; - MSG charMsg; - 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; - } - - /* 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; - } - - 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); - } -} - -/**************************************************************************** -REMARKS: -This macro/function is used to converts the scan codes reported by the -keyboard to our event libraries normalised format. We only have one scan -code for the 'A' key, and use shift modifiers to determine if it is a -Ctrl-F1, Alt-F1 etc. The raw scan codes from the keyboard work this way, -but the OS gives us 'cooked' scan codes, we have to translate them back -to the raw format. -****************************************************************************/ -#define _EVT_maskKeyCode(evt) - -/**************************************************************************** -REMARKS: -Safely abort the event module upon catching a fatal error. -****************************************************************************/ -void _EVT_abort() -{ - EVT_exit(); - PM_fatalError("Unhandled exception!"); -} - -/**************************************************************************** -PARAMETERS: -mouseMove - Callback function to call wheneve the mouse needs to be moved - -REMARKS: -Initiliase the event handling module. Here we install our mouse handling ISR -to be called whenever any button's are pressed or released. We also build -the free list of events in the event queue. - -We use handler number 2 of the mouse libraries interrupt handlers for our -event handling routines. -****************************************************************************/ -void EVTAPI EVT_init( - _EVT_mouseMoveHandler mouseMove) -{ - /* Initialise the event queue */ - _mouseMove = mouseMove; - initEventQueue(); - memset(keyUpMsg,0,sizeof(keyUpMsg)); - - /* Catch program termination signals so we can clean up properly */ - signal(SIGABRT, _EVT_abort); - signal(SIGFPE, _EVT_abort); - signal(SIGINT, _EVT_abort); -} - -/**************************************************************************** -REMARKS -Changes the range of coordinates returned by the mouse functions to the -specified range of values. This is used when changing between graphics -modes set the range of mouse coordinates for the new display mode. -****************************************************************************/ -void EVTAPI EVT_setMouseRange( - int xRes, - int yRes) -{ - rangeX = xRes; - rangeY = yRes; -} - -/**************************************************************************** -REMARKS -Modifes the mouse coordinates as necessary if scaling to OS coordinates, -and sets the OS mouse cursor position. -****************************************************************************/ -void _EVT_setMousePos( - int *x, - int *y) -{ - SetCursorPos(*x,*y); -} - -/**************************************************************************** -REMARKS: -Initiailises the internal event handling modules. The EVT_suspend function -can be called to suspend event handling (such as when shelling out to DOS), -and this function can be used to resume it again later. -****************************************************************************/ -void EVT_resume(void) -{ - /* Do nothing for Win32 */ -} - -/**************************************************************************** -REMARKS -Suspends all of our event handling operations. This is also used to -de-install the event handling code. -****************************************************************************/ -void EVT_suspend(void) -{ - /* Do nothing for Win32 */ -} - -/**************************************************************************** -REMARKS -Exits the event module for program terminatation. -****************************************************************************/ -void EVT_exit(void) -{ - /* Restore signal handlers */ - signal(SIGABRT, SIG_DFL); - signal(SIGFPE, SIG_DFL); - signal(SIGINT, SIG_DFL); -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/rttarget/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/rttarget/oshdr.h deleted file mode 100644 index 1352dadad6..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/rttarget/oshdr.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: RTTarget-32 -* -* Description: Include file to include all OS specific header files. -* -****************************************************************************/ - -#define WIN32_LEAN_AND_MEAN -#define STRICT -#include -#include diff --git a/board/MAI/bios_emulator/scitech/src/pm/rttarget/pm.c b/board/MAI/bios_emulator/scitech/src/pm/rttarget/pm.c deleted file mode 100644 index 47d7ed6ab1..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/rttarget/pm.c +++ /dev/null @@ -1,701 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: RTTarget-32 -* -* Description: Implementation for the OS Portability Manager Library, which -* contains functions to implement OS specific services in a -* generic, cross platform API. Porting the OS Portability -* Manager library is the first step to porting any SciTech -* products to a new platform. -* -****************************************************************************/ - -#include "pmapi.h" -#include "drvlib/os/os.h" -#include -#include -#include -#define WIN32_LEAN_AND_MEAN -#define STRICT -#include -#include -#ifdef __BORLANDC__ -#pragma warn -par -#endif - -/*--------------------------- Global variables ----------------------------*/ - -static void (PMAPIP fatalErrorCleanup)(void) = NULL; - -/*----------------------------- Implementation ----------------------------*/ - -void MTRR_init(void); - -/**************************************************************************** -REMARKS: -Initialise the PM library. -****************************************************************************/ -void PMAPI PM_init(void) -{ - /* TODO: dO any special init code in here. */ - MTRR_init(); -} - -/**************************************************************************** -REMARKS: -Return the operating system type identifier. -****************************************************************************/ -long PMAPI PM_getOSType(void) -{ - return _OS_RTTARGET; -} - -/**************************************************************************** -REMARKS: -Return the runtime type identifier. -****************************************************************************/ -int PMAPI PM_getModeType(void) -{ - return PM_386; -} - -/**************************************************************************** -REMARKS: -Add a file directory separator to the end of the filename. -****************************************************************************/ -void PMAPI PM_backslash( - char *s) -{ - uint pos = strlen(s); - if (s[pos-1] != '\\') { - s[pos] = '\\'; - s[pos+1] = '\0'; - } -} - -/**************************************************************************** -REMARKS: -Add a user defined PM_fatalError cleanup function. -****************************************************************************/ -void PMAPI PM_setFatalErrorCleanup( - void (PMAPIP cleanup)(void)) -{ - fatalErrorCleanup = cleanup; -} - -/**************************************************************************** -REMARKS: -Report a fatal error condition and halt the program. -****************************************************************************/ -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); */ - exit(1); -} - -/**************************************************************************** -REMARKS: -Allocate the real mode VESA transfer buffer for communicating with the BIOS. -****************************************************************************/ -void * PMAPI PM_getVESABuf( - uint *len, - uint *rseg, - uint *roff) -{ - /* No BIOS access for the RTTarget */ - return NULL; -} - -/**************************************************************************** -REMARKS: -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 */ - return true; -} - -/**************************************************************************** -REMARKS: -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 */ - return 0xD; -} - -/**************************************************************************** -REMARKS: -Set the location of the OS console cursor. -****************************************************************************/ -void PM_setOSCursorLocation( - int x, - int y) -{ - /* Nothing to do for RTTarget-32 */ -} - -/**************************************************************************** -REMARKS: -Set the width of the OS console. -****************************************************************************/ -void PM_setOSScreenWidth( - int width, - int height) -{ - /* Nothing to do for RTTarget-32 */ -} - -/**************************************************************************** -REMARKS: -Set the real time clock handler (used for software stereo modes). -****************************************************************************/ -ibool PMAPI PM_setRealTimeClockHandler( - PM_intHandler ih, - int frequency) -{ - /* Not supported for RTTarget-32 */ - return false; -} - -/**************************************************************************** -REMARKS: -Set the real time clock frequency (for stereo modes). -****************************************************************************/ -void PMAPI PM_setRealTimeClockFrequency( - int frequency) -{ - /* Not supported under RTTarget-32 */ -} - -/**************************************************************************** -REMARKS: -Restore the original real time clock handler. -****************************************************************************/ -void PMAPI PM_restoreRealTimeClockHandler(void) -{ - /* Not supported under RTTarget-32 */ -} - -/**************************************************************************** -REMARKS: -Return the current operating system path or working directory. -****************************************************************************/ -char * PMAPI PM_getCurrentPath( - char *path, - int maxLen) -{ - return getcwd(path,maxLen); -} - -/**************************************************************************** -REMARKS: -Return the drive letter for the boot drive. -****************************************************************************/ -char PMAPI PM_getBootDrive(void) -{ - return 'c'; -} - -/**************************************************************************** -REMARKS: -Return the path to the VBE/AF driver files. -****************************************************************************/ -const char * PMAPI PM_getVBEAFPath(void) -{ - return "c:\\"; -} - -/**************************************************************************** -REMARKS: -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 */ - return "c:\\nucleus"; -} - -/**************************************************************************** -REMARKS: -Return the path to the Nucleus configuration files. -****************************************************************************/ -const char * PMAPI PM_getNucleusConfigPath(void) -{ - static char path[256]; - strcpy(path,PM_getNucleusPath()); - PM_backslash(path); - strcat(path,"config"); - return path; -} - -/**************************************************************************** -REMARKS: -Return a unique identifier for the machine if possible. -****************************************************************************/ -const char * PMAPI PM_getUniqueID(void) -{ - return PM_getMachineName(); -} - -/**************************************************************************** -REMARKS: -Get the name of the machine on the network. -****************************************************************************/ -const char * PMAPI PM_getMachineName(void) -{ - /* Not necessary for RTTarget-32 */ - return "Unknown"; -} - -/**************************************************************************** -REMARKS: -Return a pointer to the real mode BIOS data area. -****************************************************************************/ -void * PMAPI PM_getBIOSPointer(void) -{ - /* Not used for RTTarget-32 */ - return NULL; -} - -/**************************************************************************** -REMARKS: -Return a pointer to 0xA0000 physical VGA graphics framebuffer. -****************************************************************************/ -void * PMAPI PM_getA0000Pointer(void) -{ - static void *bankPtr; - if (!bankPtr) - bankPtr = PM_mapPhysicalAddr(0xA0000,0xFFFF,true); - return bankPtr; -} - -/**************************************************************************** -REMARKS: -Map a physical address to a linear address in the callers process. -****************************************************************************/ -void * PMAPI PM_mapPhysicalAddr( - ulong base, - ulong limit, - ibool isCached) -{ - /* TODO: Map a physical memory address to a linear address */ - return NULL; -} - -/**************************************************************************** -REMARKS: -Free a physical address mapping allocated by PM_mapPhysicalAddr. -****************************************************************************/ -void PMAPI PM_freePhysicalAddr( - void *ptr, - ulong limit) -{ - /* TODO: Free the physical address mapping */ -} - -ulong PMAPI PM_getPhysicalAddr(void *p) -{ - /* TODO: This function should find the physical address of a linear */ - /* address. */ - return 0xFFFFFFFFUL; -} - -void PMAPI PM_sleep(ulong milliseconds) -{ - Sleep(milliseconds); -} - -int PMAPI PM_getCOMPort(int port) -{ - /* 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; - } - 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. */ - switch (port) { - case 0: return 0x3BC; - case 1: return 0x378; - case 2: return 0x278; - } - return 0; -} - -/**************************************************************************** -REMARKS: -Allocate a block of (unnamed) shared memory. -****************************************************************************/ -void * PMAPI PM_mallocShared( - long size) -{ - return PM_malloc(size); -} - -/**************************************************************************** -REMARKS: -Free a block of shared memory. -****************************************************************************/ -void PMAPI PM_freeShared( - void *ptr) -{ - PM_free(ptr); -} - -/**************************************************************************** -REMARKS: -Map a linear memory address to the calling process address space. The -address will have been allocated in another process using the -PM_mapPhysicalAddr function. -****************************************************************************/ -void * PMAPI PM_mapToProcess( - void *base, - ulong limit) -{ - return base; -} - -/**************************************************************************** -REMARKS: -Map a real mode pointer to a protected mode pointer. -****************************************************************************/ -void * PMAPI PM_mapRealPointer( - uint r_seg, - uint r_off) -{ - /* Not used for RTTarget-32 */ - return NULL; -} - -/**************************************************************************** -REMARKS: -Allocate a block of real mode memory -****************************************************************************/ -void * PMAPI PM_allocRealSeg( - uint size, - uint *r_seg, - uint *r_off) -{ - /* Not used for RTTarget-32 */ - return NULL; -} - -/**************************************************************************** -REMARKS: -Free a block of real mode memory. -****************************************************************************/ -void PMAPI PM_freeRealSeg( - void *mem) -{ - /* Not used for RTTarget-32 */ -} - -/**************************************************************************** -REMARKS: -Issue a real mode interrupt (parameters in DPMI compatible structure) -****************************************************************************/ -void PMAPI DPMI_int86( - int intno, - DPMI_regs *regs) -{ - /* Not used for RTTarget-32 */ -} - -/**************************************************************************** -REMARKS: -Issue a real mode interrupt. -****************************************************************************/ -int PMAPI PM_int86( - int intno, - RMREGS *in, - RMREGS *out) -{ - /* Not used for RTTarget-32 */ - return 0; -} - -/**************************************************************************** -REMARKS: -Issue a real mode interrupt. -****************************************************************************/ -int PMAPI PM_int86x( - int intno, - RMREGS *in, - RMREGS *out, - RMSREGS *sregs) -{ - /* Not used for RTTarget-32 */ - return 0; -} - -/**************************************************************************** -REMARKS: -Call a real mode far function. -****************************************************************************/ -void PMAPI PM_callRealMode( - uint seg, - uint off, - RMREGS *in, - RMSREGS *sregs) -{ - /* Not used for RTTarget-32 */ -} - -/**************************************************************************** -REMARKS: -Return the amount of available memory. -****************************************************************************/ -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. */ - *physical = *total = 0; -} - -/**************************************************************************** -REMARKS: -Allocate a block of locked, physical memory for DMA operations. -****************************************************************************/ -void * PMAPI PM_allocLockedMem( - uint size, - ulong *physAddr, - ibool contiguous, - ibool below16M) -{ - /* TODO: Allocate a block of locked, phsyically contigous memory for DMA */ - return 0; -} - -/**************************************************************************** -REMARKS: -Free a block of locked physical memory. -****************************************************************************/ -void PMAPI PM_freeLockedMem( - void *p, - uint size, - - ibool contiguous) -{ - /* TODO: Free a locked memory buffer */ -} - -/**************************************************************************** -REMARKS: -Call the VBE/Core software interrupt to change display banks. -****************************************************************************/ -void PMAPI PM_setBankA( - int bank) -{ - /* Not used for RTTarget-32 */ -} - -/**************************************************************************** -REMARKS: -Call the VBE/Core software interrupt to change display banks. -****************************************************************************/ -void PMAPI PM_setBankAB( - int bank) -{ - /* Not used for RTTarget-32 */ -} - -/**************************************************************************** -REMARKS: -Call the VBE/Core software interrupt to change display start address. -****************************************************************************/ -void PMAPI PM_setCRTStart( - int x, - int y, - int waitVRT) -{ - /* Not used for RTTarget-32 */ -} - -/**************************************************************************** -REMARKS: -Execute the POST on the secondary BIOS for a controller. -****************************************************************************/ -ibool PMAPI PM_doBIOSPOST( - ushort axVal, - ulong BIOSPhysAddr, - void *mappedBIOS) -{ - /* Not used for RTTarget-32 */ - return false; -} - -PM_MODULE PMAPI PM_loadLibrary( - const char *szDLLName) -{ - /* TODO: Implement this to load shared libraries! */ - (void)szDLLName; - return NULL; -} - -void * PMAPI PM_getProcAddress( - PM_MODULE hModule, - const char *szProcName) -{ - /* TODO: Implement this! */ - (void)hModule; - (void)szProcName; - return NULL; -} - -void PMAPI PM_freeLibrary( - PM_MODULE hModule) -{ - /* TODO: Implement this! */ - (void)hModule; -} - -/**************************************************************************** -REMARKS: -Function to find the first file matching a search criteria in a directory. -****************************************************************************/ -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. */ - (void)filename; - (void)findData; - return PM_FILE_INVALID; -} - -/**************************************************************************** -REMARKS: -Function to find the next file matching a search criteria in a directory. -****************************************************************************/ -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. */ - (void)handle; - (void)findData; - return false; -} - -/**************************************************************************** -REMARKS: -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. */ - (void)handle; -} - -/**************************************************************************** -REMARKS: -Function to determine if a drive is a valid drive or not. Under Unix this -function will return false for anything except a value of 3 (considered -the root drive, and equivalent to C: for non-Unix systems). The drive -numbering is: - - 1 - Drive A: - 2 - Drive B: - 3 - Drive C: - etc - -****************************************************************************/ -ibool PMAPI PM_driveValid( - char drive) -{ - if (drive == 3) - return true; - return false; -} - -/**************************************************************************** -REMARKS: -Function to get the current working directory for the specififed drive. -Under Unix this will always return the current working directory regardless -of what the value of 'drive' is. -****************************************************************************/ -void PMAPI PM_getdcwd( - int drive, - char *dir, - int len) -{ - (void)drive; - getcwd(dir,len); -} - -/**************************************************************************** -REMARKS: -Function to change the file attributes for a specific file. -****************************************************************************/ -void PMAPI PM_setFileAttr( - const char *filename, - uint attrib) -{ - /* TODO: Set the file attributes for a file */ - (void)filename; - (void)attrib; -} - -/**************************************************************************** -REMARKS: -Function to create a directory. -****************************************************************************/ -ibool PMAPI PM_mkdir( - const char *filename) -{ - return mkdir(filename) == 0; -} - -/**************************************************************************** -REMARKS: -Function to remove a directory. -****************************************************************************/ -ibool PMAPI PM_rmdir( - const char *filename) -{ - return rmdir(filename) == 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/rttarget/vflat.c b/board/MAI/bios_emulator/scitech/src/pm/rttarget/vflat.c deleted file mode 100644 index dd9dfe6826..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/rttarget/vflat.c +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: RTTarget-32 -* -* Description: Dummy module; no virtual framebuffer for this OS -* -****************************************************************************/ - -#include "pmapi.h" -#ifdef __BORLANDC__ -#pragma warn -par -#endif - -ibool PMAPI VF_available(void) -{ - return false; -} - -void * PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) -{ - return NULL; -} - -void PMAPI VF_exit(void) -{ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/rttarget/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/rttarget/ztimer.c deleted file mode 100644 index 80c184dff1..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/rttarget/ztimer.c +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: RTTarget-32 -* -* Description: OS specific implementation for the Zen Timer functions. -* -****************************************************************************/ - -/*---------------------------- Global variables ---------------------------*/ - -static CPU_largeInteger countFreq; -static ibool havePerformanceCounter; -static ulong start,finish; - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Initialise the Zen Timer module internals. -****************************************************************************/ -void __ZTimerInit(void) -{ -#ifdef NO_ASSEMBLER - havePerformanceCounter = false; -#else - havePerformanceCounter = QueryPerformanceFrequency((LARGE_INTEGER*)&countFreq); -#endif -} - -/**************************************************************************** -REMARKS: -Start the Zen Timer counting. -****************************************************************************/ -static void __LZTimerOn( - LZTimerObject *tm) -{ - if (havePerformanceCounter) - QueryPerformanceCounter((LARGE_INTEGER*)&tm->start); - else - tm->start.low = timeGetTime(); -} - -/**************************************************************************** -REMARKS: -Compute the lap time since the timer was started. -****************************************************************************/ -static ulong __LZTimerLap( - LZTimerObject *tm) -{ - CPU_largeInteger tmLap,tmCount; - - if (havePerformanceCounter) { - 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; - } -} - -/**************************************************************************** -REMARKS: -Stop the Zen Timer counting. -****************************************************************************/ -static void __LZTimerOff( - LZTimerObject *tm) -{ - if (havePerformanceCounter) - QueryPerformanceCounter((LARGE_INTEGER*)&tm->end); - else - tm->end.low = timeGetTime(); -} - -/**************************************************************************** -REMARKS: -Compute the elapsed time in microseconds between start and end timings. -****************************************************************************/ -static ulong __LZTimerCount( - LZTimerObject *tm) -{ - CPU_largeInteger tmCount; - - if (havePerformanceCounter) { - _CPU_diffTime64(&tm->start,&tm->end,&tmCount); - return _CPU_calcMicroSec(&tmCount,countFreq.low); - } - else - return (tm->end.low - tm->start.low) * 1000L; -} - -/**************************************************************************** -REMARKS: -Define the resolution of the long period timer as microseconds per timer tick. -****************************************************************************/ -#define ULZTIMER_RESOLUTION 1000 - -/**************************************************************************** -REMARKS: -Read the Long Period timer from the OS -****************************************************************************/ -static ulong __ULZReadTime(void) -{ return timeGetTime(); } - -/**************************************************************************** -REMARKS: -Compute the elapsed time from the BIOS timer tick. Note that we check to see -whether a midnight boundary has passed, and if so adjust the finish time to -account for this. We cannot detect if more that one midnight boundary has -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/smx/_event.asm b/board/MAI/bios_emulator/scitech/src/pm/smx/_event.asm deleted file mode 100644 index da62b1f712..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/_event.asm +++ /dev/null @@ -1,175 +0,0 @@ -;**************************************************************************** -;* -;* SciTech Multi-platform Graphics Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: 80386 Assembler -;* Environment: IBM PC (MS DOS) -;* -;* Description: Assembly language support routines for the event module. -;* -;**************************************************************************** - - ideal - -include "scitech.mac" ; Memory model macros - -ifdef flatmodel - -header _event ; Set up memory model - -begdataseg _event - - cextern _EVT_biosPtr,DPTR - - cpublic _EVT_dataStart - -ifdef USE_NASM -%define KB_HEAD WORD esi+01Ah ; Keyboard buffer head in BIOS data area -%define KB_TAIL WORD esi+01Ch ; Keyboard buffer tail in BIOS data area -%define KB_START WORD esi+080h ; Start of keyboard buffer in BIOS data area -%define KB_END WORD esi+082h ; End of keyboard buffer in BIOS data area -else -KB_HEAD EQU WORD esi+01Ah ; Keyboard buffer head in BIOS data area -KB_TAIL EQU WORD esi+01Ch ; Keyboard buffer tail in BIOS data area -KB_START EQU WORD esi+080h ; Start of keyboard buffer in BIOS data area -KB_END EQU WORD esi+082h ; End of keyboard buffer in BIOS data area -endif - - cpublic _EVT_dataEnd - -enddataseg _event - -begcodeseg _event ; Start of code segment - - cpublic _EVT_codeStart - -;---------------------------------------------------------------------------- -; int _EVT_getKeyCode(void) -;---------------------------------------------------------------------------- -; Returns the key code for the next available key by extracting it from -; the BIOS keyboard buffer. -;---------------------------------------------------------------------------- -cprocstart _EVT_getKeyCode - - enter_c - - mov esi,[_EVT_biosPtr] - xor ebx,ebx - xor eax,eax - mov bx,[KB_HEAD] - cmp bx,[KB_TAIL] - jz @@Done - xor eax,eax - mov ax,[esi+ebx] ; EAX := character from keyboard buffer - inc _bx - inc _bx - cmp bx,[KB_END] ; Hit the end of the keyboard buffer? - jl @@1 - mov bx,[KB_START] -@@1: mov [KB_HEAD],bx ; Update keyboard buffer head pointer - -@@Done: leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; int _EVT_disableInt(void); -;---------------------------------------------------------------------------- -; Return processor interrupt status and disable interrupts. -;---------------------------------------------------------------------------- -cprocstart _EVT_disableInt - - pushf ; Put flag word on stack - cli ; Disable interrupts! - pop eax ; deposit flag word in return register - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _EVT_restoreInt(int ps); -;---------------------------------------------------------------------------- -; Restore processor interrupt status. -;---------------------------------------------------------------------------- -cprocstart _EVT_restoreInt - - ARG ps:UINT - - push ebp - mov ebp,esp ; Set up stack frame - push [DWORD ps] - popf ; Restore processor status (and interrupts) - pop ebp - ret - -cprocend - -;---------------------------------------------------------------------------- -; int EVT_rdinx(int port,int index) -;---------------------------------------------------------------------------- -; Reads an indexed register value from an I/O port. -;---------------------------------------------------------------------------- -cprocstart EVT_rdinx - - ARG port:UINT, index:UINT - - push ebp - mov ebp,esp - mov edx,[port] - mov al,[BYTE index] - out dx,al - inc dx - in al,dx - movzx eax,al - pop ebp - ret - -cprocend - -;---------------------------------------------------------------------------- -; void EVT_wrinx(int port,int index,int value) -;---------------------------------------------------------------------------- -; Writes an indexed register value to an I/O port. -;---------------------------------------------------------------------------- -cprocstart EVT_wrinx - - ARG port:UINT, index:UINT, value:UINT - - push ebp - mov ebp,esp - mov edx,[port] - mov al,[BYTE index] - mov ah,[BYTE value] - out dx,ax - pop ebp - ret - -cprocend - - cpublic _EVT_codeEnd - -endcodeseg _event - -endif - - END ; End of module diff --git a/board/MAI/bios_emulator/scitech/src/pm/smx/_lztimer.asm b/board/MAI/bios_emulator/scitech/src/pm/smx/_lztimer.asm deleted file mode 100644 index 068eea65d2..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/_lztimer.asm +++ /dev/null @@ -1,58 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: NASM or TASM Assembler -;* Environment: smx 32 bit intel CPU -;* -;* Description: SMX does not support 486's, so this module is not necessary. -;* -;* All registers and all flags are preserved by all routines, except -;* interrupts which are always turned on -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" - -header _lztimer - -begdataseg _lztimer - -enddataseg _lztimer - -begcodeseg _lztimer ; Start of code segment - -cprocstart LZ_disable - cli - ret -cprocend - -cprocstart LZ_enable - sti - ret -cprocend - -endcodeseg _lztimer - - END diff --git a/board/MAI/bios_emulator/scitech/src/pm/smx/_pm.asm b/board/MAI/bios_emulator/scitech/src/pm/smx/_pm.asm deleted file mode 100644 index 1c7cb21864..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/_pm.asm +++ /dev/null @@ -1,448 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: 80386 Assembler, TASM 4.0 or NASM -;* Environment: 32-bit SMX embedded systems development -;* -;* Description: Low level assembly support for the PM library specific to -;* SMX. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -header _pm ; Set up memory model - -begdataseg _pm - - cextern _PM_savedDS,USHORT - -intel_id db "GenuineIntel" ; Intel vendor ID - -enddataseg _pm - -begcodeseg _pm ; Start of code segment - -;---------------------------------------------------------------------------- -; void PM_segread(PMSREGS *sregs) -;---------------------------------------------------------------------------- -; Read the current value of all segment registers -;---------------------------------------------------------------------------- -cprocstartdll16 PM_segread - - ARG sregs:DPTR - - enter_c - - mov ax,es - _les _si,[sregs] - mov [_ES _si],ax - mov [_ES _si+2],cs - mov [_ES _si+4],ss - mov [_ES _si+6],ds - mov [_ES _si+8],fs - mov [_ES _si+10],gs - - leave_c - ret - -cprocend - -; Create a table of the 256 different interrupt calls that we can jump -; into - -ifdef USE_NASM - -%assign intno 0 - -intTable: -%rep 256 - db 0CDh - db intno -%assign intno intno + 1 - ret - nop -%endrep - -else - -intno = 0 - -intTable: - REPT 256 - db 0CDh - db intno -intno = intno + 1 - ret - nop - ENDM - -endif - -;---------------------------------------------------------------------------- -; _PM_genInt - Generate the appropriate interrupt -;---------------------------------------------------------------------------- -cprocnear _PM_genInt - - push _ax ; Save _ax - push _bx ; Save _bx - mov ebx,[UINT esp+12] ; EBX := interrupt number - mov _ax,offset intTable ; Point to interrupt generation table - shl _bx,2 ; _BX := index into table - add _ax,_bx ; _AX := pointer to interrupt code - xchg eax,[esp+4] ; Restore eax, and set for int - pop _bx ; restore _bx - ret - -cprocend - -;---------------------------------------------------------------------------- -; int PM_int386x(int intno, PMREGS *in, PMREGS *out,PMSREGS *sregs) -;---------------------------------------------------------------------------- -; Issues a software interrupt in protected mode. This routine has been -; written to allow user programs to load CS and DS with different values -; other than the default. -;---------------------------------------------------------------------------- -cprocstartdll16 PM_int386x - - ARG intno:UINT, inptr:DPTR, outptr:DPTR, sregs:DPTR - - LOCAL flags:UINT, sv_ds:UINT, sv_esi:ULONG = LocalSize - - enter_c - push ds - push es ; Save segment registers - push fs - push gs - - _lds _si,[sregs] ; DS:_SI -> Load segment registers - mov es,[_si] - mov bx,[_si+6] - mov [sv_ds],_bx ; Save value of user DS on stack - mov fs,[_si+8] - mov gs,[_si+10] - - _lds _si,[inptr] ; Load CPU registers - mov eax,[_si] - mov ebx,[_si+4] - mov ecx,[_si+8] - mov edx,[_si+12] - mov edi,[_si+20] - mov esi,[_si+16] - - push ds ; Save value of DS - push _bp ; Some interrupts trash this! - clc ; Generate the interrupt - push [UINT intno] - mov ds,[WORD sv_ds] ; Set value of user's DS selector - call _PM_genInt - pop _bp ; Pop intno from stack (flags unchanged) - pop _bp ; Restore value of stack frame pointer - pop ds ; Restore value of DS - - pushf ; Save flags for later - pop [UINT flags] - push esi ; Save ESI for later - pop [DWORD sv_esi] - push ds ; Save DS for later - pop [UINT sv_ds] - - _lds _si,[outptr] ; Save CPU registers - mov [_si],eax - mov [_si+4],ebx - mov [_si+8],ecx - mov [_si+12],edx - push [DWORD sv_esi] - pop [DWORD _si+16] - mov [_si+20],edi - - mov _bx,[flags] ; Return flags - and ebx,1h ; Isolate carry flag - mov [_si+24],ebx ; Save carry flag status - - _lds _si,[sregs] ; Save segment registers - mov [_si],es - mov _bx,[sv_ds] - mov [_si+6],bx ; Get returned DS from stack - mov [_si+8],fs - mov [_si+10],gs - - pop gs ; Restore segment registers - pop fs - pop es - pop ds - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_saveDS(void) -;---------------------------------------------------------------------------- -; Save the value of DS into a section of the code segment, so that we can -; quickly load this value at a later date in the PM_loadDS() routine from -; inside interrupt handlers etc. The method to do this is different -; depending on the DOS extender being used. -;---------------------------------------------------------------------------- -cprocstartdll16 PM_saveDS - - mov [_PM_savedDS],ds ; Store away in data segment - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_loadDS(void) -;---------------------------------------------------------------------------- -; Routine to load the DS register with the default value for the current -; DOS extender. Only the DS register is loaded, not the ES register, so -; if you wish to call C code, you will need to also load the ES register -; in 32 bit protected mode. -;---------------------------------------------------------------------------- -cprocstartdll16 PM_loadDS - - mov ds,[cs:_PM_savedDS] ; We can access the proper DS through CS - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_setBankA(int bank) -;---------------------------------------------------------------------------- -cprocstart PM_setBankA - - ARG bank:UINT - - push ebp - mov ebp,esp - push ebx - mov _bx,0 - mov _ax,4F05h - mov _dx,[bank] - int 10h - pop ebx - pop ebp - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_setBankAB(int bank) -;---------------------------------------------------------------------------- -cprocstart PM_setBankAB - - ARG bank:UINT - - push ebp - mov ebp,esp - push ebx - mov _bx,0 - mov _ax,4F05h - mov _dx,[bank] - int 10h - mov _bx,1 - mov _ax,4F05h - mov _dx,[bank] - int 10h - pop ebx - pop ebp - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_setCRTStart(int x,int y,int waitVRT) -;---------------------------------------------------------------------------- -cprocstart PM_setCRTStart - - ARG x:UINT, y:UINT, waitVRT:UINT - - push ebp - mov ebp,esp - push ebx - mov _bx,[waitVRT] - mov _cx,[x] - mov _dx,[y] - mov _ax,4F07h - int 10h - pop ebx - pop ebp - ret - -cprocend - -;---------------------------------------------------------------------------- -; int _PM_inp(int port) -;---------------------------------------------------------------------------- -; Reads a byte from the specified port -;---------------------------------------------------------------------------- -cprocstart _PM_inp - - ARG port:UINT - - push _bp - mov _bp,_sp - xor _ax,_ax - mov _dx,[port] - in al,dx - pop _bp - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _PM_outp(int port,int value) -;---------------------------------------------------------------------------- -; Write a byte to the specified port. -;---------------------------------------------------------------------------- -cprocstart _PM_outp - - ARG port:UINT, value:UINT - - push _bp - mov _bp,_sp - mov _dx,[port] - mov _ax,[value] - out dx,al - pop _bp - ret - -cprocend - -; Macro to delay briefly to ensure that enough time has elapsed between -; successive I/O accesses so that the device being accessed can respond -; to both accesses even on a very fast PC. - -ifdef USE_NASM -%macro DELAY 0 - jmp short $+2 - jmp short $+2 - jmp short $+2 -%endmacro -%macro IODELAYN 1 -%rep %1 - DELAY -%endrep -%endmacro -else -macro DELAY - jmp short $+2 - jmp short $+2 - jmp short $+2 -endm -macro IODELAYN N - rept N - DELAY - endm -endm -endif - -;---------------------------------------------------------------------------- -; uchar _PM_readCMOS(int index) -;---------------------------------------------------------------------------- -; Read the value of a specific CMOS register. We do this with both -; normal interrupts and NMI disabled. -;---------------------------------------------------------------------------- -cprocstart _PM_readCMOS - - ARG index:UINT - - push _bp - mov _bp,_sp - pushfd - mov al,[BYTE index] - or al,80h ; Add disable NMI flag - cli - out 70h,al - IODELAYN 5 - in al,71h - mov ah,al - xor al,al - IODELAYN 5 - out 70h,al ; Re-enable NMI - sti - mov al,ah ; Return value in AL - popfd - pop _bp - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _PM_writeCMOS(int index,uchar value) -;---------------------------------------------------------------------------- -; Read the value of a specific CMOS register. We do this with both -; normal interrupts and NMI disabled. -;---------------------------------------------------------------------------- -cprocstart _PM_writeCMOS - - ARG index:UINT, value:UCHAR - - push _bp - mov _bp,_sp - pushfd - mov al,[BYTE index] - or al,80h ; Add disable NMI flag - cli - out 70h,al - IODELAYN 5 - mov al,[value] - out 71h,al - xor al,al - IODELAYN 5 - out 70h,al ; Re-enable NMI - sti - popfd - pop _bp - ret - -cprocend - -;---------------------------------------------------------------------------- -; _PM_getPDB - Return the Page Table Directory Base address -;---------------------------------------------------------------------------- -cprocstart _PM_getPDB - - mov eax,cr3 - and eax,0FFFFF000h - ret - -cprocend - -;---------------------------------------------------------------------------- -; _PM_flushTLB - Flush the Translation Lookaside buffer -;---------------------------------------------------------------------------- -cprocstart PM_flushTLB - - wbinvd ; Flush the CPU cache - mov eax,cr3 - mov cr3,eax ; Flush the TLB - ret - -cprocend - -endcodeseg _pm - - END ; End of module diff --git a/board/MAI/bios_emulator/scitech/src/pm/smx/_pmsmx.asm b/board/MAI/bios_emulator/scitech/src/pm/smx/_pmsmx.asm deleted file mode 100644 index 8352ce30c1..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/_pmsmx.asm +++ /dev/null @@ -1,933 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: 80386 Assembler, TASM 4.0 or NASM -;* Environment: 32-bit SMX embedded systems development -;* -;* Description: Low level assembly support for the PM library specific to -;* SMX interrupt handling. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -header _pmsmx ; Set up memory model - -; Define the size of our local stacks. For real mode code they cant be -; that big, but for 32 bit protected mode code we can make them nice and -; large so that complex C functions can be used. - -MOUSE_STACK EQU 4096 -TIMER_STACK EQU 4096 -KEY_STACK EQU 1024 -INT10_STACK EQU 1024 - -ifdef USE_NASM - -; Macro to load DS and ES registers with correct value. - -%imacro LOAD_DS 0 - mov ds,[cs:_PM_savedDS] - mov es,[cs:_PM_savedDS] -%endmacro - -; Note that interrupts we disable interrupts during the following stack -; %imacro for correct operation, but we do not enable them again. Normally -; these %imacros are used within interrupt handlers so interrupts should -; already be off. We turn them back on explicitly later if the user code -; needs them to be back on. - -; Macro to switch to a new local stack. - -%imacro NEWSTK 1 - cli - mov [seg_%1],ss - mov [ptr_%1],_sp - mov [TempSeg],ds - mov ss,[TempSeg] - mov _sp,offset %1 -%endmacro - -; %imacro to switch back to the old stack. - -%imacro RESTSTK 1 - cli - mov ss,[seg_%1] - mov _sp,[ptr_%1] -%endmacro - -; %imacro to swap the current stack with the one saved away. - -%imacro SWAPSTK 1 - cli - mov ax,ss - xchg ax,[seg_%1] - mov ss,ax - xchg _sp,[ptr_%1] -%endmacro - -else - -; Macro to load DS and ES registers with correct value. - -MACRO LOAD_DS - mov ds,[cs:_PM_savedDS] - mov es,[cs:_PM_savedDS] -ENDM - -; Note that interrupts we disable interrupts during the following stack -; macro for correct operation, but we do not enable them again. Normally -; these macros are used within interrupt handlers so interrupts should -; already be off. We turn them back on explicitly later if the user code -; needs them to be back on. - -; Macro to switch to a new local stack. - -MACRO NEWSTK stkname - cli - mov [seg_&stkname&],ss - mov [ptr_&stkname&],_sp - mov [TempSeg],ds - mov ss,[TempSeg] - mov _sp,offset stkname -ENDM - -; Macro to switch back to the old stack. - -MACRO RESTSTK stkname - cli - mov ss,[seg_&stkname&] - mov _sp,[ptr_&stkname&] -ENDM - -; Macro to swap the current stack with the one saved away. - -MACRO SWAPSTK stkname - cli - mov ax,ss - xchg ax,[seg_&stkname&] - mov ss,ax - xchg _sp,[ptr_&stkname&] -ENDM - -endif - -begdataseg _pmsmx - - cextern _PM_savedDS,USHORT - cextern _PM_critHandler,CPTR - cextern _PM_breakHandler,CPTR - cextern _PM_timerHandler,CPTR - cextern _PM_rtcHandler,CPTR - cextern _PM_keyHandler,CPTR - cextern _PM_key15Handler,CPTR - cextern _PM_mouseHandler,CPTR - cextern _PM_int10Handler,CPTR - - cextern _PM_ctrlCPtr,DPTR - cextern _PM_ctrlBPtr,DPTR - cextern _PM_critPtr,DPTR - - cextern _PM_prevTimer,FCPTR - cextern _PM_prevRTC,FCPTR - cextern _PM_prevKey,FCPTR - cextern _PM_prevKey15,FCPTR - cextern _PM_prevBreak,FCPTR - cextern _PM_prevCtrlC,FCPTR - cextern _PM_prevCritical,FCPTR - cextern _PM_prevRealTimer,ULONG - cextern _PM_prevRealRTC,ULONG - cextern _PM_prevRealKey,ULONG - cextern _PM_prevRealKey15,ULONG - cextern _PM_prevRealInt10,ULONG - -cpublic _PM_pmsmxDataStart - -; Allocate space for all of the local stacks that we need. These stacks -; are not very large, but should be large enough for most purposes -; (generally you want to handle these interrupts quickly, simply storing -; the information for later and then returning). If you need bigger -; stacks then change the appropriate value in here. - - ALIGN 4 - dclb MOUSE_STACK ; Space for local stack (small) -MsStack: ; Stack starts at end! -ptr_MsStack DUINT 0 ; Place to store old stack offset -seg_MsStack dw 0 ; Place to store old stack segment - - ALIGN 4 - dclb INT10_STACK ; Space for local stack (small) -Int10Stack: ; Stack starts at end! -ptr_Int10Stack DUINT 0 ; Place to store old stack offset -seg_Int10Stack dw 0 ; Place to store old stack segment - - ALIGN 4 - dclb TIMER_STACK ; Space for local stack (small) -TmStack: ; Stack starts at end! -ptr_TmStack DUINT 0 ; Place to store old stack offset -seg_TmStack dw 0 ; Place to store old stack segment - - ALIGN 4 - dclb TIMER_STACK ; Space for local stack (small) -RtcStack: ; Stack starts at end! -ptr_RtcStack DUINT 0 ; Place to store old stack offset -seg_RtcStack dw 0 ; Place to store old stack segment -RtcInside dw 0 ; Are we still handling current interrupt - - ALIGN 4 - dclb KEY_STACK ; Space for local stack (small) -KyStack: ; Stack starts at end! -ptr_KyStack DUINT 0 ; Place to store old stack offset -seg_KyStack dw 0 ; Place to store old stack segment -KyInside dw 0 ; Are we still handling current interrupt - - ALIGN 4 - dclb KEY_STACK ; Space for local stack (small) -Ky15Stack: ; Stack starts at end! -ptr_Ky15Stack DUINT 0 ; Place to store old stack offset -seg_Ky15Stack dw 0 ; Place to store old stack segment - -TempSeg dw 0 ; Place to store stack segment - -cpublic _PM_pmsmxDataEnd - -enddataseg _pmsmx - -begcodeseg _pmsmx ; Start of code segment - -cpublic _PM_pmsmxCodeStart - -;---------------------------------------------------------------------------- -; PM_mouseISR - Mouse interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; Interrupt subroutine called by the mouse driver upon interrupts, to -; dispatch control to high level C based subroutines. Interrupts are on -; when we call the user code. -; -; It is _extremely_ important to save the state of the extended registers -; as these may well be trashed by the routines called from here and not -; restored correctly by the mouse interface module. -; -; NOTE: This routine switches to a local stack before calling any C code, -; and hence is _not_ re-entrant. For mouse handlers this is not a -; problem, as the mouse driver arbitrates calls to the user mouse -; handler for us. -; -; Entry: AX - Condition mask giving reason for call -; BX - Mouse button state -; CX - Horizontal cursor coordinate -; DX - Vertical cursor coordinate -; SI - Horizontal mickey value -; DI - Vertical mickey value -; -;---------------------------------------------------------------------------- -cprocfar _PM_mouseISR - - push ds ; Save value of DS - push es - pushad ; Save _all_ extended registers - cld ; Clear direction flag - - LOAD_DS ; Load DS register - NEWSTK MsStack ; Switch to local stack - -; Call the installed high level C code routine - - clrhi dx ; Clear out high order values - clrhi cx - clrhi bx - clrhi ax - sgnhi si - sgnhi di - - push _di - push _si - push _dx - push _cx - push _bx - push _ax - sti ; Enable interrupts - call [CPTR _PM_mouseHandler] - _add sp,12,24 - - RESTSTK MsStack ; Restore previous stack - - popad ; Restore all extended registers - pop es - pop ds - ret ; We are done!! - -cprocend - -;---------------------------------------------------------------------------- -; PM_timerISR - Timer interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; Hardware interrupt handler for the timer interrupt, to dispatch control -; to high level C based subroutines. We save the state of all registers -; in this routine, and switch to a local stack. Interrupts are *off* -; when we call the user code. -; -; NOTE: This routine switches to a local stack before calling any C code, -; and hence is _not_ re-entrant. Make sure your C code executes as -; quickly as possible, since a timer overrun will simply hang the -; system. -;---------------------------------------------------------------------------- -cprocfar _PM_timerISR - - push ds ; Save value of DS - push es - pushad ; Save _all_ extended registers - cld ; Clear direction flag - - LOAD_DS ; Load DS register - - NEWSTK TmStack ; Switch to local stack - call [CPTR _PM_timerHandler] - RESTSTK TmStack ; Restore previous stack - - popad ; Restore all extended registers - pop es - pop ds - iret ; Return from interrupt - -cprocend - -;---------------------------------------------------------------------------- -; PM_chainPrevTimer - Chain to previous timer interrupt and return -;---------------------------------------------------------------------------- -; Chains to the previous timer interrupt routine and returns control -; back to the high level interrupt handler. -;---------------------------------------------------------------------------- -cprocstart PM_chainPrevTimer - -ifdef TNT - push eax - push ebx - push ecx - pushfd ; Push flags on stack to simulate interrupt - mov ax,250Eh ; Call real mode procedure function - mov ebx,[_PM_prevRealTimer] - mov ecx,1 ; Copy real mode flags to real mode stack - int 21h ; Call the real mode code - popfd - pop ecx - pop ebx - pop eax - ret -else - SWAPSTK TmStack ; Swap back to previous stack - pushf ; Save state of interrupt flag - pushf ; Push flags on stack to simulate interrupt -ifdef USE_NASM - call far dword [_PM_prevTimer] -else - call [_PM_prevTimer] -endif - popf ; Restore state of interrupt flag - SWAPSTK TmStack ; Swap back to C stack again - ret -endif - -cprocend - -; Macro to delay briefly to ensure that enough time has elapsed between -; successive I/O accesses so that the device being accessed can respond -; to both accesses even on a very fast PC. - -ifdef USE_NASM -%macro DELAY 0 - jmp short $+2 - jmp short $+2 - jmp short $+2 -%endmacro -%macro IODELAYN 1 -%rep %1 - DELAY -%endrep -%endmacro -else -macro DELAY - jmp short $+2 - jmp short $+2 - jmp short $+2 -endm -macro IODELAYN N - rept N - DELAY - endm -endm -endif - -;---------------------------------------------------------------------------- -; PM_rtcISR - Real time clock interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; Hardware interrupt handler for the timer interrupt, to dispatch control -; to high level C based subroutines. We save the state of all registers -; in this routine, and switch to a local stack. Interrupts are *off* -; when we call the user code. -; -; NOTE: This routine switches to a local stack before calling any C code, -; and hence is _not_ re-entrant. Make sure your C code executes as -; quickly as possible, since a timer overrun will simply hang the -; system. -;---------------------------------------------------------------------------- -cprocfar _PM_rtcISR - - push ds ; Save value of DS - push es - pushad ; Save _all_ extended registers - cld ; Clear direction flag - -; Clear priority interrupt controller and re-enable interrupts so we -; dont lock things up for long. - - mov al,20h - out 0A0h,al - out 020h,al - -; Clear real-time clock timeout - - in al,70h ; Read CMOS index register - push _ax ; and save for later - IODELAYN 3 - mov al,0Ch - out 70h,al - IODELAYN 5 - in al,71h - -; Call the C interrupt handler function - - LOAD_DS ; Load DS register - cmp [BYTE RtcInside],1 ; Check for mutual exclusion - je @@Exit - mov [BYTE RtcInside],1 - sti ; Re-enable interrupts - NEWSTK RtcStack ; Switch to local stack - call [CPTR _PM_rtcHandler] - RESTSTK RtcStack ; Restore previous stack - mov [BYTE RtcInside],0 - -@@Exit: pop _ax - out 70h,al ; Restore CMOS index register - popad ; Restore all extended registers - pop es - pop ds - iret ; Return from interrupt - -cprocend - -;---------------------------------------------------------------------------- -; PM_keyISR - keyboard interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; Hardware interrupt handler for the keyboard interrupt, to dispatch control -; to high level C based subroutines. We save the state of all registers -; in this routine, and switch to a local stack. Interrupts are *off* -; when we call the user code. -; -; NOTE: This routine switches to a local stack before calling any C code, -; and hence is _not_ re-entrant. However we ensure within this routine -; mutual exclusion to the keyboard handling routine. -;---------------------------------------------------------------------------- -cprocfar _PM_keyISR - - push ds ; Save value of DS - push es - pushad ; Save _all_ extended registers - cld ; Clear direction flag - - LOAD_DS ; Load DS register - - cmp [BYTE KyInside],1 ; Check for mutual exclusion - je @@Reissued - - mov [BYTE KyInside],1 - NEWSTK KyStack ; Switch to local stack - call [CPTR _PM_keyHandler] ; Call C code - RESTSTK KyStack ; Restore previous stack - mov [BYTE KyInside],0 - -@@Exit: popad ; Restore all extended registers - pop es - pop ds - iret ; Return from interrupt - -; When the BIOS keyboard handler needs to change the SHIFT status lights -; on the keyboard, in the process of doing this the keyboard controller -; re-issues another interrupt, while the current handler is still executing. -; If we recieve another interrupt while still handling the current one, -; then simply chain directly to the previous handler. -; -; Note that for most DOS extenders, the real mode interrupt handler that we -; install takes care of this for us. - -@@Reissued: -ifdef TNT - push eax - push ebx - push ecx - pushfd ; Push flags on stack to simulate interrupt - mov ax,250Eh ; Call real mode procedure function - mov ebx,[_PM_prevRealKey] - mov ecx,1 ; Copy real mode flags to real mode stack - int 21h ; Call the real mode code - popfd - pop ecx - pop ebx - pop eax -else - pushf -ifdef USE_NASM - call far dword [_PM_prevKey] -else - call [_PM_prevKey] -endif -endif - jmp @@Exit - -cprocend - -;---------------------------------------------------------------------------- -; PM_chainPrevkey - Chain to previous key interrupt and return -;---------------------------------------------------------------------------- -; Chains to the previous key interrupt routine and returns control -; back to the high level interrupt handler. -;---------------------------------------------------------------------------- -cprocstart PM_chainPrevKey - -ifdef TNT - push eax - push ebx - push ecx - pushfd ; Push flags on stack to simulate interrupt - mov ax,250Eh ; Call real mode procedure function - mov ebx,[_PM_prevRealKey] - mov ecx,1 ; Copy real mode flags to real mode stack - int 21h ; Call the real mode code - popfd - pop ecx - pop ebx - pop eax - ret -else - -; YIKES! For some strange reason, when execution returns from the -; previous keyboard handler, interrupts are re-enabled!! Since we expect -; interrupts to remain off during the duration of our handler, this can -; cause havoc. However our stack macros always turn off interrupts, so they -; will be off when we exit this routine. Obviously there is a tiny weeny -; window when interrupts will be enabled, but there is nothing we can -; do about this. - - SWAPSTK KyStack ; Swap back to previous stack - pushf ; Push flags on stack to simulate interrupt -ifdef USE_NASM - call far dword [_PM_prevKey] -else - call [_PM_prevKey] -endif - SWAPSTK KyStack ; Swap back to C stack again - ret -endif - -cprocend - -;---------------------------------------------------------------------------- -; PM_key15ISR - Int 15h keyboard interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; This routine gets called if we have been called to handle the Int 15h -; keyboard interrupt callout from real mode. -; -; Entry: AX - Hardware scan code to process -; Exit: AX - Hardware scan code to process (0 to ignore) -;---------------------------------------------------------------------------- -cprocfar _PM_key15ISR - - push ds - push es - LOAD_DS - cmp ah,4Fh - jnz @@NotOurs ; Quit if not keyboard callout - - pushad - cld ; Clear direction flag - xor ah,ah ; AX := scan code - NEWSTK Ky15Stack ; Switch to local stack - push _ax - call [CPTR _PM_key15Handler] ; Call C code - _add sp,2,4 - RESTSTK Ky15Stack ; Restore previous stack - test ax,ax - jz @@1 - stc ; Set carry to process as normal - jmp @@2 -@@1: clc ; Clear carry to ignore scan code -@@2: popad - jmp @@Exit ; We are done - -@@NotOurs: -ifdef TNT - push eax - push ebx - push ecx - pushfd ; Push flags on stack to simulate interrupt - mov ax,250Eh ; Call real mode procedure function - mov ebx,[_PM_prevRealKey15] - mov ecx,1 ; Copy real mode flags to real mode stack - int 21h ; Call the real mode code - popfd - pop ecx - pop ebx - pop eax -else - pushf -ifdef USE_NASM - call far dword [_PM_prevKey15] -else - call [_PM_prevKey15] -endif -endif -@@Exit: pop es - pop ds - retf 4 - -cprocend - -;---------------------------------------------------------------------------- -; PM_breakISR - Control Break interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; Hardware interrupt handler for the Ctrl-Break interrupt. We simply set -; the Ctrl-Break flag to a 1 and leave (note that this is accessed through -; a far pointer, as it may well be located in conventional memory). -;---------------------------------------------------------------------------- -cprocfar _PM_breakISR - - sti - push ds ; Save value of DS - push es - push _bx - - LOAD_DS ; Load DS register - mov ebx,[_PM_ctrlBPtr] - mov [UINT _ES _bx],1 - -; Run alternate break handler code if installed - - cmp [CPTR _PM_breakHandler],0 - je @@Exit - - pushad - mov _ax,1 - push _ax - call [CPTR _PM_breakHandler] ; Call C code - pop _ax - popad - -@@Exit: pop _bx - pop es - pop ds - iret ; Return from interrupt - -cprocend - -;---------------------------------------------------------------------------- -; int PM_ctrlBreakHit(int clearFlag) -;---------------------------------------------------------------------------- -; Returns the current state of the Ctrl-Break flag and possibly clears it. -;---------------------------------------------------------------------------- -cprocstart PM_ctrlBreakHit - - ARG clearFlag:UINT - - enter_c - pushf ; Save interrupt status - push es - mov ebx,[_PM_ctrlBPtr] - cli ; No interrupts thanks! - mov _ax,[_ES _bx] - test [BYTE clearFlag],1 - jz @@Done - mov [UINT _ES _bx],0 - -@@Done: pop es - popf ; Restore interrupt status - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; PM_ctrlCISR - Control Break interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; Hardware interrupt handler for the Ctrl-C interrupt. We simply set -; the Ctrl-C flag to a 1 and leave (note that this is accessed through -; a far pointer, as it may well be located in conventional memory). -;---------------------------------------------------------------------------- -cprocfar _PM_ctrlCISR - - sti - push ds ; Save value of DS - push es - push _bx - - LOAD_DS ; Load DS register - mov ebx,[_PM_ctrlCPtr] - mov [UINT _ES _bx],1 - -; Run alternate break handler code if installed - - cmp [CPTR _PM_breakHandler],0 - je @@Exit - - pushad - mov _ax,0 - push _ax - call [CPTR _PM_breakHandler] ; Call C code - pop _ax - popad - -@@Exit: pop _bx - pop es - pop ds - iret ; Return from interrupt - iretd - -cprocend - -;---------------------------------------------------------------------------- -; int PM_ctrlCHit(int clearFlag) -;---------------------------------------------------------------------------- -; Returns the current state of the Ctrl-C flag and possibly clears it. -;---------------------------------------------------------------------------- -cprocstart PM_ctrlCHit - - ARG clearFlag:UINT - - enter_c - pushf ; Save interrupt status - push es - mov ebx,[_PM_ctrlCPtr] - cli ; No interrupts thanks! - mov _ax,[_ES _bx] - test [BYTE clearFlag],1 - jz @@Done - mov [UINT _ES _bx],0 - -@@Done: - pop es - popf ; Restore interrupt status - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; PM_criticalISR - Control Error handler interrupt subroutine dispatcher -;---------------------------------------------------------------------------- -; Interrupt handler for the MSDOS Critical Error interrupt, to dispatch -; control to high level C based subroutines. We save the state of all -; registers in this routine, and switch to a local stack. We also pass -; the values of the AX and DI registers to the as pointers, so that the -; values can be modified before returning to MSDOS. -;---------------------------------------------------------------------------- -cprocfar _PM_criticalISR - - sti - push ds ; Save value of DS - push es - push _bx ; Save register values changed - cld ; Clear direction flag - - LOAD_DS ; Load DS register - mov ebx,[_PM_critPtr] - mov [_ES _bx],ax - mov [_ES _bx+2],di - -; Run alternate critical handler code if installed - - cmp [CPTR _PM_critHandler],0 - je @@NoAltHandler - - pushad - push _di - push _ax - call [CPTR _PM_critHandler] ; Call C code - _add sp,4,8 - popad - - pop _bx - pop es - pop ds - iret ; Return from interrupt - -@@NoAltHandler: - mov ax,3 ; Tell MSDOS to fail the operation - pop _bx - pop es - pop ds - iret ; Return from interrupt - -cprocend - -;---------------------------------------------------------------------------- -; int PM_criticalError(int *axVal,int *diVal,int clearFlag) -;---------------------------------------------------------------------------- -; Returns the current state of the critical error flags, and the values that -; MSDOS passed in the AX and DI registers to our handler. -;---------------------------------------------------------------------------- -cprocstart PM_criticalError - - ARG axVal:DPTR, diVal:DPTR, clearFlag:UINT - - enter_c - pushf ; Save interrupt status - push es - mov ebx,[_PM_critPtr] - cli ; No interrupts thanks! - xor _ax,_ax - xor _di,_di - mov ax,[_ES _bx] - mov di,[_ES _bx+2] - test [BYTE clearFlag],1 - jz @@NoClear - mov [ULONG _ES _bx],0 -@@NoClear: - _les _bx,[axVal] - mov [_ES _bx],_ax - _les _bx,[diVal] - mov [_ES _bx],_di - pop es - popf ; Restore interrupt status - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_setMouseHandler(int mask, PM_mouseHandler mh) -;---------------------------------------------------------------------------- -cprocstart _PM_setMouseHandler - - ARG mouseMask:UINT - - enter_c - push es - - mov ax,0Ch ; AX := Function 12 - install interrupt sub - mov _cx,[mouseMask] ; CX := mouse mask - mov _dx,offset _PM_mouseISR - push cs - pop es ; ES:_DX -> mouse handler - int 33h ; Call mouse driver - - pop es - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_mousePMCB(void) -;---------------------------------------------------------------------------- -; Mouse realmode callback routine. Upon entry to this routine, we recieve -; the following from the DPMI server: -; -; Entry: DS:_SI -> Real mode stack at time of call -; ES:_DI -> Real mode register data structure -; SS:_SP -> Locked protected mode stack to use -;---------------------------------------------------------------------------- -cprocfar _PM_mousePMCB - - pushad - mov eax,[es:_di+1Ch] ; Load register values from real mode - mov ebx,[es:_di+10h] - mov ecx,[es:_di+18h] - mov edx,[es:_di+14h] - mov esi,[es:_di+04h] - mov edi,[es:_di] - call _PM_mouseISR ; Call the mouse handler - popad - - mov ax,[ds:_si] - mov [es:_di+2Ah],ax ; Plug in return IP address - mov ax,[ds:_si+2] - mov [es:_di+2Ch],ax ; Plug in return CS value - add [WORD es:_di+2Eh],4 ; Remove return address from stack - iret ; Go back to real mode! - -cprocend - -;---------------------------------------------------------------------------- -; void PM_int10PMCB(void) -;---------------------------------------------------------------------------- -; int10 realmode callback routine. Upon entry to this routine, we recieve -; the following from the DPMI server: -; -; Entry: DS:ESI -> Real mode stack at time of call -; ES:EDI -> Real mode register data structure -; SS:ESP -> Locked protected mode stack to use -;---------------------------------------------------------------------------- -cprocfar _PM_int10PMCB - - pushad - push ds - push es - push fs - - pushfd - pop eax - mov [es:edi+20h],ax ; Save return flag status - mov ax,[ds:esi] - mov [es:edi+2Ah],ax ; Plug in return IP address - mov ax,[ds:esi+2] - mov [es:edi+2Ch],ax ; Plug in return CS value - add [WORD es:edi+2Eh],4 ; Remove return address from stack - -; Call the install int10 handler in protected mode. This function gets called -; with DS set to the current data selector, and ES:EDI pointing the the -; real mode DPMI register structure at the time of the interrupt. The -; handle must be written in assembler to be able to extract the real mode -; register values from the structure - - push es - pop fs ; FS:EDI -> real mode registers - LOAD_DS - NEWSTK Int10Stack ; Switch to local stack - - call [_PM_int10Handler] - - RESTSTK Int10Stack ; Restore previous stack - pop fs - pop es - pop ds - popad - iret ; Go back to real mode! - -cprocend - -cpublic _PM_pmsmxCodeEnd - -endcodeseg _pmsmx - - END ; End of module diff --git a/board/MAI/bios_emulator/scitech/src/pm/smx/_vflat.asm b/board/MAI/bios_emulator/scitech/src/pm/smx/_vflat.asm deleted file mode 100644 index 34985a9d8b..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/_vflat.asm +++ /dev/null @@ -1,652 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Based on original code Copyright 1994 Otto Chrons -;* -;* Language: 80386 Assembler, TASM 4.0 or later -;* Environment: IBM PC 32 bit protected mode -;* -;* Description: Low level page fault handler for virtual linear framebuffers. -;* -;**************************************************************************** - - IDEAL - JUMPS - -include "scitech.mac" ; Memory model macros - -header _vflat ; Set up memory model - -VFLAT_START EQU 0F0000000h -VFLAT_END EQU 0F03FFFFFh -PAGE_PRESENT EQU 1 -PAGE_NOTPRESENT EQU 0 -PAGE_READ EQU 0 -PAGE_WRITE EQU 2 - -ifdef DOS4GW - -;---------------------------------------------------------------------------- -; DOS4G/W flat linear framebuffer emulation. -;---------------------------------------------------------------------------- - -begdataseg _vflat - -; Near pointers to the page directory base and our page tables. All of -; this memory is always located in the first Mb of DOS memory. - -PDBR dd 0 ; Page directory base register (CR3) -accessPageAddr dd 0 -accessPageTable dd 0 - -; CauseWay page directory & 1st page table linear addresses. - -CauseWayDIRLinear dd 0 -CauseWay1stLinear dd 0 - -; Place to store a copy of the original Page Table Directory before we -; intialised our virtual buffer code. - -pageDirectory: resd 1024 ; Saved page table directory - -ValidCS dw 0 ; Valid CS for page faults -Ring0CS dw 0 ; Our ring 0 code selector -LastPage dd 0 ; Last page we mapped in -BankFuncBuf: resb 101 ; Place to store bank switch code -BankFuncPtr dd offset BankFuncBuf - -INT14Gate: -INT14Offset dd 0 ; eip of original vector -INT14Selector dw 0 ; cs of original vector - - cextern _PM_savedDS,USHORT - cextern VF_haveCauseWay,BOOL - -enddataseg _vflat - -begcodeseg _vflat ; Start of code segment - - cextern VF_malloc,FPTR - -;---------------------------------------------------------------------------- -; PF_handler64k - Page fault handler for 64k banks -;---------------------------------------------------------------------------- -; The handler below is a 32 bit ring 0 page fault handler. It receives -; control immediately after any page fault or after an IRQ6 (hardware -; interrupt). This provides the fastest possible handling of page faults -; since it jump directly here. If this is a page fault, the number -; immediately on the stack will be an error code, at offset 4 will be -; the eip of the faulting instruction, at offset 8 will be the cs of the -; faulting instruction. If it is a hardware interrupt, it will not have -; the error code and the eflags will be at offset 8. -;---------------------------------------------------------------------------- -cprocfar PF_handler64k - -; Check if this is a processor exeception or a page fault - - push eax - mov ax,[cs:ValidCS] ; Use CS override to access data - cmp [ss:esp+12],ax ; Is this a page fault? - jne @@ToOldHandler ; Nope, jump to the previous handler - -; Get address of page fault and check if within our handlers range - - mov eax,cr2 ; EBX has page fault linear address - cmp eax,VFLAT_START ; Is the fault less than ours? - jb @@ToOldHandler ; Yep, go to previous handler - cmp eax,VFLAT_END ; Is the fault more than ours? - jae @@ToOldHandler ; Yep, go to previous handler - -; This is our page fault, so we need to handle it - - pushad - push ds - push es - mov ebx,eax ; EBX := page fault address - and ebx,invert 0FFFFh ; Mask to 64k bank boundary - mov ds,[cs:_PM_savedDS]; Load segment registers - mov es,[cs:_PM_savedDS] - -; Map in the page table for our virtual framebuffer area for modification - - mov edi,[PDBR] ; EDI points to page directory - mov edx,ebx ; EDX = linear address - shr edx,22 ; EDX = offset to page directory - mov edx,[edx*4+edi] ; EDX = physical page table address - mov eax,edx - mov edx,[accessPageTable] - or eax,7 - mov [edx],eax - mov eax,cr3 - mov cr3,eax ; Update page table cache - -; Mark all pages valid for the new page fault area - - mov esi,ebx ; ESI := linear address for page - shr esi,10 - and esi,0FFFh ; Offset into page table - add esi,[accessPageAddr] -ifdef USE_NASM -%assign off 0 -%rep 16 - or [DWORD esi+off],0000000001h ; Enable pages -%assign off off+4 -%endrep -else -off = 0 -REPT 16 - or [DWORD esi+off],0000000001h ; Enable pages -off = off+4 -ENDM -endif - -; Mark all pages invalid for the previously mapped area - - xchg esi,[LastPage] ; Save last page for next page fault - test esi,esi - jz @@DoneMapping ; Dont update if first time round -ifdef USE_NASM -%assign off 0 -%rep 16 - or [DWORD esi+off],0FFFFFFFEh ; Disable pages -%assign off off+4 -%endrep -else -off = 0 -REPT 16 - and [DWORD esi+off],0FFFFFFFEh ; Disable pages -off = off+4 -ENDM -endif - -@@DoneMapping: - mov eax,cr3 - mov cr3,eax ; Flush the TLB - -; Now program the new SuperVGA starting bank address - - mov eax,ebx ; EAX := page fault address - shr eax,16 - and eax,0FFh ; Mask to 0-255 - call [BankFuncPtr] ; Call the bank switch function - - pop es - pop ds - popad - pop eax - add esp,4 ; Pop the error code from stack - iretd ; Return to faulting instruction - -@@ToOldHandler: - pop eax -ifdef USE_NASM - jmp far dword [cs:INT14Gate]; Chain to previous handler -else - jmp [FWORD cs:INT14Gate]; Chain to previous handler -endif - -cprocend - -;---------------------------------------------------------------------------- -; PF_handler4k - Page fault handler for 4k banks -;---------------------------------------------------------------------------- -; The handler below is a 32 bit ring 0 page fault handler. It receives -; control immediately after any page fault or after an IRQ6 (hardware -; interrupt). This provides the fastest possible handling of page faults -; since it jump directly here. If this is a page fault, the number -; immediately on the stack will be an error code, at offset 4 will be -; the eip of the faulting instruction, at offset 8 will be the cs of the -; faulting instruction. If it is a hardware interrupt, it will not have -; the error code and the eflags will be at offset 8. -;---------------------------------------------------------------------------- -cprocfar PF_handler4k - -; Fill in when we have tested all the 64Kb code - -ifdef USE_NASM - jmp far dword [cs:INT14Gate]; Chain to previous handler -else - jmp [FWORD cs:INT14Gate]; Chain to previous handler -endif - -cprocend - -;---------------------------------------------------------------------------- -; void InstallFaultHandler(void *baseAddr,int bankSize) -;---------------------------------------------------------------------------- -; Installes the page fault handler directly int the interrupt descriptor -; table for maximum performance. This of course requires ring 0 access, -; but none of this stuff will run without ring 0! -;---------------------------------------------------------------------------- -cprocstart InstallFaultHandler - - ARG baseAddr:ULONG, bankSize:UINT - - enter_c - - mov [DWORD LastPage],0 ; No pages have been mapped - mov ax,cs - mov [ValidCS],ax ; Save CS value for page faults - -; Put address of our page fault handler into the IDT directly - - sub esp,6 ; Allocate space on stack -ifdef USE_NASM - sidt [ss:esp] ; Store pointer to IDT -else - sidt [FWORD ss:esp] ; Store pointer to IDT -endif - pop ax ; add esp,2 - pop eax ; Absolute address of IDT - add eax,14*8 ; Point to Int #14 - -; Note that Interrupt gates do not have the high and low word of the -; offset in adjacent words in memory, there are 4 bytes separating them. - - mov ecx,[eax] ; Get cs and low 16 bits of offset - mov edx,[eax+6] ; Get high 16 bits of offset in dx - shl edx,16 - mov dx,cx ; edx has offset - mov [INT14Offset],edx ; Save offset - shr ecx,16 - mov [INT14Selector],cx ; Save original cs - mov [eax+2],cs ; Install new cs - mov edx,offset PF_handler64k - cmp [UINT bankSize],4 - jne @@1 - mov edx,offset PF_handler4k -@@1: mov [eax],dx ; Install low word of offset - shr edx,16 - mov [eax+6],dx ; Install high word of offset - - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; void RemoveFaultHandler(void) -;---------------------------------------------------------------------------- -; Closes down the virtual framebuffer services and restores the previous -; page fault handler. -;---------------------------------------------------------------------------- -cprocstart RemoveFaultHandler - - enter_c - -; Remove page fault handler from IDT - - sub esp,6 ; Allocate space on stack -ifdef USE_NASM - sidt [ss:esp] ; Store pointer to IDT -else - sidt [FWORD ss:esp] ; Store pointer to IDT -endif - - pop ax ; add esp,2 - pop eax ; Absolute address of IDT - add eax,14*8 ; Point to Int #14 - mov cx,[INT14Selector] - mov [eax+2],cx ; Restore original CS - mov edx,[INT14Offset] - mov [eax],dx ; Install low word of offset - shr edx,16 - mov [eax+6],dx ; Install high word of offset - - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; void InstallBankFunc(int codeLen,void *bankFunc) -;---------------------------------------------------------------------------- -; Installs the bank switch function by relocating it into our data segment -; and making it into a callable function. We do it this way to make the -; code identical to the way that the VflatD devices work under Windows. -;---------------------------------------------------------------------------- -cprocstart InstallBankFunc - - ARG codeLen:UINT, bankFunc:DPTR - - enter_c - - mov esi,[bankFunc] ; Copy the code into buffer - mov edi,offset BankFuncBuf - mov ecx,[codeLen] - rep movsb - mov [BYTE edi],0C3h ; Terminate the function with a near ret - - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; int InitPaging(void) -;---------------------------------------------------------------------------- -; Initializes paging system. If paging is not enabled, builds a page table -; directory and page tables for physical memory -; -; Exit: 0 - Successful -; -1 - Couldn't initialize paging mechanism -;---------------------------------------------------------------------------- -cprocstart InitPaging - - push ebx - push ecx - push edx - push esi - push edi - -; Are we running under CauseWay? - - mov ax,0FFF9h - int 31h - jc @@NotCauseway - cmp ecx,"CAUS" - jnz @@NotCauseway - cmp edx,"EWAY" - jnz @@NotCauseway - - mov [BOOL VF_haveCauseWay],1 - mov [CauseWayDIRLinear],esi - mov [CauseWay1stLinear],edi - -; Check for DPMI - - mov ax,0ff00h - push es - int 31h - pop es - shr edi,2 - and edi,3 - cmp edi,2 - jz @@ErrExit ; Not supported under DPMI - - mov eax,[CauseWayDIRLinear] - jmp @@CopyCR3 - -@@NotCauseway: - mov ax,cs - test ax,3 ; Which ring are we running - jnz @@ErrExit ; Needs zero ring to access - ; page tables (CR3) - mov eax,cr0 ; Load CR0 - test eax,80000000h ; Is paging enabled? - jz @@ErrExit ; No, we must have paging! - - mov eax,cr3 ; Load directory address - and eax,0FFFFF000h - -@@CopyCR3: - mov [PDBR],eax ; Save it - mov esi,eax - mov edi,offset pageDirectory - mov ecx,1024 - cld - rep movsd ; Copy the original page table directory - cmp [DWORD accessPageAddr],0; Check if we have allocated page - jne @@HaveRealMem ; table already (we cant free it) - - mov eax,0100h ; DPMI DOS allocate - mov ebx,8192/16 - int 31h ; Allocate 8192 bytes - and eax,0FFFFh - shl eax,4 ; EAX points to newly allocated memory - add eax,4095 - and eax,0FFFFF000h ; Page align - mov [accessPageAddr],eax - -@@HaveRealMem: - mov eax,[accessPageAddr] ; EAX -> page table in 1st Mb - shr eax,12 - and eax,3FFh ; Page table offset - shl eax,2 - cmp [BOOL VF_haveCauseWay],0 - jz @@NotCW0 - mov ebx,[CauseWay1stLinear] - jmp @@Put1st - -@@NotCW0: - mov ebx,[PDBR] - mov ebx,[ebx] - and ebx,0FFFFF000h ; Page table for 1st megabyte - -@@Put1st: - add eax,ebx - mov [accessPageTable],eax - sub eax,eax ; No error - jmp @@Exit - -@@ErrExit: - mov eax,-1 - -@@Exit: pop edi - pop esi - pop edx - pop ecx - pop ebx - ret - -cprocend - -;---------------------------------------------------------------------------- -; void ClosePaging(void) -;---------------------------------------------------------------------------- -; Closes the paging system -;---------------------------------------------------------------------------- -cprocstart ClosePaging - - push eax - push ecx - push edx - push esi - push edi - - mov eax,[accessPageAddr] - call AccessPage ; Restore AccessPage mapping - mov edi,[PDBR] - mov esi,offset pageDirectory - mov ecx,1024 - cld - rep movsd ; Restore the original page table directory - -@@Exit: pop edi - pop esi - pop edx - pop ecx - pop eax - ret - -cprocend - -;---------------------------------------------------------------------------- -; long AccessPage(long phys) -;---------------------------------------------------------------------------- -; Maps a known page to given physical memory -; Entry: EAX - Physical memory -; Exit: EAX - Linear memory address of mapped phys mem -;---------------------------------------------------------------------------- -cprocstatic AccessPage - - push edx - mov edx,[accessPageTable] - or eax,7 - mov [edx],eax - mov eax,cr3 - mov cr3,eax ; Update page table cache - mov eax,[accessPageAddr] - pop edx - ret - -cprocend - -;---------------------------------------------------------------------------- -; long GetPhysicalAddress(long linear) -;---------------------------------------------------------------------------- -; Returns the physical address of linear address -; Entry: EAX - Linear address to convert -; Exit: EAX - Physical address -;---------------------------------------------------------------------------- -cprocstatic GetPhysicalAddress - - push ebx - push edx - mov edx,eax - shr edx,22 ; EDX is the directory offset - mov ebx,[PDBR] - mov edx,[edx*4+ebx] ; Load page table address - push eax - mov eax,edx - call AccessPage ; Access the page table - mov edx,eax - pop eax - shr eax,12 - and eax,03FFh ; EAX offset into page table - mov eax,[edx+eax*4] ; Load physical address - and eax,0FFFFF000h - pop edx - pop ebx - ret - -cprocend - -;---------------------------------------------------------------------------- -; void CreatePageTable(long pageDEntry) -;---------------------------------------------------------------------------- -; Creates a page table for specific address (4MB) -; Entry: EAX - Page directory entry (top 10-bits of address) -;---------------------------------------------------------------------------- -cprocstatic CreatePageTable - - push ebx - push ecx - push edx - push edi - mov ebx,eax ; Save address - mov eax,8192 - push eax - call VF_malloc ; Allocate page table directory - add esp,4 - add eax,0FFFh - and eax,0FFFFF000h ; Page align (4KB) - mov edi,eax ; Save page table linear address - sub eax,eax ; Fill with zero - mov ecx,1024 - cld - rep stosd ; Clear page table - sub edi,4096 - mov eax,edi - call GetPhysicalAddress - mov edx,[PDBR] - or eax,7 ; Present/write/user bit - mov [edx+ebx*4],eax ; Save physical address into page directory - mov eax,cr3 - mov cr3,eax ; Update page table cache - pop edi - pop edx - pop ecx - pop ebx - ret - -cprocend - -;---------------------------------------------------------------------------- -; void MapPhysical2Linear(ulong pAddr, ulong lAddr, int pages, int flags); -;---------------------------------------------------------------------------- -; Maps physical memory into linear memory -; Entry: pAddr - Physical address -; lAddr - Linear address -; pages - Number of 4K pages to map -; flags - Page flags -; bit 0 = present -; bit 1 = Read(0)/Write(1) -;---------------------------------------------------------------------------- -cprocstart MapPhysical2Linear - - ARG pAddr:ULONG, lAddr:ULONG, pages:UINT, pflags:UINT - - enter_c - - and [ULONG pAddr],0FFFFF000h; Page boundary - and [ULONG lAddr],0FFFFF000h; Page boundary - mov ecx,[pflags] - and ecx,11b ; Just two bits - or ecx,100b ; Supervisor bit - mov [pflags],ecx - - mov edx,[lAddr] - shr edx,22 ; EDX = Directory - mov esi,[PDBR] - mov edi,[pages] ; EDI page count - mov ebx,[lAddr] - -@@CreateLoop: - mov ecx,[esi+edx*4] ; Load page table address - test ecx,1 ; Is it present? - jnz @@TableOK - mov eax,edx - call CreatePageTable ; Create a page table -@@TableOK: - mov eax,ebx - shr eax,12 - and eax,3FFh - sub eax,1024 - neg eax ; EAX = page count in this table - inc edx ; Next table - mov ebx,0 ; Next time we'll map 1K pages - sub edi,eax ; Subtract mapped pages from page count - jns @@CreateLoop ; Create more tables if necessary - - mov ecx,[pages] ; ECX = Page count - mov esi,[lAddr] - shr esi,12 ; Offset part isn't needed - mov edi,[pAddr] -@@MappingLoop: - mov eax,esi - shr eax,10 ; EAX = offset to page directory - mov ebx,[PDBR] - mov eax,[eax*4+ebx] ; EAX = page table address - call AccessPage - mov ebx,esi - and ebx,3FFh ; EBX = offset to page table - mov edx,edi - add edi,4096 ; Next physical address - inc esi ; Next linear page - or edx,[pflags] ; Update flags... - mov [eax+ebx*4],edx ; Store page table entry - loop @@MappingLoop - mov eax,cr3 - mov cr3,eax ; Update page table cache - - leave_c - ret - -cprocend - -endcodeseg _vflat - -endif - - END ; End of module diff --git a/board/MAI/bios_emulator/scitech/src/pm/smx/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/smx/cpuinfo.c deleted file mode 100644 index 5447e574ec..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/cpuinfo.c +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit SMX embedded systems development. -* -* Description: SMX specific code for the CPU detection module. -* -****************************************************************************/ - -/*----------------------------- Implementation ----------------------------*/ - -/* External timing function */ - -void __ZTimerInit(void); - -/**************************************************************************** -REMARKS: -Do nothing for DOS because we don't have thread priorities. -****************************************************************************/ -#define SetMaxThreadPriority() 0 - -/**************************************************************************** -REMARKS: -Do nothing for DOS because we don't have thread priorities. -****************************************************************************/ -#define RestoreThreadPriority(i) (void)(i) - -/**************************************************************************** -REMARKS: -Initialise the counter and return the frequency of the counter. -****************************************************************************/ -static void GetCounterFrequency( - CPU_largeInteger *freq) -{ - ulong resolution; - - __ZTimerInit(); - ULZTimerResolution(&resolution); - freq->low = (ulong)(10000000000.0 / resolution); - freq->high = 0; -} - -/**************************************************************************** -REMARKS: -Read the counter and return the counter value. -****************************************************************************/ -#define GetCounter(t) \ -{ \ - (t)->low = ULZReadTime() * 10000L; \ - (t)->high = 0; \ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/smx/event.c b/board/MAI/bios_emulator/scitech/src/pm/smx/event.c deleted file mode 100644 index 533c2615b1..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/event.c +++ /dev/null @@ -1,368 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit SMX embedded systems development -* -* Description: 32-bit SMX implementation for the SciTech cross platform -* event library. -* -****************************************************************************/ - -#include "smx/ps2mouse.h" - -/*--------------------------- Global variables ----------------------------*/ - -ibool _VARAPI _EVT_useEvents = true; /* True to use event handling */ -ibool _VARAPI _EVT_installed = 0; /* Event handers installed? */ -uchar _VARAPI *_EVT_biosPtr = NULL; /* Pointer to the BIOS data area */ -static ibool haveMouse = false; /* True if we have a mouse */ - -/*---------------------------- Implementation -----------------------------*/ - -/* External assembler functions */ - -void EVTAPI _EVT_pollJoystick(void); -uint EVTAPI _EVT_disableInt(void); -uint EVTAPI _EVT_restoreInt(uint flags); -void EVTAPI _EVT_codeStart(void); -void EVTAPI _EVT_codeEnd(void); -void EVTAPI _EVT_cCodeStart(void); -void EVTAPI _EVT_cCodeEnd(void); -int EVTAPI _EVT_getKeyCode(void); -int EVTAPI EVT_rdinx(int port,int index); -void EVTAPI EVT_wrinx(int port,int index,int value); - -/**************************************************************************** -REMARKS: -Do nothing for DOS, because we are fully interrupt driven. -****************************************************************************/ -#define _EVT_pumpMessages() - -/**************************************************************************** -REMARKS: -This function is used to return the number of ticks since system -startup in milliseconds. This should be the same value that is placed into -the time stamp fields of events, and is used to implement auto mouse down -events. -****************************************************************************/ -ulong _EVT_getTicks(void) -{ - return (ulong)PM_getLong(_EVT_biosPtr+0x6C) * 55UL; -} - -/**************************************************************************** -REMARKS: -Include generic raw scancode keyboard module. -****************************************************************************/ -#include "common/keyboard.c" - -/**************************************************************************** -REMARKS: -Determines if we have a mouse attached and functioning. -****************************************************************************/ -static ibool detectMouse(void) -{ - return(ps2Query()); -} - -/**************************************************************************** -PARAMETERS: -what - Event code -message - Event message -x,y - Mouse position at time of event -but_stat - Mouse button status at time of event - -REMARKS: -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). -****************************************************************************/ -static void addMouseEvent( - uint what, - uint message, - int x, - int y, - int mickeyX, - int mickeyY, - uint but_stat) -{ - 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 */ - } -} - -/**************************************************************************** -PARAMETERS: -mask - Event mask -butstate - Button state -x - Mouse x coordinate -y - Mouse y coordinate - -REMARKS: -Mouse event handling routine. This gets called when a mouse event occurs, -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. */ -****************************************************************************/ -static void EVTAPI mouseISR( - uint mask, - uint butstate, - int x, - int y, - int mickeyX, - int mickeyY) -{ - RMREGS regs; - 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); - } - if (mask & 0x2A) { - 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); - } - EVT.oldKey = -1; -} - -/**************************************************************************** -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 - in conjunction with smx keyboard handler. -****************************************************************************/ -static void EVTAPI keyboardISR(void) -{ - PM_chainPrevKey(); - processRawScanCode(PM_inpb(0x60)); - PM_outpb(0x20,0x20); -} - -/**************************************************************************** -REMARKS: -Safely abort the event module upon catching a fatal error. -****************************************************************************/ -void _EVT_abort() -{ - EVT_exit(); - PM_fatalError("Unhandled exception!"); -} - -/**************************************************************************** -PARAMETERS: -mouseMove - Callback function to call wheneve the mouse needs to be moved - -REMARKS: -Initiliase the event handling module. Here we install our mouse handling ISR -to be called whenever any button's are pressed or released. We also build -the free list of events in the event queue. - -We use handler number 2 of the mouse libraries interrupt handlers for our -event handling routines. -****************************************************************************/ -void EVTAPI EVT_init( - _EVT_mouseMoveHandler mouseMove) -{ - int i; - - EVT.mouseMove = mouseMove; - _EVT_biosPtr = PM_getBIOSPointer(); - EVT_resume(); -} - -/**************************************************************************** -REMARKS: -Initiailises the internal event handling modules. The EVT_suspend function -can be called to suspend event handling (such as when shelling out to DOS), -and this function can be used to resume it again later. -****************************************************************************/ -void EVTAPI EVT_resume(void) -{ - static int locked = 0; - int stat; - uchar mods; - 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; - } -} - -/**************************************************************************** -REMARKS -Changes the range of coordinates returned by the mouse functions to the -specified range of values. This is used when changing between graphics -modes set the range of mouse coordinates for the new display mode. -****************************************************************************/ -void EVTAPI EVT_setMouseRange( - int xRes, - int yRes) -{ - if (haveMouse) { - ps2MouseStop(); - ps2MouseStart( 0, xRes, 0, yRes, -1, -1, -1); - } -} - -/**************************************************************************** -REMARKS -Modifes the mouse coordinates as necessary if scaling to OS coordinates, -and sets the OS mouse cursor position. -****************************************************************************/ -void _EVT_setMousePos( - int *x, - int *y) -{ - if (haveMouse) - ps2MouseMove(*x, *y); -} - -/**************************************************************************** -REMARKS -Suspends all of our event handling operations. This is also used to -de-install the event handling code. -****************************************************************************/ -void EVTAPI EVT_suspend(void) -{ - uchar mods; - - if (_EVT_installed) { - 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; - } -} - -/**************************************************************************** -REMARKS -Exits the event module for program terminatation. -****************************************************************************/ -void EVTAPI EVT_exit(void) -{ - EVT_suspend(); -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/smx/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/smx/oshdr.h deleted file mode 100644 index 3ff8daa2a9..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/oshdr.h +++ /dev/null @@ -1,29 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit SMX embedded systems development. -* -* Description: Include file to include all OS specific header files. -* -****************************************************************************/ diff --git a/board/MAI/bios_emulator/scitech/src/pm/smx/pm.c b/board/MAI/bios_emulator/scitech/src/pm/smx/pm.c deleted file mode 100644 index 99ee3d4be4..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/pm.c +++ /dev/null @@ -1,1187 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32 bit SMX embedded systems development. -* -* Description: Implementation for the OS Portability Manager Library, which -* contains functions to implement OS specific services in a -* generic, cross platform API. Porting the OS Portability -* Manager library is the first step to porting any SciTech -* products to a new platform. -* -****************************************************************************/ - -#include "pmapi.h" -#include "drvlib/os/os.h" -#include "ztimerc.h" -#include "event.h" -#include "mtrr.h" -#include "pm_help.h" -#include -#include -#include -#include -#include -#ifdef __GNUC__ -#include -#include -#include -#else -#include -#endif -#ifdef __BORLANDC__ -#pragma warn -par -#endif - -/*--------------------------- Global variables ----------------------------*/ - -typedef struct { - int oldMode; - int old50Lines; - } DOS_stateBuf; - -#define MAX_RM_BLOCKS 10 - -static struct { - void *p; - uint tag; - } rmBlocks[MAX_RM_BLOCKS]; - -static uint VESABuf_len = 1024; /* Length of the VESABuf buffer */ -static void *VESABuf_ptr = NULL; /* Near pointer to VESABuf */ -static uint VESABuf_rseg; /* Real mode segment of VESABuf */ -static uint VESABuf_roff; /* Real mode offset of VESABuf */ -static void (PMAPIP fatalErrorCleanup)(void) = NULL; -ushort _VARAPI _PM_savedDS = 0; -static ulong PDB = 0,*pPDB = NULL; -static uint VXD_version = -1; - -/*----------------------------- Implementation ----------------------------*/ - -ulong _ASMAPI _PM_getPDB(void); -void _ASMAPI _PM_VxDCall(VXD_regs *regs,uint off,uint sel); - -/**************************************************************************** -REMARKS: -External function to call the PMHELP helper VxD. -****************************************************************************/ -void PMAPI PM_VxDCall( - VXD_regs *regs) -{ -} - -/**************************************************************************** -RETURNS: -BCD coded version number of the VxD, or 0 if not loaded (ie: 0x202 - 2.2) - -REMARKS: -This function gets the version number for the VxD that we have connected to. -****************************************************************************/ -uint PMAPI PMHELP_getVersion(void) -{ - return VXD_version = 0; -} - -void PMAPI PM_init(void) -{ -#ifndef REALMODE - MTRR_init(); -#endif -} - -/**************************************************************************** -PARAMETERS: -base - The starting physical base address of the region -size - The size in bytes of the region -type - Type to place into the MTRR register - -RETURNS: -Error code describing the result. - -REMARKS: -Function to enable write combining for the specified region of memory. -****************************************************************************/ -int PMAPI PM_enableWriteCombine( - ulong base, - ulong size, - uint type) -{ -#ifndef REALMODE - return MTRR_enableWriteCombine(base,size,type); -#else - return PM_MTRR_NOT_SUPPORTED; -#endif -} - -ibool PMAPI PM_haveBIOSAccess(void) -{ return false; } - -long PMAPI PM_getOSType(void) -{ return _OS_SMX; } - -int PMAPI PM_getModeType(void) -{ return PM_386; } - -void PMAPI PM_backslash(char *s) -{ - uint pos = strlen(s); - if (s[pos-1] != '\\') { - s[pos] = '\\'; - s[pos+1] = '\0'; - } -} - -void PMAPI PM_setFatalErrorCleanup( - void (PMAPIP cleanup)(void)) -{ - fatalErrorCleanup = cleanup; -} - -void MGLOutput(char *); - -void PMAPI PM_fatalError(const char *msg) -{ - if (fatalErrorCleanup) - fatalErrorCleanup(); - MGLOutput(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); - 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); - } - *len = VESABuf_len; - *rseg = VESABuf_rseg; - *roff = VESABuf_roff; - return VESABuf_ptr; -} - -int PMAPI PM_int386(int intno, PMREGS *in, PMREGS *out) -{ - PMSREGS sregs; - PM_segread(&sregs); - return PM_int386x(intno,in,out,&sregs); -} - -/* Routines to set and get the real mode interrupt vectors, by making - * direct real mode calls to DOS and bypassing the DOS extenders API. - * This is the safest way to handle this, as some servers try to be - * smart about changing real mode vectors. - */ - -void PMAPI _PM_getRMvect(int intno, long *realisr) -{ - RMREGS regs; - RMSREGS sregs; - - PM_saveDS(); - regs.h.ah = 0x35; - regs.h.al = intno; - PM_int86x(0x21, ®s, ®s, &sregs); - *realisr = ((long)sregs.es << 16) | regs.x.bx; -} - -void PMAPI _PM_setRMvect(int intno, long realisr) -{ - RMREGS regs; - RMSREGS sregs; - - PM_saveDS(); - regs.h.ah = 0x25; - regs.h.al = intno; - sregs.ds = (int)(realisr >> 16); - regs.x.dx = (int)(realisr & 0xFFFF); - PM_int86x(0x21, ®s, ®s, &sregs); -} - -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; - } - } - PM_fatalError("To many real mode memory block allocations!"); -} - -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; - } - PM_fatalError("Could not find prior real mode memory block allocation!"); - return 0; -} - -char * PMAPI PM_getCurrentPath( - char *path, - int maxLen) -{ - return getcwd(path,maxLen); -} - -char PMAPI PM_getBootDrive(void) -{ return 'C'; } - -const char * PMAPI PM_getVBEAFPath(void) -{ return "c:\\"; } - -const char * PMAPI PM_getNucleusPath(void) -{ - static char path[256]; - char *env; - - if ((env = getenv("NUCLEUS_PATH")) != NULL) - return env; - return "c:\\nucleus"; -} - -const char * PMAPI PM_getNucleusConfigPath(void) -{ - static char path[256]; - strcpy(path,PM_getNucleusPath()); - PM_backslash(path); - strcat(path,"config"); - return path; -} - -const char * PMAPI PM_getUniqueID(void) -{ return "SMX"; } - -const char * PMAPI PM_getMachineName(void) -{ return "SMX"; } - -int PMAPI PM_kbhit(void) -{ - int hit; - event_t evt; - - hit = EVT_peekNext(&evt,EVT_KEYDOWN | EVT_KEYREPEAT); - EVT_flush(~(EVT_KEYDOWN | EVT_KEYREPEAT)); - return hit; -} - -int PMAPI PM_getch(void) -{ - event_t evt; - - EVT_halt(&evt,EVT_KEYDOWN); - return EVT_asciiCode(evt.message); -} - -PM_HWND PMAPI PM_openConsole(PM_HWND hwndUser,int device,int xRes,int yRes,int bpp,ibool fullScreen) -{ - /* Not used for SMX */ - (void)hwndUser; - (void)device; - (void)xRes; - (void)yRes; - (void)bpp; - (void)fullScreen; - return 0; -} - -int PMAPI PM_getConsoleStateSize(void) -{ - return sizeof(DOS_stateBuf); -} - -void PMAPI PM_saveConsoleState(void *stateBuf,PM_HWND hwndConsole) -{ - RMREGS regs; - DOS_stateBuf *sb = stateBuf; - - /* Save the old video mode state */ - regs.h.ah = 0x0F; - PM_int86(0x10,®s,®s); - 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); - } - (void)hwndConsole; -} - -void PMAPI PM_setSuspendAppCallback(int (_ASMAPIP saveState)(int flags)) -{ - /* Not used for SMX */ - (void)saveState; -} - -void PMAPI PM_restoreConsoleState(const void *stateBuf,PM_HWND hwndConsole) -{ - RMREGS regs; - const DOS_stateBuf *sb = stateBuf; - - /* Retore 50 line mode if set */ - if (sb->old50Lines) { - regs.x.ax = 0x1112; - regs.x.bx = 0; - PM_int86(0x10,®s,®s); - } - (void)hwndConsole; -} - -void PMAPI PM_closeConsole(PM_HWND hwndConsole) -{ - /* Not used for SMX */ - (void)hwndConsole; -} - -void PMAPI PM_setOSCursorLocation(int x,int y) -{ - uchar *_biosPtr = PM_getBIOSPointer(); - PM_setByte(_biosPtr+0x50,x); - PM_setByte(_biosPtr+0x51,y); -} - -void PMAPI PM_setOSScreenWidth(int width,int height) -{ - uchar *_biosPtr = PM_getBIOSPointer(); - PM_setWord(_biosPtr+0x4A,width); - 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); - } - else { - PM_setWord(_biosPtr+0x60,0x0D0E); - PM_setByte(_biosPtr+0x85,0x016); - } -} - -void * PMAPI PM_mallocShared(long size) -{ - return PM_malloc(size); -} - -void PMAPI PM_freeShared(void *ptr) -{ - PM_free(ptr); -} - -#define GetRMVect(intno,isr) *(isr) = ((ulong*)rmZeroPtr)[intno] -#define SetRMVect(intno,isr) ((ulong*)rmZeroPtr)[intno] = (isr) - -ibool PMAPI PM_doBIOSPOST( - ushort axVal, - ulong BIOSPhysAddr, - void *mappedBIOS, - ulong BIOSLen) -{ - static int firstTime = true; - static uchar *rmZeroPtr; - long Current10,Current6D,Current42; - RMREGS regs; - RMSREGS sregs; - - /* Create a zero memory mapping for us to use */ - if (firstTime) { - 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; - } - - /* Save current handlers of int 10h and 6Dh */ - GetRMVect(0x10,&Current10); - GetRMVect(0x6D,&Current6D); - - /* POST the secondary BIOS */ - GetRMVect(0x42,&Current42); - SetRMVect(0x10,Current42); /* Restore int 10h to STD-BIOS */ - regs.x.ax = axVal; - PM_callRealMode(0xC000,0x0003,®s,&sregs); - - /* Restore current handlers */ - SetRMVect(0x10,Current10); - SetRMVect(0x6D,Current6D); - - /* Second the primary BIOS mappin 1:1 for 0xC0000 physical */ - if (BIOSPhysAddr != 0xC0000L) { - /* SMX does not support this */ - (void)mappedBIOS; - } - return true; -} - -void PMAPI PM_sleep(ulong milliseconds) -{ - ulong microseconds = milliseconds * 1000L; - LZTimerObject tm; - - LZTimerOnExt(&tm); - while (LZTimerLapExt(&tm) < microseconds) - ; - LZTimerOffExt(&tm); -} - -int PMAPI PM_getCOMPort(int port) -{ - switch (port) { - 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; - } - return 0; -} - -PM_MODULE PMAPI PM_loadLibrary( - const char *szDLLName) -{ - (void)szDLLName; - return NULL; -} - -void * PMAPI PM_getProcAddress( - PM_MODULE hModule, - const char *szProcName) -{ - (void)hModule; - (void)szProcName; - return NULL; -} - -void PMAPI PM_freeLibrary( - PM_MODULE hModule) -{ - (void)hModule; -} - -int PMAPI PM_setIOPL( - int level) -{ - return level; -} - -/**************************************************************************** -REMARKS: -Internal function to convert the find data to the generic interface. -****************************************************************************/ -static void convertFindData( - PM_findData *findData, - struct find_t *blk) -{ - ulong dwSize = findData->dwSize; - - memset(findData,0,findData->dwSize); - findData->dwSize = dwSize; - if (blk->attrib & _A_RDONLY) - findData->attrib |= PM_FILE_READONLY; - if (blk->attrib & _A_SUBDIR) - findData->attrib |= PM_FILE_DIRECTORY; - if (blk->attrib & _A_ARCH) - findData->attrib |= PM_FILE_ARCHIVE; - if (blk->attrib & _A_HIDDEN) - findData->attrib |= PM_FILE_HIDDEN; - if (blk->attrib & _A_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; -} - -#define FIND_MASK (_A_RDONLY | _A_ARCH | _A_SUBDIR | _A_HIDDEN | _A_SYSTEM) - -/**************************************************************************** -REMARKS: -Function to find the first file matching a search criteria in a directory. -****************************************************************************/ -void * PMAPI PM_findFirstFile( - const char *filename, - PM_findData *findData) -{ - struct find_t *blk; - - if ((blk = PM_malloc(sizeof(*blk))) == NULL) - return PM_FILE_INVALID; - if (_dos_findfirst((char*)filename,FIND_MASK,blk) == 0) { - convertFindData(findData,blk); - return blk; - } - return PM_FILE_INVALID; -} - -/**************************************************************************** -REMARKS: -Function to find the next file matching a search criteria in a directory. -****************************************************************************/ -ibool PMAPI PM_findNextFile( - void *handle, - PM_findData *findData) -{ - struct find_t *blk = handle; - - if (_dos_findnext(blk) == 0) { - convertFindData(findData,blk); - return true; - } - return false; -} - -/**************************************************************************** -REMARKS: -Function to close the find process -****************************************************************************/ -void PMAPI PM_findClose( - void *handle) -{ - PM_free(handle); -} - -/**************************************************************************** -REMARKS: -Function to determine if a drive is a valid drive or not. Under Unix this -function will return false for anything except a value of 3 (considered -the root drive, and equivalent to C: for non-Unix systems). The drive -numbering is: - - 1 - Drive A: - 2 - Drive B: - 3 - Drive C: - etc - -****************************************************************************/ -ibool PMAPI PM_driveValid( - char drive) -{ - RMREGS regs; - regs.h.dl = (uchar)(drive - 'A' + 1); - regs.h.ah = 0x36; /* Get disk information service */ - PM_int86(0x21,®s,®s); - return regs.x.ax != 0xFFFF; /* AX = 0xFFFF if disk is invalid */ -} - -/**************************************************************************** -REMARKS: -Function to get the current working directory for the specififed drive. -Under Unix this will always return the current working directory regardless -of what the value of 'drive' is. -****************************************************************************/ -void PMAPI PM_getdcwd( - int drive, - char *dir, - int len) -{ - uint oldDrive,maxDrives; - _dos_getdrive(&oldDrive); - _dos_setdrive(drive,&maxDrives); - getcwd(dir,len); - _dos_setdrive(oldDrive,&maxDrives); -} - -/**************************************************************************** -REMARKS: -Function to change the file attributes for a specific file. -****************************************************************************/ -void PMAPI PM_setFileAttr( - const char *filename, - uint attrib) -{ -#if defined(TNT) && defined(_MSC_VER) - DWORD attr = 0; - - if (attrib & PM_FILE_READONLY) - attr |= FILE_ATTRIBUTE_READONLY; - if (attrib & PM_FILE_ARCHIVE) - attr |= FILE_ATTRIBUTE_ARCHIVE; - if (attrib & PM_FILE_HIDDEN) - attr |= FILE_ATTRIBUTE_HIDDEN; - if (attrib & PM_FILE_SYSTEM) - attr |= FILE_ATTRIBUTE_SYSTEM; - SetFileAttributes((LPSTR)filename, attr); -#else - uint attr = 0; - - if (attrib & PM_FILE_READONLY) - attr |= _A_RDONLY; - if (attrib & PM_FILE_ARCHIVE) - attr |= _A_ARCH; - if (attrib & PM_FILE_HIDDEN) - attr |= _A_HIDDEN; - if (attrib & PM_FILE_SYSTEM) - attr |= _A_SYSTEM; - _dos_setfileattr(filename,attr); -#endif -} - -/**************************************************************************** -REMARKS: -Function to create a directory. -****************************************************************************/ -ibool PMAPI PM_mkdir( - const char *filename) -{ -#ifdef __GNUC__ - return mkdir(filename,S_IRUSR) == 0; -#else -/*AM: return mkdir(filename) == 0; */ - return(false); -#endif -} - -/**************************************************************************** -REMARKS: -Function to remove a directory. -****************************************************************************/ -ibool PMAPI PM_rmdir( - const char *filename) -{ -/*AM: return rmdir(filename) == 0; */ - return(false); -} - -/**************************************************************************** -REMARKS: -Allocates a block of locked, physically contiguous memory. The memory -may be required to be below the 16Meg boundary. -****************************************************************************/ -void * PMAPI PM_allocLockedMem( - uint size, - ulong *physAddr, - ibool contiguous, - ibool below16M) -{ - void *p; - uint r_seg,r_off; - PM_lockHandle lh; - - /* Under DOS the only way to know the physical memory address is to - * allocate the memory below the 1Meg boundary as real mode memory. - * We also allocate 4095 bytes more memory than we need, so we can - * properly page align the start of the memory block for DMA operations. - */ - if (size > 4096) - return NULL; - if ((p = PM_allocRealSeg((size + 0xFFF) & ~0xFFF,&r_seg,&r_off)) == NULL) - return NULL; - *physAddr = ((r_seg << 4) + r_off + 0xFFF) & ~0xFFF; - PM_lockDataPages(p,size*2,&lh); - return p; -} - -void PMAPI PM_freeLockedMem(void *p,uint size,ibool contiguous) -{ - (void)size; - PM_freeRealSeg(p); -} - -/*-------------------------------------------------------------------------*/ -/* Generic DPMI routines common to 16/32 bit code */ -/*-------------------------------------------------------------------------*/ - -ulong PMAPI DPMI_mapPhysicalToLinear(ulong physAddr,ulong limit) -{ - PMREGS r; - 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; - } - - /* 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 - * will fail the calls unless this is the case. If we round the - * physical address, then we also add an extra offset into the address - * that we return. - */ - physOfs = physAddr & 4095; - physAddr = physAddr & ~4095; - limit = ((limit+physOfs+1+4095) & ~4095)-1; - - r.x.ax = 0x800; /* DPMI map physical to linear */ - r.x.bx = physAddr >> 16; - r.x.cx = physAddr & 0xFFFF; - r.x.si = limit >> 16; - r.x.di = limit & 0xFFFF; - PM_int386(0x31, &r, &r); - if (r.x.cflag) - return 0xFFFFFFFFUL; - return ((ulong)r.x.bx << 16) + r.x.cx + physOfs; -} - -int PMAPI DPMI_setSelectorBase(ushort sel,ulong linAddr) -{ - PMREGS r; - - r.x.ax = 7; /* DPMI set selector base address */ - r.x.bx = sel; - r.x.cx = linAddr >> 16; - r.x.dx = linAddr & 0xFFFF; - PM_int386(0x31, &r, &r); - if (r.x.cflag) - return 0; - return 1; -} - -ulong PMAPI DPMI_getSelectorBase(ushort sel) -{ - PMREGS r; - - r.x.ax = 6; /* DPMI get selector base address */ - r.x.bx = sel; - PM_int386(0x31, &r, &r); - return ((ulong)r.x.cx << 16) + r.x.dx; -} - -int PMAPI DPMI_setSelectorLimit(ushort sel,ulong limit) -{ - PMREGS r; - - r.x.ax = 8; /* DPMI set selector limit */ - r.x.bx = sel; - r.x.cx = limit >> 16; - r.x.dx = limit & 0xFFFF; - PM_int386(0x31, &r, &r); - if (r.x.cflag) - return 0; - return 1; -} - -uint PMAPI DPMI_createSelector(ulong base,ulong limit) -{ - uint sel; - PMREGS r; - - /* Allocate 1 descriptor */ - r.x.ax = 0; - r.x.cx = 1; - PM_int386(0x31, &r, &r); - if (r.x.cflag) return 0; - sel = r.x.ax; - - /* Set the descriptor access rights (for a 32 bit page granular - * segment, ring 0). - */ - r.x.ax = 9; - r.x.bx = sel; - r.x.cx = 0x4093; - PM_int386(0x31, &r, &r); - - /* Map physical memory and create selector */ - if ((base = DPMI_mapPhysicalToLinear(base,limit)) == 0xFFFFFFFFUL) - return 0; - if (!DPMI_setSelectorBase(sel,base)) - return 0; - if (!DPMI_setSelectorLimit(sel,limit)) - return 0; - return sel; -} - -void PMAPI DPMI_freeSelector(uint sel) -{ - PMREGS r; - - r.x.ax = 1; - r.x.bx = sel; - PM_int386(0x31, &r, &r); -} - -int PMAPI DPMI_lockLinearPages(ulong linear,ulong len) -{ - PMREGS r; - - r.x.ax = 0x600; /* DPMI Lock Linear Region */ - r.x.bx = (linear >> 16); /* Linear address in BX:CX */ - r.x.cx = (linear & 0xFFFF); - r.x.si = (len >> 16); /* Length in SI:DI */ - r.x.di = (len & 0xFFFF); - PM_int386(0x31, &r, &r); - return (!r.x.cflag); -} - -int PMAPI DPMI_unlockLinearPages(ulong linear,ulong len) -{ - PMREGS r; - - r.x.ax = 0x601; /* DPMI Unlock Linear Region */ - r.x.bx = (linear >> 16); /* Linear address in BX:CX */ - r.x.cx = (linear & 0xFFFF); - r.x.si = (len >> 16); /* Length in SI:DI */ - r.x.di = (len & 0xFFFF); - PM_int386(0x31, &r, &r); - return (!r.x.cflag); -} - -void * PMAPI DPMI_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) -{ - PMSREGS sregs; - ulong linAddr; - ulong DSBaseAddr; - - /* Get the base address for the default DS selector */ - 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; - } - - /* 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; - } - - /* Now expand the default DS selector to 4Gb so we can access it */ - if (!DPMI_setSelectorLimit(sregs.ds,0xFFFFFFFFUL)) - 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 - * caching enabled which hurts the performance of the linear framebuffer - * as it disables write combining on Pentium Pro and above processors. - * - * For those processors cache disabling is better handled through the - * MTRR registers anyway (we can write combine a region but disable - * 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; - } - } - } - } - - /* Now return the base address of the memory into the default DS */ - return (void*)(linAddr - DSBaseAddr); -} - -/* Some DOS extender implementations do not directly support calling a - * real mode procedure from protected mode. However we can simulate what - * we need temporarily hooking the INT 6Ah vector with a small real mode - * stub that will call our real mode code for us. - */ - -static uchar int6AHandler[] = { - 0x00,0x00,0x00,0x00, /* __PMODE_callReal variable */ - 0xFB, /* sti */ - 0x2E,0xFF,0x1E,0x00,0x00, /* call [cs:__PMODE_callReal] */ - 0xCF, /* iretf */ - }; -static uchar *crPtr = NULL; /* Pointer to of int 6A handler */ -static uint crRSeg,crROff; /* Real mode seg:offset of handler */ - -void PMAPI PM_callRealMode(uint seg,uint off, RMREGS *in, - RMSREGS *sregs) -{ - uchar *p; - 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)); - } - PM_setWord(crPtr,off); /* Plug in address to call */ - PM_setWord(crPtr+2,seg); - p = PM_mapRealPointer(0,0x6A * 4); - oldOff = PM_getWord(p); /* Save old handler address */ - oldSeg = PM_getWord(p+2); - PM_setWord(p,crROff+4); /* Hook 6A handler */ - PM_setWord(p+2,crRSeg); - PM_int86x(0x6A, in, in, sregs); /* Call real mode code */ - PM_setWord(p,oldOff); /* Restore old handler */ - PM_setWord(p+2,oldSeg); -} - -void * PMAPI PM_getBIOSPointer(void) -{ return PM_mapPhysicalAddr(0x400,0xFFFF,true); } - -void * PMAPI PM_getA0000Pointer(void) -{ return PM_mapPhysicalAddr(0xA0000,0xFFFF,true); } - -void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) -{ return DPMI_mapPhysicalAddr(base,limit,isCached); } - -void PMAPI PM_freePhysicalAddr(void *ptr,ulong limit) -{ - /* Mapping cannot be free */ -} - -ulong PMAPI PM_getPhysicalAddr(void *p) -{ - /* TODO: This function should find the physical address of a linear */ - /* address. */ - (void)p; - return 0xFFFFFFFFUL; -} - -void * PMAPI PM_mapToProcess(void *base,ulong limit) -{ - (void)limit; - return (void*)base; -} - -void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) -{ - static uchar *zeroPtr = NULL; - - if (!zeroPtr) - zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF,true); - return (void*)(zeroPtr + MK_PHYS(r_seg,r_off)); -} - -void * PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off) -{ - PMREGS r; - void *p; - - r.x.ax = 0x100; /* DPMI allocate DOS memory */ - r.x.bx = (size + 0xF) >> 4; /* number of paragraphs */ - PM_int386(0x31, &r, &r); - if (r.x.cflag) - return NULL; /* DPMI call failed */ - *r_seg = r.x.ax; /* Real mode segment */ - *r_off = 0; - p = PM_mapRealPointer(*r_seg,*r_off); - _PM_addRealModeBlock(p,r.x.dx); - return p; -} - -void PMAPI PM_freeRealSeg(void *mem) -{ - PMREGS 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; - -void PMAPI DPMI_setInt10Handler(DPMI_handler_t handler) -{ - DPMI_int10 = handler; -} - -void PMAPI DPMI_int86(int intno, DPMI_regs *regs) -{ - PMREGS r; - PMSREGS sr; - - if (intno == 0x10 && DPMI_int10) { - if (DPMI_int10(regs)) - return; - } - PM_segread(&sr); - r.x.ax = 0x300; /* DPMI issue real interrupt */ - r.h.bl = intno; - r.h.bh = 0; - r.x.cx = 0; - sr.es = sr.ds; - r.e.edi = (uint)regs; - PM_int386x(0x31, &r, &r, &sr); /* Issue the interrupt */ -} - -#define IN(reg) rmregs.reg = in->e.reg -#define OUT(reg) out->e.reg = rmregs.reg - -int PMAPI PM_int86(int intno, RMREGS *in, RMREGS *out) -{ - DPMI_regs rmregs; - - 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 */ - - OUT(eax); OUT(ebx); OUT(ecx); OUT(edx); OUT(esi); OUT(edi); - out->x.cflag = rmregs.flags & 0x1; - return out->x.ax; -} - -int PMAPI PM_int86x(int intno, RMREGS *in, RMREGS *out, - RMSREGS *sregs) -{ - DPMI_regs rmregs; - - memset(&rmregs, 0, sizeof(rmregs)); - IN(eax); IN(ebx); IN(ecx); IN(edx); IN(esi); IN(edi); - rmregs.es = sregs->es; - rmregs.ds = sregs->ds; - -/*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; - sregs->cs = rmregs.cs; - sregs->ss = rmregs.ss; - sregs->ds = rmregs.ds; - out->x.cflag = rmregs.flags & 0x1; - return out->x.ax; -} - -#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; - -#pragma pack() - -void PMAPI PM_availableMemory(ulong *physical,ulong *total) -{ - PMREGS r; - PMSREGS sr; - MemInfo memInfo; - - PM_segread(&sr); - r.x.ax = 0x500; /* DPMI get free memory info */ - sr.es = sr.ds; - r.e.edi = (uint)&memInfo; - PM_int386x(0x31, &r, &r, &sr); /* Issue the interrupt */ - *physical = memInfo.NumPhysicalPagesFree * 4096; - *total = memInfo.LargestBlockAvail; - if (*total < *physical) - *physical = *total; -} - -/**************************************************************************** -REMARKS: -Function to get the file attributes for a specific file. -****************************************************************************/ -uint PMAPI PM_getFileAttr( - const char *filename) -{ - /* TODO: Implement this! */ - return 0; -} - -/**************************************************************************** -REMARKS: -Function to get the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_getFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - /* TODO: Implement this! */ - return false; -} - -/**************************************************************************** -REMARKS: -Function to set the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_setFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - /* 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 deleted file mode 100644 index 98e31bc638..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/pmsmx.c +++ /dev/null @@ -1,471 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit SMX embedded systems development -* -* Description: Implementation for the OS Portability Manager Library, which -* contains functions to implement OS specific services in a -* generic, cross platform API. Porting the OS Portability -* Manager library is the first step to porting any SciTech -* products to a new platform. -* -****************************************************************************/ - -#include "pmapi.h" -#include -#include -#include -#include -#include "smx/ps2mouse.h" - -/*--------------------------- Global variables ----------------------------*/ - -static int globalDataStart; - -PM_criticalHandler _VARAPI _PM_critHandler = NULL; -PM_breakHandler _VARAPI _PM_breakHandler = NULL; -PM_intHandler _VARAPI _PM_timerHandler = NULL; -PM_intHandler _VARAPI _PM_rtcHandler = NULL; -PM_intHandler _VARAPI _PM_keyHandler = NULL; -PM_key15Handler _VARAPI _PM_key15Handler = NULL; -PM_mouseHandler _VARAPI _PM_mouseHandler = NULL; -PM_intHandler _VARAPI _PM_int10Handler = NULL; -int _VARAPI _PM_mouseMask; - -uchar * _VARAPI _PM_ctrlCPtr; /* Location of Ctrl-C flag */ -uchar * _VARAPI _PM_ctrlBPtr; /* Location of Ctrl-Break flag */ -uchar * _VARAPI _PM_critPtr; /* Location of Critical error Bf*/ -PMFARPTR _VARAPI _PM_prevTimer = PMNULL; /* Previous timer handler */ -PMFARPTR _VARAPI _PM_prevRTC = PMNULL; /* Previous RTC handler */ -PMFARPTR _VARAPI _PM_prevKey = PMNULL; /* Previous key handler */ -PMFARPTR _VARAPI _PM_prevKey15 = PMNULL; /* Previous key15 handler */ -PMFARPTR _VARAPI _PM_prevBreak = PMNULL; /* Previous break handler */ -PMFARPTR _VARAPI _PM_prevCtrlC = PMNULL; /* Previous CtrlC handler */ -PMFARPTR _VARAPI _PM_prevCritical = PMNULL; /* Previous critical handler */ -long _VARAPI _PM_prevRealTimer; /* Previous real mode timer */ -long _VARAPI _PM_prevRealRTC; /* Previous real mode RTC */ -long _VARAPI _PM_prevRealKey; /* Previous real mode key */ -long _VARAPI _PM_prevRealKey15; /* Previous real mode key15 */ -long _VARAPI _PM_prevRealInt10; /* Previous real mode int 10h */ -static uchar _PM_oldCMOSRegA; /* CMOS register A contents */ -static uchar _PM_oldCMOSRegB; /* CMOS register B contents */ -static uchar _PM_oldRTCPIC2; /* Mask value for RTC IRQ8 */ - -/*----------------------------- Implementation ----------------------------*/ - -/* Globals for locking interrupt handlers in _pmsmx.asm */ - -extern int _ASMAPI _PM_pmsmxDataStart; -extern int _ASMAPI _PM_pmsmxDataEnd; -void _ASMAPI _PM_pmsmxCodeStart(void); -void _ASMAPI _PM_pmsmxCodeEnd(void); - -/* Protected mode interrupt handlers, also called by PM callbacks below */ - -void _ASMAPI _PM_timerISR(void); -void _ASMAPI _PM_rtcISR(void); -void _ASMAPI _PM_keyISR(void); -void _ASMAPI _PM_key15ISR(void); -void _ASMAPI _PM_breakISR(void); -void _ASMAPI _PM_ctrlCISR(void); -void _ASMAPI _PM_criticalISR(void); -void _ASMAPI _PM_mouseISR(void); -void _ASMAPI _PM_int10PMCB(void); - -/* Protected mode DPMI callback handlers */ - -void _ASMAPI _PM_mousePMCB(void); - -/* Routine to install a mouse handler function */ - -void _ASMAPI _PM_setMouseHandler(int mask); - -/* Routine to allocate DPMI real mode callback routines */ - -void _ASMAPI _DPMI_allocateCallback(void (_ASMAPI *pmcode)(),void *rmregs,long *RMCB); -void _ASMAPI _DPMI_freeCallback(long RMCB); - -/* DPMI helper functions in PMLITE.C */ - -ulong PMAPI DPMI_mapPhysicalToLinear(ulong physAddr,ulong limit); -int PMAPI DPMI_setSelectorBase(ushort sel,ulong linAddr); -ulong PMAPI DPMI_getSelectorBase(ushort sel); -int PMAPI DPMI_setSelectorLimit(ushort sel,ulong limit); -uint PMAPI DPMI_createSelector(ulong base,ulong limit); -void PMAPI DPMI_freeSelector(uint sel); -int PMAPI DPMI_lockLinearPages(ulong linear,ulong len); -int PMAPI DPMI_unlockLinearPages(ulong linear,ulong len); - -/* Functions to read and write CMOS registers */ - -uchar PMAPI _PM_readCMOS(int index); -void PMAPI _PM_writeCMOS(int index,uchar value); - -/*-------------------------------------------------------------------------*/ -/* Generic routines common to all environments */ -/*-------------------------------------------------------------------------*/ - -void PMAPI PM_resetMouseDriver(int hardReset) -{ - ps2MouseReset(); -} - -void PMAPI PM_setRealTimeClockFrequency(int frequency) -{ - static short convert[] = { - 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); - } - 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); - } -} - -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; - } -} - -void PMAPI PM_getPMvect(int intno, PMFARPTR *isr) -{ - PMREGS regs; - - regs.x.ax = 0x204; - regs.h.bl = intno; - PM_int386(0x31,®s,®s); - isr->sel = regs.x.cx; - isr->off = regs.e.edx; -} - -void PMAPI PM_setPMvect(int intno, PM_intHandler isr) -{ - PMSREGS sregs; - PMREGS regs; - - PM_saveDS(); - regs.x.ax = 0x205; /* Set protected mode vector */ - regs.h.bl = intno; - PM_segread(&sregs); - regs.x.cx = sregs.cs; - regs.e.edx = (uint)isr; - PM_int386(0x31,®s,®s); -} - -void PMAPI PM_restorePMvect(int intno, PMFARPTR isr) -{ - PMREGS regs; - - regs.x.ax = 0x205; - regs.h.bl = intno; - regs.x.cx = isr.sel; - regs.e.edx = isr.off; - PM_int386(0x31,®s,®s); -} - -static long prevRealBreak; /* Previous real mode break handler */ -static long prevRealCtrlC; /* Previous real mode CtrlC handler */ -static long prevRealCritical; /* Prev real mode critical handler */ - -int PMAPI PM_setMouseHandler(int mask, PM_mouseHandler mh) -{ - lockPMHandlers(); /* Ensure our handlers are locked */ - - _PM_mouseHandler = mh; - return 0; -} - -void PMAPI PM_restoreMouseHandler(void) -{ - if (_PM_mouseHandler) - _PM_mouseHandler = NULL; -} - -static void getISR(int intno, PMFARPTR *pmisr, long *realisr) -{ - PM_getPMvect(intno,pmisr); -} - -static void restoreISR(int intno, PMFARPTR pmisr, long realisr) -{ - PM_restorePMvect(intno,pmisr); -} - -static void setISR(int intno, void (* PMAPI pmisr)()) -{ - lockPMHandlers(); /* Ensure our handlers are locked */ - PM_setPMvect(intno,pmisr); -} - -void PMAPI PM_setTimerHandler(PM_intHandler th) -{ - getISR(PM_IRQ0, &_PM_prevTimer, &_PM_prevRealTimer); - _PM_timerHandler = th; - setISR(PM_IRQ0, _PM_timerISR); -} - -void PMAPI PM_restoreTimerHandler(void) -{ - if (_PM_timerHandler) { - restoreISR(PM_IRQ0, _PM_prevTimer, _PM_prevRealTimer); - _PM_timerHandler = NULL; - } -} - -ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler th,int frequency) -{ - /* Save the old CMOS real time clock values */ - _PM_oldCMOSRegA = _PM_readCMOS(0x0A); - _PM_oldCMOSRegB = _PM_readCMOS(0x0B); - - /* Set the real time clock interrupt handler */ - getISR(0x70, &_PM_prevRTC, &_PM_prevRealRTC); - _PM_rtcHandler = th; - setISR(0x70, _PM_rtcISR); - - /* Program the real time clock default frequency */ - PM_setRealTimeClockFrequency(frequency); - - /* Unmask IRQ8 in the PIC2 */ - _PM_oldRTCPIC2 = PM_inpb(0xA1); - PM_outpb(0xA1,_PM_oldRTCPIC2 & 0xFE); - return true; -} - -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; - } -} - -void PMAPI PM_setKeyHandler(PM_intHandler kh) -{ - getISR(PM_IRQ1, &_PM_prevKey, &_PM_prevRealKey); - _PM_keyHandler = kh; - setISR(PM_IRQ1, _PM_keyISR); -} - -void PMAPI PM_restoreKeyHandler(void) -{ - if (_PM_keyHandler) { - restoreISR(PM_IRQ1, _PM_prevKey, _PM_prevRealKey); - _PM_keyHandler = NULL; - } -} - -void PMAPI PM_setKey15Handler(PM_key15Handler kh) -{ - getISR(0x15, &_PM_prevKey15, &_PM_prevRealKey15); - _PM_key15Handler = kh; - setISR(0x15, _PM_key15ISR); -} - -void PMAPI PM_restoreKey15Handler(void) -{ - if (_PM_key15Handler) { - restoreISR(0x15, _PM_prevKey15, _PM_prevRealKey15); - _PM_key15Handler = NULL; - } -} - -/* Real mode Ctrl-C and Ctrl-Break handler. This handler simply sets a - * flag in the real mode code segment and exit. We save the location - * of this flag in real mode memory so that both the real mode and - * protected mode code will be modifying the same flags. - */ - -static uchar ctrlHandler[] = { - 0x00,0x00,0x00,0x00, /* ctrlBFlag */ - 0x66,0x2E,0xC7,0x06,0x00,0x00, - 0x01,0x00,0x00,0x00, /* mov [cs:ctrlBFlag],1 */ - 0xCF, /* iretf */ - }; - -void PMAPI PM_installAltBreakHandler(PM_breakHandler bh) -{ - uint rseg,roff; - - getISR(0x1B, &_PM_prevBreak, &prevRealBreak); - getISR(0x23, &_PM_prevCtrlC, &prevRealCtrlC); - _PM_breakHandler = bh; - setISR(0x1B, _PM_breakISR); - setISR(0x23, _PM_ctrlCISR); - - /* Hook the real mode vectors for these handlers, as these are not - * normally reflected by the DPMI server up to protected mode - */ - _PM_ctrlBPtr = PM_allocRealSeg(sizeof(ctrlHandler)*2, &rseg, &roff); - memcpy(_PM_ctrlBPtr,ctrlHandler,sizeof(ctrlHandler)); - memcpy(_PM_ctrlBPtr+sizeof(ctrlHandler),ctrlHandler,sizeof(ctrlHandler)); - _PM_ctrlCPtr = _PM_ctrlBPtr + sizeof(ctrlHandler); - _PM_setRMvect(0x1B,((long)rseg << 16) | (roff+4)); - _PM_setRMvect(0x23,((long)rseg << 16) | (roff+sizeof(ctrlHandler)+4)); -} - -void PMAPI PM_installBreakHandler(void) -{ - PM_installAltBreakHandler(NULL); -} - -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); - } -} - -/* Real mode Critical Error handler. This handler simply saves the AX and - * DI values in the real mode code segment and exits. We save the location - * of this flag in real mode memory so that both the real mode and - * protected mode code will be modifying the same flags. - */ - -static uchar criticalHandler[] = { - 0x00,0x00, /* axCode */ - 0x00,0x00, /* diCode */ - 0x2E,0xA3,0x00,0x00, /* mov [cs:axCode],ax */ - 0x2E,0x89,0x3E,0x02,0x00, /* mov [cs:diCode],di */ - 0xB8,0x03,0x00, /* mov ax,3 */ - 0xCF, /* iretf */ - }; - -void PMAPI PM_installAltCriticalHandler(PM_criticalHandler ch) -{ - uint rseg,roff; - - getISR(0x24, &_PM_prevCritical, &prevRealCritical); - _PM_critHandler = ch; - setISR(0x24, _PM_criticalISR); - - /* Hook the real mode vector, as this is not normally reflected by the - * DPMI server up to protected mode. - */ - _PM_critPtr = PM_allocRealSeg(sizeof(criticalHandler)*2, &rseg, &roff); - memcpy(_PM_critPtr,criticalHandler,sizeof(criticalHandler)); - _PM_setRMvect(0x24,((long)rseg << 16) | (roff+4)); -} - -void PMAPI PM_installCriticalHandler(void) -{ - PM_installAltCriticalHandler(NULL); -} - -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; - } -} - -int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - PMSREGS sregs; - PM_segread(&sregs); - return DPMI_lockLinearPages((uint)p + DPMI_getSelectorBase(sregs.ds),len); -} - -int PMAPI PM_unlockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - PMSREGS sregs; - PM_segread(&sregs); - return DPMI_unlockLinearPages((uint)p + DPMI_getSelectorBase(sregs.ds),len); -} - -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. */ - return DPMI_lockLinearPages((uint)p,len); -} - -int PMAPI PM_unlockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - PMSREGS sregs; - PM_segread(&sregs); - return DPMI_unlockLinearPages((uint)p,len); -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/smx/vflat.c b/board/MAI/bios_emulator/scitech/src/pm/smx/vflat.c deleted file mode 100644 index 579ef2c95c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/vflat.c +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Dummy module; no virtual framebuffer for this OS -* -****************************************************************************/ - -#include "pmapi.h" - -ibool PMAPI VF_available(void) -{ - return false; -} - -void * PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) -{ - baseAddr = baseAddr; - bankSize = bankSize; - codeLen = codeLen; - bankFunc = bankFunc; - return NULL; -} - -void PMAPI VF_exit(void) -{ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/smx/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/smx/ztimer.c deleted file mode 100644 index 794119282e..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/ztimer.c +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit SMX embedded systems development -* -* Description: OS specific implementation for the Zen Timer functions. -* LZTimer not supported for smx (as needed for i486 processors), only -* ULZTimer is supported at this time. -* -****************************************************************************/ - -/*---------------------------- Global smx variables -----------------------*/ - -extern ulong _cdecl etime; /* elapsed time */ -extern ulong _cdecl xticks_per_second(void); - -/*----------------------------- Implementation ----------------------------*/ - -/* External assembler functions */ - -void _ASMAPI LZ_disable(void); -void _ASMAPI LZ_enable(void); - - -/**************************************************************************** -REMARKS: -Initialise the Zen Timer module internals. -****************************************************************************/ -void __ZTimerInit(void) -{ -} - -ulong reterr(void) -{ - PM_fatalError("Zen Timer not supported for smx."); - return(0); -} - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerOn(tm) PM_fatalError("Zen Timer not supported for smx.") - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerLap(tm) reterr() - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerOff(tm) PM_fatalError("Zen Timer not supported for smx.") - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerCount(tm) reterr() - -/**************************************************************************** -REMARKS: -Define the resolution of the long period timer as seconds per timer tick. -****************************************************************************/ -#define ULZTIMER_RESOLUTION (ulong)(1000000/xticks_per_second()) - -/**************************************************************************** -REMARKS: -Read the Long Period timer value from the smx timer tick. -****************************************************************************/ -static ulong __ULZReadTime(void) -{ - ulong ticks; - LZ_disable(); /* Turn of interrupts */ - ticks = etime; - LZ_enable(); /* Turn on interrupts again */ - return ticks; -} - -/**************************************************************************** -REMARKS: -Compute the elapsed time from the BIOS timer tick. Note that we check to see -whether a midnight boundary has passed, and if so adjust the finish time to -account for this. We cannot detect if more that one midnight boundary has -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 */ - 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 deleted file mode 100644 index 0615e90165..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/stub/cpuinfo.c +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: *** TODO: ADD YOUR OS ENVIRONMENT NAME HERE *** -* -* Description: Module to implement OS specific services to measure the -* CPU frequency. -* -****************************************************************************/ - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -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. */ - return oldPriority; -} - -/**************************************************************************** -REMARKS: -Restore the original thread priority. -****************************************************************************/ -static void RestoreThreadPriority( - int priority) -{ - /* TODO: Restore the original thread priority on exit. */ -} - -/**************************************************************************** -REMARKS: -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. */ - freq->low = 0; - freq->high = 0; -} - -/**************************************************************************** -REMARKS: -Read the counter and return the counter value. - -TODO: Implement this to read the counter. It should be done as a macro - for accuracy. -****************************************************************************/ -#define GetCounter(t) \ -{ \ - (t)->low = 0; \ - (t)->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 deleted file mode 100644 index 204c492540..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/stub/event.c +++ /dev/null @@ -1,199 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: *** TODO: ADD YOUR OS ENVIRONMENT NAME HERE *** -* -* Description: **** implementation for the SciTech cross platform -* event library. -* -****************************************************************************/ - -/*---------------------------- Global Variables ---------------------------*/ - -static ushort keyUpMsg[256] = {0};/* Table of key up messages */ -static int rangeX,rangeY; /* Range of mouse coordinates */ - -/*---------------------------- Implementation -----------------------------*/ - -/* These are not used under non-DOS systems */ -#define _EVT_disableInt() 1 -#define _EVT_restoreInt(flags) - -/**************************************************************************** -PARAMETERS: -scanCode - Scan code to test - -REMARKS: -This macro determines if a specified key is currently down at the -time that the call is made. -****************************************************************************/ -#define _EVT_isKeyDown(scanCode) (keyUpMsg[scanCode] != 0) - -/**************************************************************************** -REMARKS: -This function is used to return the number of ticks since system -startup in milliseconds. This should be the same value that is placed into -the time stamp fields of events, and is used to implement auto mouse down -events. -****************************************************************************/ -ulong _EVT_getTicks(void) -{ - /* TODO: Implement this for your OS! */ -} - -/**************************************************************************** -REMARKS: -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. */ -} - -/**************************************************************************** -REMARKS: -This macro/function is used to converts the scan codes reported by the -keyboard to our event libraries normalised format. We only have one scan -code for the 'A' key, and use shift modifiers to determine if it is a -Ctrl-F1, Alt-F1 etc. The raw scan codes from the keyboard work this way, -but the OS gives us 'cooked' scan codes, we have to translate them back -to the raw format. -****************************************************************************/ -#define _EVT_maskKeyCode(evt) - -/**************************************************************************** -REMARKS: -Safely abort the event module upon catching a fatal error. -****************************************************************************/ -void _EVT_abort() -{ - EVT_exit(); - PM_fatalError("Unhandled exception!"); -} - -/**************************************************************************** -PARAMETERS: -mouseMove - Callback function to call wheneve the mouse needs to be moved - -REMARKS: -Initiliase the event handling module. Here we install our mouse handling ISR -to be called whenever any button's are pressed or released. We also build -the free list of events in the event queue. - -We use handler number 2 of the mouse libraries interrupt handlers for our -event handling routines. -****************************************************************************/ -void EVTAPI EVT_init( - _EVT_mouseMoveHandler mouseMove) -{ - /* Initialise the event queue */ - _mouseMove = mouseMove; - initEventQueue(); - memset(keyUpMsg,0,sizeof(keyUpMsg)); - - /* TODO: Do any OS specific initialisation here */ - - /* Catch program termination signals so we can clean up properly */ - signal(SIGABRT, _EVT_abort); - signal(SIGFPE, _EVT_abort); - signal(SIGINT, _EVT_abort); -} - -/**************************************************************************** -REMARKS -Changes the range of coordinates returned by the mouse functions to the -specified range of values. This is used when changing between graphics -modes set the range of mouse coordinates for the new display mode. -****************************************************************************/ -void EVTAPI EVT_setMouseRange( - int xRes, - int yRes) -{ - rangeX = xRes; - rangeY = yRes; -} - -/**************************************************************************** -REMARKS: -Initiailises the internal event handling modules. The EVT_suspend function -can be called to suspend event handling (such as when shelling out to DOS), -and this function can be used to resume it again later. -****************************************************************************/ -void EVT_resume(void) -{ - /* Do nothing for non DOS systems */ -} - -/**************************************************************************** -REMARKS -Suspends all of our event handling operations. This is also used to -de-install the event handling code. -****************************************************************************/ -void EVT_suspend(void) -{ - /* Do nothing for non DOS systems */ -} - -/**************************************************************************** -REMARKS -Exits the event module for program terminatation. -****************************************************************************/ -void EVT_exit(void) -{ - /* Restore signal handlers */ - signal(SIGABRT, SIG_DFL); - signal(SIGFPE, SIG_DFL); - signal(SIGINT, SIG_DFL); - - /* 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 deleted file mode 100644 index 1395cbc3c4..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/stub/oshdr.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: BeOS -* -* Description: Include file to include all OS specific header files. -* -****************************************************************************/ - -/* 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 deleted file mode 100644 index 5f278c32df..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/stub/pm.c +++ /dev/null @@ -1,980 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: *** TODO: ADD YOUR OS ENVIRONMENT NAME HERE *** -* -* Description: Implementation for the OS Portability Manager Library, which -* contains functions to implement OS specific services in a -* generic, cross platform API. Porting the OS Portability -* Manager library is the first step to porting any SciTech -* products to a new platform. -* -****************************************************************************/ - -#include "pmapi.h" -#include "drvlib/os/os.h" -#include -#include -#include - -/* 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. */ - -static uint VESABuf_len = 1024; /* Length of the VESABuf buffer */ -static void *VESABuf_ptr = NULL; /* Near pointer to VESABuf */ -static uint VESABuf_rseg; /* Real mode segment of VESABuf */ -static uint VESABuf_roff; /* Real mode offset of VESABuf */ - -static void (PMAPIP fatalErrorCleanup)(void) = NULL; - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -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: 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(); */ -} - -/**************************************************************************** -REMARKS: -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 */ - return _OS_MYOS; -} - -/**************************************************************************** -REMARKS: -Return the runtime type identifier (always PM_386 for protected mode) -****************************************************************************/ -int PMAPI PM_getModeType(void) -{ return PM_386; } - -/**************************************************************************** -REMARKS: -Add a file directory separator to the end of the filename. -****************************************************************************/ -void PMAPI PM_backslash( - char *s) -{ - uint pos = strlen(s); - if (s[pos-1] != '/') { - s[pos] = '/'; - s[pos+1] = '\0'; - } -} - -/**************************************************************************** -REMARKS: -Add a user defined PM_fatalError cleanup function. -****************************************************************************/ -void PMAPI PM_setFatalErrorCleanup( - void (PMAPIP cleanup)(void)) -{ - fatalErrorCleanup = cleanup; -} - -/**************************************************************************** -REMARKS: -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. */ - if (fatalErrorCleanup) - fatalErrorCleanup(); - fprintf(stderr,"%s\n", msg); - exit(1); -} - -/**************************************************************************** -REMARKS: -Exit handler to kill the VESA transfer buffer. -****************************************************************************/ -static void ExitVBEBuf(void) -{ - /* TODO: If you do not have BIOS access, remove this function. */ - if (VESABuf_ptr) - PM_freeRealSeg(VESABuf_ptr); - VESABuf_ptr = 0; -} - -/**************************************************************************** -REMARKS: -Allocate the real mode VESA transfer buffer for communicating with the BIOS. -****************************************************************************/ -void * PMAPI PM_getVESABuf( - uint *len, - uint *rseg, - uint *roff) -{ - /* TODO: If you do not have BIOS access, simply delete the guts of */ - /* this function and return NULL. */ - if (!VESABuf_ptr) { - /* Allocate a global buffer for communicating with the VESA VBE */ - if ((VESABuf_ptr = PM_allocRealSeg(VESABuf_len, &VESABuf_rseg, &VESABuf_roff)) == NULL) - return NULL; - atexit(ExitVBEBuf); - } - *len = VESABuf_len; - *rseg = VESABuf_rseg; - *roff = VESABuf_roff; - return VESABuf_ptr; -} - -/**************************************************************************** -REMARKS: -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. */ - return true; -} - -/**************************************************************************** -REMARKS: -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. */ - return 0xD; -} - -/**************************************************************************** -REMARKS: -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). */ - return 0; -} - -/**************************************************************************** -REMARKS: -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. */ - return 1; -} - -/**************************************************************************** -REMARKS: -Save the state of the console into the state buffer. -****************************************************************************/ -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. */ -} - -/**************************************************************************** -REMARKS: -Restore the state of the console from the state buffer. -****************************************************************************/ -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. */ -} - -/**************************************************************************** -REMARKS: -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. */ -} - -/**************************************************************************** -REMARKS: -Set the location of the OS console cursor. -****************************************************************************/ -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). */ -} - -/**************************************************************************** -REMARKS: -Set the width of the OS console. -****************************************************************************/ -void PM_setOSScreenWidth( - int width, - int height) -{ - /* TODO: Set the OS console screen width. This is generally unused for */ - /* new OS ports. */ -} - -/**************************************************************************** -REMARKS: -Set the real time clock handler (used for software stereo modes). -****************************************************************************/ -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. */ - return false; -} - -/**************************************************************************** -REMARKS: -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. */ -} - -/**************************************************************************** -REMARKS: -Restore the original real time clock handler. -****************************************************************************/ -void PMAPI PM_restoreRealTimeClockHandler(void) -{ - /* TODO: Restores the real time clock handler. */ -} - -/**************************************************************************** -REMARKS: -Return the current operating system path or working directory. -****************************************************************************/ -char * PMAPI PM_getCurrentPath( - char *path, - int maxLen) -{ - return getcwd(path,maxLen); -} - -/**************************************************************************** -REMARKS: -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. */ - return '/'; -} - -/**************************************************************************** -REMARKS: -Return the path to the VBE/AF driver files (legacy and not used). -****************************************************************************/ -const char * PMAPI PM_getVBEAFPath(void) -{ - return PM_getNucleusConfigPath(); -} - -/**************************************************************************** -REMARKS: -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. */ - char *env = getenv("NUCLEUS_PATH"); - return env ? env : "/usr/lib/nucleus"; -} - -/**************************************************************************** -REMARKS: -Return the path to the Nucleus configuration files. -****************************************************************************/ -const char * PMAPI PM_getNucleusConfigPath(void) -{ - static char path[256]; - strcpy(path,PM_getNucleusPath()); - PM_backslash(path); - strcat(path,"config"); - return path; -} - -/**************************************************************************** -REMARKS: -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. */ - static char buf[128]; - gethostname(buf, 128); - return buf; -} - -/**************************************************************************** -REMARKS: -Get the name of the machine on the network. -****************************************************************************/ -const char * PMAPI PM_getMachineName(void) -{ - /* TODO: Return the network machine name for the machine. */ - static char buf[128]; - gethostname(buf, 128); - return buf; -} - -/**************************************************************************** -REMARKS: -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. */ - if (!zeroPtr) - zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF,true); - return (void*)(zeroPtr + 0x400); -} - -/**************************************************************************** -REMARKS: -Return a pointer to 0xA0000 physical VGA graphics framebuffer. -****************************************************************************/ -void * PMAPI PM_getA0000Pointer(void) -{ - static void *bankPtr; - if (!bankPtr) - bankPtr = PM_mapPhysicalAddr(0xA0000,0xFFFF,true); - return bankPtr; -} - -/**************************************************************************** -REMARKS: -Map a physical address to a linear address in the callers process. -****************************************************************************/ -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. */ - return NULL; -} - -/**************************************************************************** -REMARKS: -Free a physical address mapping allocated by PM_mapPhysicalAddr. -****************************************************************************/ -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. */ -} - -/**************************************************************************** -REMARKS: -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. */ - return 0xFFFFFFFFUL; -} - -void PMAPI PM_sleep(ulong 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. */ - switch (port) { - 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. */ - switch (port) { - case 0: return 0x3BC; - case 1: return 0x378; - case 2: return 0x278; - } - return 0; -} - -/**************************************************************************** -REMARKS: -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. */ - return PM_malloc(size); -} - -/**************************************************************************** -REMARKS: -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. */ - PM_free(ptr); -} - -/**************************************************************************** -REMARKS: -Map a linear memory address to the calling process address space. The -address will have been allocated in another process using the -PM_mapPhysicalAddr function. -****************************************************************************/ -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. */ - - /* 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; -} - -/**************************************************************************** -REMARKS: -Map a real mode pointer to a protected mode pointer. -****************************************************************************/ -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. */ - if (!zeroPtr) - zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF); - return (void*)(zeroPtr + MK_PHYS(r_seg,r_off)); -} - -/**************************************************************************** -REMARKS: -Allocate a block of real mode memory -****************************************************************************/ -void * PMAPI PM_allocRealSeg( - uint size, - 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. */ - return NULL; -} - -/**************************************************************************** -REMARKS: -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. */ -} - -/**************************************************************************** -REMARKS: -Issue a real mode interrupt (parameters in DPMI compatible structure) -****************************************************************************/ -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. */ -} - -/**************************************************************************** -REMARKS: -Issue a real mode interrupt. -****************************************************************************/ -int PMAPI PM_int86( - int intno, - 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. */ - return 0; -} - -/**************************************************************************** -REMARKS: -Issue a real mode interrupt. -****************************************************************************/ -int PMAPI PM_int86x( - int intno, - RMREGS *in, - 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. */ - return 0; -} - -/**************************************************************************** -REMARKS: -Call a real mode far function. -****************************************************************************/ -void PMAPI PM_callRealMode( - uint seg, - uint off, - 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. */ -} - -/**************************************************************************** -REMARKS: -Return the amount of available memory. -****************************************************************************/ -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. */ - *physical = *total = 0; -} - -/**************************************************************************** -REMARKS: -Allocate a block of locked, physical memory for DMA operations. -****************************************************************************/ -void * PMAPI PM_allocLockedMem( - uint size, - ulong *physAddr, - 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. */ - return NULL; -} - -/**************************************************************************** -REMARKS: -Free a block of locked physical memory. -****************************************************************************/ -void PMAPI PM_freeLockedMem( - void *p, - uint size, - ibool contiguous) -{ - /* TODO: Free a memory block allocated with PM_allocLockedMem. */ -} - -/**************************************************************************** -REMARKS: -Call the VBE/Core software interrupt to change display banks. -****************************************************************************/ -void PMAPI PM_setBankA( - int bank) -{ - 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. */ - regs.x.ax = 0x4F05; - regs.x.bx = 0x0000; - regs.x.dx = bank; - PM_int86(0x10,®s,®s); -} - -/**************************************************************************** -REMARKS: -Call the VBE/Core software interrupt to change display banks. -****************************************************************************/ -void PMAPI PM_setBankAB( - int bank) -{ - 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. */ - regs.x.ax = 0x4F05; - regs.x.bx = 0x0000; - regs.x.dx = bank; - PM_int86(0x10,®s,®s); - regs.x.ax = 0x4F05; - regs.x.bx = 0x0001; - regs.x.dx = bank; - PM_int86(0x10,®s,®s); -} - -/**************************************************************************** -REMARKS: -Call the VBE/Core software interrupt to change display start address. -****************************************************************************/ -void PMAPI PM_setCRTStart( - int x, - int y, - int waitVRT) -{ - 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. */ - regs.x.ax = 0x4F07; - regs.x.bx = waitVRT; - regs.x.cx = x; - regs.x.dx = y; - PM_int86(0x10,®s,®s); -} - -/**************************************************************************** -REMARKS: -Enable write combining for the memory region. -****************************************************************************/ -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). */ - return false; -} - -/**************************************************************************** -REMARKS: -Execute the POST on the secondary BIOS for a controller. -****************************************************************************/ -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. */ - return false; -} - -/**************************************************************************** -REMARKS: -Load an OS specific shared library or DLL. If the OS does not support -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. */ - (void)szDLLName; - return NULL; -} - -/**************************************************************************** -REMARKS: -Get the address of a named procedure from a shared library. -****************************************************************************/ -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. */ - (void)hModule; - (void)szProcName; - return NULL; -} - -/**************************************************************************** -REMARKS: -Unload a shared library. -****************************************************************************/ -void PMAPI PM_freeLibrary( - PM_MODULE hModule) -{ - /* TODO: This function free a previously loaded native shared library. */ - (void)hModule; -} - -/**************************************************************************** -REMARKS: -Enable requested I/O privledge level (usually only to set to a value of -3, and then restore it back again). If the OS is protected this function -must be implemented in order to enable I/O port access for ring 3 -applications. The function should return the IOPL level active before -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). */ - return level; -} - -/**************************************************************************** -REMARKS: -Function to find the first file matching a search criteria in a directory. -****************************************************************************/ -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. */ - (void)filename; - (void)findData; - return PM_FILE_INVALID; -} - -/**************************************************************************** -REMARKS: -Function to find the next file matching a search criteria in a directory. -****************************************************************************/ -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. */ - (void)handle; - (void)findData; - return false; -} - -/**************************************************************************** -REMARKS: -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. */ - (void)handle; -} - -/**************************************************************************** -REMARKS: -Function to determine if a drive is a valid drive or not. Under Unix this -function will return false for anything except a value of 3 (considered -the root drive, and equivalent to C: for non-Unix systems). The drive -numbering is: - - 1 - Drive A: - 2 - Drive B: - 3 - Drive C: - etc - -****************************************************************************/ -ibool PMAPI PM_driveValid( - char drive) -{ - if (drive == 3) - return true; - return false; -} - -/**************************************************************************** -REMARKS: -Function to get the current working directory for the specififed drive. -Under Unix this will always return the current working directory regardless -of what the value of 'drive' is. -****************************************************************************/ -void PMAPI PM_getdcwd( - int drive, - char *dir, - int len) -{ - (void)drive; - getcwd(dir,len); -} - -/**************************************************************************** -REMARKS: -Function to change the file attributes for a specific file. -****************************************************************************/ -void PMAPI PM_setFileAttr( - const char *filename, - uint attrib) -{ - /* TODO: Set the file attributes for a file */ - (void)filename; - (void)attrib; -} - -/**************************************************************************** -REMARKS: -Function to create a directory. -****************************************************************************/ -ibool PMAPI PM_mkdir( - const char *filename) -{ - return mkdir(filename) == 0; -} - -/**************************************************************************** -REMARKS: -Function to remove a directory. -****************************************************************************/ -ibool PMAPI PM_rmdir( - const char *filename) -{ - return rmdir(filename) == 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/stub/vflat.c b/board/MAI/bios_emulator/scitech/src/pm/stub/vflat.c deleted file mode 100644 index 579ef2c95c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/stub/vflat.c +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Dummy module; no virtual framebuffer for this OS -* -****************************************************************************/ - -#include "pmapi.h" - -ibool PMAPI VF_available(void) -{ - return false; -} - -void * PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) -{ - baseAddr = baseAddr; - bankSize = bankSize; - codeLen = codeLen; - bankFunc = bankFunc; - return NULL; -} - -void PMAPI VF_exit(void) -{ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/stub/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/stub/ztimer.c deleted file mode 100644 index 820e292390..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/stub/ztimer.c +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: *** TODO: ADD YOUR OS ENVIRONMENT NAME HERE *** -* -* Description: OS specific implementation for the Zen Timer functions. -* -****************************************************************************/ - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Initialise the Zen Timer module internals. -****************************************************************************/ -void __ZTimerInit(void) -{ - /* TODO: Do any specific internal initialisation in here */ -} - -/**************************************************************************** -REMARKS: -Start the Zen Timer counting. -****************************************************************************/ -static void __LZTimerOn( - LZTimerObject *tm) -{ - /* TODO: Start the Zen Timer counting. This should be a macro if */ - /* possible. */ -} - -/**************************************************************************** -REMARKS: -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. */ - return 0; -} - -/**************************************************************************** -REMARKS: -Stop the Zen Timer counting. -****************************************************************************/ -static void __LZTimerOff( - LZTimerObject *tm) -{ - /* TODO: Stop the timer counting. Should be a macro if possible. */ -} - -/**************************************************************************** -REMARKS: -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. */ - return 0; -} - -/**************************************************************************** -REMARKS: -Define the resolution of the long period timer as microseconds per timer tick. -****************************************************************************/ -#define ULZTIMER_RESOLUTION 1 - -/**************************************************************************** -REMARKS: -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. */ -} - -/**************************************************************************** -REMARKS: -Compute the elapsed time from the BIOS timer tick. Note that we check to see -whether a midnight boundary has passed, and if so adjust the finish time to -account for this. We cannot detect if more that one midnight boundary has -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/tests/altbrk.c b/board/MAI/bios_emulator/scitech/src/pm/tests/altbrk.c deleted file mode 100644 index ba90262745..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/altbrk.c +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to check the ability to install a C based -* control C/break interrupt handler. Note that this -* alternate version does not work with all extenders. -* -* Functions tested: PM_installAltBreakHandler() -* PM_restoreBreakHandler() -* -* -****************************************************************************/ - -#include -#include -#include "pmapi.h" - -volatile int breakHit = false; -volatile int ctrlCHit = false; - -#pragma off (check_stack) /* No stack checking under Watcom */ - -void PMAPI breakHandler(uint bHit) -{ - if (bHit) - breakHit = true; - else - 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; - } - - 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"); - } - - 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 deleted file mode 100644 index e13730758e..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/altcrit.c +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to check the ability to install a C based -* critical error handler. -* -* Functions tested: PM_installCriticalHandler() -* PM_criticalError() -* PM_restoreCriticalHandler() -* -* -****************************************************************************/ - -#include -#include -#include "pmapi.h" - -volatile uint criticalError = false; -volatile uint axValue; -volatile uint diValue; - -#pragma off (check_stack) /* No stack checking under Watcom */ - -uint PMAPI criticalHandler(uint axVal,uint diVal) -{ - criticalError = true; - axValue = axVal; - diValue = diVal; - return 3; /* Tell MS-DOS to fail the operation */ -} - -int main(void) -{ - FILE *f; - - 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; - } - - 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); - } - else - 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 deleted file mode 100644 index 5fa3382483..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/biosptr.c +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to check the ability to manipulate the -* BIOS data area from protected mode using the PM -* library. Compile and link with the appropriate command -* line for your DOS extender. -* -* Functions tested: PM_getBIOSSelector() -* PM_getLong() -* PM_getByte() -* PM_getWord() -* -****************************************************************************/ - -#include -#include -#include "pmapi.h" - -/* Macros to obtain values from the BIOS data area */ - -#define TICKS() PM_getLong(bios+0x6C) -#define KB_STAT PM_getByte(bios+0x17) -#define KB_HEAD PM_getWord(bios+0x1A) -#define KB_TAIL PM_getWord(bios+0x1C) - -/* Macros for working with the keyboard buffer */ - -#define KB_HIT() (KB_HEAD != KB_TAIL) -#define CTRL() (KB_STAT & 4) -#define SHIFT() (KB_STAT & 2) -#define ESC 0x1B - -/* Selector for BIOS data area */ - -uchar *bios; - -int main(void) -{ - int c,done = 0; - - 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; - } - - 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; - } - } - - 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 deleted file mode 100644 index 15d503c0de..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/block.c +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Test program for the PM_blockUntilTimeout function. -* -****************************************************************************/ - -#include -#include "pmapi.h" - -#define DELAY_MSECS 1100 -#define LOOPS 5 - -/*-------------------------- Implementation -------------------------------*/ - -/* The following routine takes a long count in microseconds and outputs - * a string representing the count in seconds. It could be modified to - * return a pointer to a static string representing the count rather - * than printing it out. - */ - -void ReportTime(ulong count) -{ - ulong secs; - - secs = count / 1000000L; - count = count - secs * 1000000L; - printf("Time taken: %lu.%06lu seconds\n",secs,count); -} - -int main(void) -{ - int i; - - printf("Detecting processor information ..."); - fflush(stdout); - printf("\n\n%s\n", CPU_getProcessorName()); - ZTimerInit(); - LZTimerOn(); - for (i = 0; i < LOOPS; i++) { - 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 deleted file mode 100644 index 10b644656e..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/brk.c +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to check the ability to install a C based -* control C/break interrupt handler. -* -* Functions tested: PM_installBreakHandler() -* PM_ctrlCHit() -* PM_ctrlBreakHit() -* PM_restoreBreakHandler() -* -* -****************************************************************************/ - -#include -#include -#include "pmapi.h" - -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; - } - - 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"); - } - - 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 deleted file mode 100644 index 4d37cab465..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/callreal.c +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to check the ability to call a real mode -* procedure. We simply copy a terribly simple assembly -* language routine into a real mode block that we allocate, -* and then attempt to call the routine and verify that it -* was successful. -* -* Functions tested: PM_allocRealSeg() -* PM_freeRealSeg() -* PM_callRealMode() -* -****************************************************************************/ - -#include -#include -#include -#include "pmapi.h" - -/* Block of real mode code we will eventually call */ - -static unsigned char realModeCode[] = { - 0x93, /* xchg ax,bx */ - 0x87, 0xCA, /* xchg cx,dx */ - 0xCB /* retf */ - }; - -int main(void) -{ - RMREGS regs; - RMSREGS sregs; - uchar *p; - unsigned r_seg,r_off; - - 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; - } - - /* 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); - } - - /* Copy the real mode code */ - memcpy(p,realModeCode,sizeof(realModeCode)); - - /* Now call the real mode code */ - regs.x.ax = 1; - regs.x.bx = 2; - regs.x.cx = 3; - regs.x.dx = 4; - regs.x.si = 5; - regs.x.di = 6; - sregs.es = 7; - 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); - } - else - printf("Real mode call succeeded!\n"); - - /* Free the memory we allocated */ - PM_freeRealSeg(p); - return 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/checks.c b/board/MAI/bios_emulator/scitech/src/pm/tests/checks.c deleted file mode 100644 index 5933ac9f73..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/checks.c +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Main module for building checked builds of products with -* assertions and trace code. -* -****************************************************************************/ - -#include "scitech.h" -#include -#include -#include -#ifdef __WINDOWS__ -#define WIN32_LEAN_AND_MEAN -#define STRICT -#include -#endif - -#ifdef CHECKED - -/*---------------------------- Global variables ---------------------------*/ - -#define LOGFILE "\\scitech.log" - -void (*_CHK_fail)(int fatal,const char *msg,const char *cond,const char *file,int line) = _CHK_defaultFail; - -/*---------------------------- Implementation -----------------------------*/ - -/**************************************************************************** -DESCRIPTION: -Handles fatal error and warning conditions for checked builds. - -HEADER: -scitech.h - -REMARKS: -This function is called whenever an inline check or warning fails in any -of the SciTech runtime libraries. Warning conditions simply cause the -condition to be logged to the log file and send to the system debugger -under Window. Fatal error conditions do all of the above, and then -terminate the program with a fatal error conditions. - -This handler may be overriden by the user code if necessary to replace it -with a different handler (the MGL for instance overrides this and replaces -it with a handler that does an MGL_exit() before terminating the application -so that it will clean up correctly. -****************************************************************************/ -void _CHK_defaultFail( - int fatal, - const char *msg, - const char *cond, - const char *file, - int line) -{ - char buf[256]; - FILE *log = fopen(LOGFILE, "at+"); - - sprintf(buf,msg,cond,file,line); - if (log) { - fputs(buf,log); - fflush(log); - fclose(log); -#ifdef __WINDOWS__ - OutputDebugStr(buf); -#endif - } - if (fatal) { -#ifdef __WINDOWS__ - MessageBox(NULL, buf,"Fatal Error!",MB_ICONEXCLAMATION); -#else - fputs(buf,stderr); -#endif - 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 deleted file mode 100644 index 30e5dd30df..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/cpu.c +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Test program for the CPU detection code. -* -****************************************************************************/ - -#include "ztimer.h" -#include "pmapi.h" -#include -#include - -/*----------------------------- Implementation ----------------------------*/ - -int main(void) -{ - printf("Detecting processor information ..."); - fflush(stdout); - printf("\n\n%s\n", CPU_getProcessorName()); - if (CPU_haveRDTSC()) - 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 deleted file mode 100644 index 60f1251a5d..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/critical.c +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to check the ability to install a C based -* critical error handler. -* -* Functions tested: PM_installAltCriticalHandler() -* PM_restoreCriticalHandler() -* -* -****************************************************************************/ - -#include -#include -#include "pmapi.h" - -int main(void) -{ - FILE *f; - int axcode,dicode; - - 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; - } - - 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); - } - 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 deleted file mode 100644 index 06c2180ceb..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/getch.c +++ /dev/null @@ -1,501 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Test program to test out the cross platform event handling -* library. -* -****************************************************************************/ - -#include -#include -#include -#include "pmapi.h" -#include "event.h" - -/* Translation table for key codes */ - -typedef struct { - int code; - char *name; - } KeyEntry; - -KeyEntry ASCIICodes[] = { - {ASCII_ctrlA ,"ASCII_ctrlA"}, - {ASCII_ctrlB ,"ASCII_ctrlB"}, - {ASCII_ctrlC ,"ASCII_ctrlC"}, - {ASCII_ctrlD ,"ASCII_ctrlD"}, - {ASCII_ctrlE ,"ASCII_ctrlE"}, - {ASCII_ctrlF ,"ASCII_ctrlF"}, - {ASCII_ctrlG ,"ASCII_ctrlG"}, - {ASCII_backspace ,"ASCII_backspace"}, - {ASCII_ctrlH ,"ASCII_ctrlH"}, - {ASCII_tab ,"ASCII_tab"}, - {ASCII_ctrlI ,"ASCII_ctrlI"}, - {ASCII_ctrlJ ,"ASCII_ctrlJ"}, - {ASCII_ctrlK ,"ASCII_ctrlK"}, - {ASCII_ctrlL ,"ASCII_ctrlL"}, - {ASCII_enter ,"ASCII_enter"}, - {ASCII_ctrlM ,"ASCII_ctrlM"}, - {ASCII_ctrlN ,"ASCII_ctrlN"}, - {ASCII_ctrlO ,"ASCII_ctrlO"}, - {ASCII_ctrlP ,"ASCII_ctrlP"}, - {ASCII_ctrlQ ,"ASCII_ctrlQ"}, - {ASCII_ctrlR ,"ASCII_ctrlR"}, - {ASCII_ctrlS ,"ASCII_ctrlS"}, - {ASCII_ctrlT ,"ASCII_ctrlT"}, - {ASCII_ctrlU ,"ASCII_ctrlU"}, - {ASCII_ctrlV ,"ASCII_ctrlV"}, - {ASCII_ctrlW ,"ASCII_ctrlW"}, - {ASCII_ctrlX ,"ASCII_ctrlX"}, - {ASCII_ctrlY ,"ASCII_ctrlY"}, - {ASCII_ctrlZ ,"ASCII_ctrlZ"}, - {ASCII_esc ,"ASCII_esc"}, - {ASCII_space ,"ASCII_space"}, - {ASCII_exclamation ,"ASCII_exclamation"}, - {ASCII_quote ,"ASCII_quote"}, - {ASCII_pound ,"ASCII_pound"}, - {ASCII_dollar ,"ASCII_dollar"}, - {ASCII_percent ,"ASCII_percent"}, - {ASCII_ampersand ,"ASCII_ampersand"}, - {ASCII_apostrophe ,"ASCII_apostrophe"}, - {ASCII_leftBrace ,"ASCII_leftBrace"}, - {ASCII_rightBrace ,"ASCII_rightBrace"}, - {ASCII_times ,"ASCII_times"}, - {ASCII_plus ,"ASCII_plus"}, - {ASCII_comma ,"ASCII_comma"}, - {ASCII_minus ,"ASCII_minus"}, - {ASCII_period ,"ASCII_period"}, - {ASCII_divide ,"ASCII_divide"}, - {ASCII_0 ,"ASCII_0"}, - {ASCII_1 ,"ASCII_1"}, - {ASCII_2 ,"ASCII_2"}, - {ASCII_3 ,"ASCII_3"}, - {ASCII_4 ,"ASCII_4"}, - {ASCII_5 ,"ASCII_5"}, - {ASCII_6 ,"ASCII_6"}, - {ASCII_7 ,"ASCII_7"}, - {ASCII_8 ,"ASCII_8"}, - {ASCII_9 ,"ASCII_9"}, - {ASCII_colon ,"ASCII_colon"}, - {ASCII_semicolon ,"ASCII_semicolon"}, - {ASCII_lessThan ,"ASCII_lessThan"}, - {ASCII_equals ,"ASCII_equals"}, - {ASCII_greaterThan ,"ASCII_greaterThan"}, - {ASCII_question ,"ASCII_question"}, - {ASCII_at ,"ASCII_at"}, - {ASCII_A ,"ASCII_A"}, - {ASCII_B ,"ASCII_B"}, - {ASCII_C ,"ASCII_C"}, - {ASCII_D ,"ASCII_D"}, - {ASCII_E ,"ASCII_E"}, - {ASCII_F ,"ASCII_F"}, - {ASCII_G ,"ASCII_G"}, - {ASCII_H ,"ASCII_H"}, - {ASCII_I ,"ASCII_I"}, - {ASCII_J ,"ASCII_J"}, - {ASCII_K ,"ASCII_K"}, - {ASCII_L ,"ASCII_L"}, - {ASCII_M ,"ASCII_M"}, - {ASCII_N ,"ASCII_N"}, - {ASCII_O ,"ASCII_O"}, - {ASCII_P ,"ASCII_P"}, - {ASCII_Q ,"ASCII_Q"}, - {ASCII_R ,"ASCII_R"}, - {ASCII_S ,"ASCII_S"}, - {ASCII_T ,"ASCII_T"}, - {ASCII_U ,"ASCII_U"}, - {ASCII_V ,"ASCII_V"}, - {ASCII_W ,"ASCII_W"}, - {ASCII_X ,"ASCII_X"}, - {ASCII_Y ,"ASCII_Y"}, - {ASCII_Z ,"ASCII_Z"}, - {ASCII_leftSquareBrace ,"ASCII_leftSquareBrace"}, - {ASCII_backSlash ,"ASCII_backSlash"}, - {ASCII_rightSquareBrace ,"ASCII_rightSquareBrace"}, - {ASCII_caret ,"ASCII_caret"}, - {ASCII_underscore ,"ASCII_underscore"}, - {ASCII_leftApostrophe ,"ASCII_leftApostrophe"}, - {ASCII_a ,"ASCII_a"}, - {ASCII_b ,"ASCII_b"}, - {ASCII_c ,"ASCII_c"}, - {ASCII_d ,"ASCII_d"}, - {ASCII_e ,"ASCII_e"}, - {ASCII_f ,"ASCII_f"}, - {ASCII_g ,"ASCII_g"}, - {ASCII_h ,"ASCII_h"}, - {ASCII_i ,"ASCII_i"}, - {ASCII_j ,"ASCII_j"}, - {ASCII_k ,"ASCII_k"}, - {ASCII_l ,"ASCII_l"}, - {ASCII_m ,"ASCII_m"}, - {ASCII_n ,"ASCII_n"}, - {ASCII_o ,"ASCII_o"}, - {ASCII_p ,"ASCII_p"}, - {ASCII_q ,"ASCII_q"}, - {ASCII_r ,"ASCII_r"}, - {ASCII_s ,"ASCII_s"}, - {ASCII_t ,"ASCII_t"}, - {ASCII_u ,"ASCII_u"}, - {ASCII_v ,"ASCII_v"}, - {ASCII_w ,"ASCII_w"}, - {ASCII_x ,"ASCII_x"}, - {ASCII_y ,"ASCII_y"}, - {ASCII_z ,"ASCII_z"}, - {ASCII_leftCurlyBrace ,"ASCII_leftCurlyBrace"}, - {ASCII_verticalBar ,"ASCII_verticalBar"}, - {ASCII_rightCurlyBrace ,"ASCII_rightCurlyBrace"}, - {ASCII_tilde ,"ASCII_tilde"}, - {0 ,"ASCII_unknown"}, - }; - -KeyEntry ScanCodes[] = { - {KB_padEnter ,"KB_padEnter"}, - {KB_padMinus ,"KB_padMinus"}, - {KB_padPlus ,"KB_padPlus"}, - {KB_padTimes ,"KB_padTimes"}, - {KB_padDivide ,"KB_padDivide"}, - {KB_padLeft ,"KB_padLeft"}, - {KB_padRight ,"KB_padRight"}, - {KB_padUp ,"KB_padUp"}, - {KB_padDown ,"KB_padDown"}, - {KB_padInsert ,"KB_padInsert"}, - {KB_padDelete ,"KB_padDelete"}, - {KB_padHome ,"KB_padHome"}, - {KB_padEnd ,"KB_padEnd"}, - {KB_padPageUp ,"KB_padPageUp"}, - {KB_padPageDown ,"KB_padPageDown"}, - {KB_padCenter ,"KB_padCenter"}, - {KB_F1 ,"KB_F1"}, - {KB_F2 ,"KB_F2"}, - {KB_F3 ,"KB_F3"}, - {KB_F4 ,"KB_F4"}, - {KB_F5 ,"KB_F5"}, - {KB_F6 ,"KB_F6"}, - {KB_F7 ,"KB_F7"}, - {KB_F8 ,"KB_F8"}, - {KB_F9 ,"KB_F9"}, - {KB_F10 ,"KB_F10"}, - {KB_F11 ,"KB_F11"}, - {KB_F12 ,"KB_F12"}, - {KB_left ,"KB_left"}, - {KB_right ,"KB_right"}, - {KB_up ,"KB_up"}, - {KB_down ,"KB_down"}, - {KB_insert ,"KB_insert"}, - {KB_delete ,"KB_delete"}, - {KB_home ,"KB_home"}, - {KB_end ,"KB_end"}, - {KB_pageUp ,"KB_pageUp"}, - {KB_pageDown ,"KB_pageDown"}, - {KB_capsLock ,"KB_capsLock"}, - {KB_numLock ,"KB_numLock"}, - {KB_scrollLock ,"KB_scrollLock"}, - {KB_leftShift ,"KB_leftShift"}, - {KB_rightShift ,"KB_rightShift"}, - {KB_leftCtrl ,"KB_leftCtrl"}, - {KB_rightCtrl ,"KB_rightCtrl"}, - {KB_leftAlt ,"KB_leftAlt"}, - {KB_rightAlt ,"KB_rightAlt"}, - {KB_leftWindows ,"KB_leftWindows"}, - {KB_rightWindows ,"KB_rightWindows"}, - {KB_menu ,"KB_menu"}, - {KB_sysReq ,"KB_sysReq"}, - {KB_esc ,"KB_esc"}, - {KB_1 ,"KB_1"}, - {KB_2 ,"KB_2"}, - {KB_3 ,"KB_3"}, - {KB_4 ,"KB_4"}, - {KB_5 ,"KB_5"}, - {KB_6 ,"KB_6"}, - {KB_7 ,"KB_7"}, - {KB_8 ,"KB_8"}, - {KB_9 ,"KB_9"}, - {KB_0 ,"KB_0"}, - {KB_minus ,"KB_minus"}, - {KB_equals ,"KB_equals"}, - {KB_backSlash ,"KB_backSlash"}, - {KB_backspace ,"KB_backspace"}, - {KB_tab ,"KB_tab"}, - {KB_Q ,"KB_Q"}, - {KB_W ,"KB_W"}, - {KB_E ,"KB_E"}, - {KB_R ,"KB_R"}, - {KB_T ,"KB_T"}, - {KB_Y ,"KB_Y"}, - {KB_U ,"KB_U"}, - {KB_I ,"KB_I"}, - {KB_O ,"KB_O"}, - {KB_P ,"KB_P"}, - {KB_leftSquareBrace ,"KB_leftSquareBrace"}, - {KB_rightSquareBrace ,"KB_rightSquareBrace"}, - {KB_enter ,"KB_enter"}, - {KB_A ,"KB_A"}, - {KB_S ,"KB_S"}, - {KB_D ,"KB_D"}, - {KB_F ,"KB_F"}, - {KB_G ,"KB_G"}, - {KB_H ,"KB_H"}, - {KB_J ,"KB_J"}, - {KB_K ,"KB_K"}, - {KB_L ,"KB_L"}, - {KB_semicolon ,"KB_semicolon"}, - {KB_apostrophe ,"KB_apostrophe"}, - {KB_Z ,"KB_Z"}, - {KB_X ,"KB_X"}, - {KB_C ,"KB_C"}, - {KB_V ,"KB_V"}, - {KB_B ,"KB_B"}, - {KB_N ,"KB_N"}, - {KB_M ,"KB_M"}, - {KB_comma ,"KB_comma"}, - {KB_period ,"KB_period"}, - {KB_divide ,"KB_divide"}, - {KB_space ,"KB_space"}, - {KB_tilde ,"KB_tilde"}, - {0 ,"KB_unknown"}, - }; - -/**************************************************************************** -PARAMETERS: -x - X coordinate of the mouse cursor position (screen coordinates) -y - Y coordinate of the mouse cursor position (screen coordinates) - -REMARKS: -This gets called periodically to move the mouse. It will get called when -the mouse may not have actually moved, so check if it has before redrawing -it. -****************************************************************************/ -void EVTAPI moveMouse( - int x, - int y) -{ -} - -/**************************************************************************** -PARAMETERS: -code - Code to translate -keys - Table of translation key values to look up - -REMARKS: -Simple function to look up the printable name for the keyboard code. -****************************************************************************/ -KeyEntry *FindKey( - int code, - KeyEntry *keys) -{ - KeyEntry *key; - - for (key = keys; key->code != 0; key++) { - if (key->code == code) - break; - } - return key; -} - -/**************************************************************************** -PARAMETERS: -evt - Event to display modifiers for - -REMARKS: -Function to display shift modifiers flags -****************************************************************************/ -void DisplayModifiers( - event_t *evt) -{ - if (evt->modifiers & EVT_LEFTBUT) - printf(", LBUT"); - if (evt->modifiers & EVT_RIGHTBUT) - printf(", RBUT"); - if (evt->modifiers & EVT_MIDDLEBUT) - 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_CTRLSTATE) { - 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"); - } -} - -/**************************************************************************** -PARAMETERS: -msg - Message to display for type of event -evt - Event to display - -REMARKS: -Function to display the status of the keyboard event to the screen. -****************************************************************************/ -void DisplayKey( - char *msg, - event_t *evt) -{ - KeyEntry *ascii,*scan; - char ch = EVT_asciiCode(evt->message); - - 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 : ' '); - DisplayModifiers(evt); - printf("\n"); -} - -/**************************************************************************** -PARAMETERS: -msg - Message to display for type of event -evt - Event to display - -REMARKS: -Function to display the status of the mouse event to the screen. -****************************************************************************/ -void DisplayMouse( - char *msg, - event_t *evt) -{ - printf("%s: ", msg); - if (evt->message & EVT_LEFTBMASK) - printf("LEFT "); - if (evt->message & EVT_RIGHTBMASK) - printf("RIGHT "); - if (evt->message & EVT_MIDDLEBMASK) - 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("\n"); -} - -/**************************************************************************** -PARAMETERS: -msg - Message to display for type of event -evt - Event to display - -REMARKS: -Function to display the status of the joystick event to the screen. -****************************************************************************/ -void DisplayJoy( - char *msg, - 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'); -} - -/**************************************************************************** -REMARKS: -Joystick calibration routine -****************************************************************************/ -void CalibrateJoy(void) -{ - event_t evt; - if(EVT_joyIsPresent()){ - printf("Joystick Calibration\nMove the joystick to the upper left corner and press any button.\n"); - EVT_halt(&evt, EVT_JOYCLICK); - EVT_halt(&evt, EVT_JOYCLICK); - EVT_joySetUpperLeft(); - printf("Move the joystick to the lower right corner and press any button.\n"); - EVT_halt(&evt, EVT_JOYCLICK); - EVT_halt(&evt, EVT_JOYCLICK); - EVT_joySetLowerRight(); - printf("Move the joystick to center position and press any button.\n"); - EVT_halt(&evt, EVT_JOYCLICK); - EVT_halt(&evt, EVT_JOYCLICK); - EVT_joySetCenter(); - printf("Joystick calibrated\n"); - } -} - -/**************************************************************************** -REMARKS: -Main program entry point -****************************************************************************/ -int main(void) -{ - event_t evt; - ibool done = false; - PM_HWND hwndConsole; - - hwndConsole = PM_openConsole(0,0,0,0,0,true); - EVT_init(&moveMouse); - 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_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 deleted file mode 100644 index 67ad2456e8..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/isvesa.c +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to check the ability to allocate real mode -* memory and to call real mode interrupt handlers such as -* the VESA VBE BIOS from protected mode. Compile and link -* with the appropriate command line for your DOS extender. -* -* Functions tested: PM_getVESABuf() -* PM_mapRealPointer() -* PM_int86x() -* -****************************************************************************/ - -#include -#include -#include -#include "pmapi.h" - -/* SuperVGA information block */ - -#pragma pack(1) - -typedef struct { - char VESASignature[4]; /* 'VESA' 4 byte signature */ - short VESAVersion; /* VBE version number */ - ulong OEMStringPtr; /* Far pointer to OEM string */ - ulong Capabilities; /* Capabilities of video card */ - ulong VideoModePtr; /* Far pointer to supported modes */ - short TotalMemory; /* Number of 64kb memory blocks */ - char reserved[236]; /* Pad to 256 byte block size */ - } VgaInfoBlock; - -#pragma pack() - -int main(void) -{ - RMREGS regs; - RMSREGS sregs; - VgaInfoBlock vgaInfo; - ushort *mode; - uint vgLen; - uchar *vgPtr; - unsigned r_vgseg,r_vgoff; - - 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; - } - - /* Allocate a 256 byte block of real memory for communicating with - * the VESA BIOS. - */ - if ((vgPtr = PM_getVESABuf(&vgLen,&r_vgseg,&r_vgoff)) == NULL) { - printf("Unable to allocate VESA memory buffer!\n"); - exit(1); - } - - /* Call the VESA VBE to see if it is out there */ - regs.x.ax = 0x4F00; - regs.x.di = r_vgoff; - sregs.es = r_vgseg; - memcpy(vgPtr,"VBE2",4); - PM_int86x(0x10, ®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++; - } - } - else - 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 deleted file mode 100644 index dba88853c2..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/key.c +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to check the ability to install a C based -* keyboard interrupt handler. -* -* Functions tested: PM_setKeyHandler() -* PM_chainPrevKey() -* PM_restoreKeyHandler() -* -* -****************************************************************************/ - -#include -#include -#include "pmapi.h" - -volatile long count = 0; - -#pragma off (check_stack) /* No stack checking under Watcom */ - -void PMAPI keyHandler(void) -{ - count++; - PM_chainPrevKey(); /* Chain to previous handler */ -} - -int main(void) -{ - int ch; - PM_lockHandle lh; - - 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; - } - - /* 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 - * function is well less than 100 bytes (and an entire 4k page will - * need to be locked by the server anyway). - */ - PM_lockCodePages((__codePtr)keyHandler,100,&lh); - PM_lockDataPages((void*)&count,sizeof(count),&lh); - PM_installBreakHandler(); /* We *DONT* want Ctrl-Breaks! */ - PM_setKeyHandler(keyHandler); - 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); - } - - PM_restoreKeyHandler(); - PM_restoreBreakHandler(); - PM_unlockDataPages((void*)&count,sizeof(count),&lh); - PM_unlockCodePages((__codePtr)keyHandler,100,&lh); - printf("\n\nKeyboard handler was called %ld times\n", count); - return 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/key15.c b/board/MAI/bios_emulator/scitech/src/pm/tests/key15.c deleted file mode 100644 index b0b94be9c2..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/key15.c +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to check the ability to install a C based -* keyboard Int 15h interrupt handler. This is an alternate -* way to intercept scancodes from the keyboard by hooking -* the Int 15h keyboard intercept callout. -* -* Functions tested: PM_setKey15Handler() -* PM_restoreKey15Handler() -* -* -****************************************************************************/ - -#include -#include -#include "pmapi.h" - -volatile long count = 0; -volatile short lastScanCode = 0; - -#pragma off (check_stack) /* No stack checking under Watcom */ - -short PMAPI keyHandler(short scanCode) -{ - count++; - lastScanCode = scanCode; - return scanCode; /* Let BIOS process as normal */ -} - -int main(void) -{ - int ch; - PM_lockHandle lh; - - 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; - } - - /* 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 - * function is well less than 100 bytes (and an entire 4k page will - * need to be locked by the server anyway). - */ - PM_lockCodePages((__codePtr)keyHandler,100,&lh); - PM_lockDataPages((void*)&count,sizeof(count),&lh); - PM_installBreakHandler(); /* We *DONT* want Ctrl-Break's! */ - PM_setKey15Handler(keyHandler); - 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); - } - - PM_restoreKey15Handler(); - PM_restoreBreakHandler(); - PM_unlockDataPages((void*)&count,sizeof(count),&lh); - PM_unlockCodePages((__codePtr)keyHandler,100,&lh); - printf("\n\nKeyboard handler was called %ld times\n", count); - printf("Last scan code %04X\n", lastScanCode); - return 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/memtest.c b/board/MAI/bios_emulator/scitech/src/pm/tests/memtest.c deleted file mode 100644 index a2c655b4a3..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/memtest.c +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to determine just how much memory can be -* allocated with the compiler in use. Compile and link -* with the appropriate command line for your DOS extender. -* -* Functions tested: PM_malloc() -* PM_availableMemory() -* -* -****************************************************************************/ - -#include -#include -#include -#include -#include "pmapi.h" - -#ifdef __16BIT__ -#define MAXALLOC 64 -#else -#define MAXALLOC 2000 -#endif - -int main(void) -{ - int i; - ulong allocs; - ulong physical,total; - char *p,*pa[MAXALLOC]; - - 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; - } - - printf("Memory available at start:\n"); - PM_availableMemory(&physical,&total); - printf(" Physical memory: %ld Kb\n", physical / 1024); - 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; - } - - printf("\n\nAllocated total of %lu bytes\n", 10 * (allocs << 10)); - - printf("\nMemory available at end:\n"); - PM_availableMemory(&physical,&total); - printf(" Physical memory: %ld Kb\n", physical / 1024); - printf(" Total (including virtual): %ld Kb\n", total / 1024); - - for (i = allocs-1; i >= 0; 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"); - PM_availableMemory(&physical,&total); - printf(" Physical memory: %ld Kb\n", physical / 1024); - printf(" Total (including virtual): %ld Kb\n", total / 1024); - - return 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/mouse.c b/board/MAI/bios_emulator/scitech/src/pm/tests/mouse.c deleted file mode 100644 index 2765a0d1cc..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/mouse.c +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to check the ability to install an assembly -* language mouse interrupt handler. We use assembly language -* as it must be a far function and should swap to a local -* 32 bit stack if it is going to call any C based code (which -* we do in this example). -* -* Functions tested: PM_installMouseHandler() -* PM_int86() -* -* -****************************************************************************/ - -#include -#include -#include "pmapi.h" - -volatile long count = 0; - -#pragma off (check_stack) /* No stack checking under Watcom */ - -void PMAPI mouseHandler( - uint mask, - uint butstate, - int x, - int y, - int mickeyX, - int mickeyY) -{ - mask = mask; /* We dont use any of the parameters */ - butstate = butstate; - x = x; - y = y; - mickeyX = mickeyX; - mickeyY = mickeyY; - count++; -} - -int main(void) -{ - RMREGS regs; - PM_lockHandle lh; - - 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; - } - - 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); - } - - /* 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 - * function is well less than 100 bytes (and an entire 4k page will - * need to be locked by the server anyway). - */ - 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("Mouse handler installed - Hit any key to exit\n"); - PM_getch(); - - PM_restoreMouseHandler(); - PM_unlockDataPages((void*)&count,sizeof(count),&lh); - PM_unlockCodePages((__codePtr)mouseHandler,100,&lh); - printf("Mouse handler was called %ld times\n", count); - return 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/restore.c b/board/MAI/bios_emulator/scitech/src/pm/tests/restore.c deleted file mode 100644 index e00be750e3..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/restore.c +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Linux/QNX -* -* Description: Program to restore the console state state from a previously -* saved state if the program crashed while the console -* was in graphics mode. -* -****************************************************************************/ - -#include -#include -#include "pmapi.h" - -void setVideoMode(int mode) -{ - RMREGS r; - - r.x.ax = mode; - PM_int86(0x10, &r, &r); -} - -int main(void) -{ - PM_HWND hwndConsole; - 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; - } - fread(&stateSize,1,sizeof(stateSize),f); - if (stateSize != PM_getConsoleStateSize()) { - 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; - } - fread(stateBuf,1,stateSize,f); - fclose(f); - - /* Open the console */ - hwndConsole = PM_openConsole(0,0,0,0,0,true); - - /* Forcibly set 80x25 text mode using the BIOS */ - setVideoMode(0x3); - - /* Restore the previous console state */ - PM_restoreConsoleState(stateBuf,0); - PM_closeConsole(hwndConsole); - PM_free(stateBuf); - 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 deleted file mode 100644 index acef9226a8..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/rtc.c +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to check the ability to install a C based -* Real Time Clock interrupt handler. -* -* Functions tested: PM_setRealTimeClockHandler() -* PM_restoreRealTimeClockHandler() -* -****************************************************************************/ - -#include -#include -#include "pmapi.h" - -volatile long count = 0; - -#pragma off (check_stack) /* No stack checking under Watcom */ - -void PMAPI RTCHandler(void) -{ - count++; -} - -int main(void) -{ - long oldCount; - PM_lockHandle lh; - - 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; - } - - /* 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 - * function is well less than 100 bytes (and an entire 4k page will - * need to be locked by the server anyway). - */ - PM_lockCodePages((__codePtr)RTCHandler,100,&lh); - PM_lockDataPages((void*)&count,sizeof(count),&lh); - PM_installBreakHandler(); /* We *DONT* want Ctrl-Breaks! */ - PM_setRealTimeClockHandler(RTCHandler,128); - 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; - } - } - - PM_restoreRealTimeClockHandler(); - PM_restoreBreakHandler(); - PM_unlockDataPages((void*)&count,sizeof(count),&lh); - PM_unlockCodePages((__codePtr)RTCHandler,100,&lh); - printf("RealTimeClock handler was called %ld times\n", count); - return 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/save.c b/board/MAI/bios_emulator/scitech/src/pm/tests/save.c deleted file mode 100644 index f7324562f8..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/save.c +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Linux/QNX -* -* Description: Program to save the console state state so that it can -* be later restored if the program crashed while the console -* was in graphics mode. -* -****************************************************************************/ - -#include -#include -#include "pmapi.h" - -int main(void) -{ - PM_HWND hwndConsole; - ulong stateSize; - void *stateBuf; - FILE *f; - - /* Allocate a buffer to save console state and save the state */ - 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_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"); - else { - 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 deleted file mode 100644 index be275e1a04..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/showpci.c +++ /dev/null @@ -1,253 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to test the PCI library functions. -* -****************************************************************************/ - -#include "pmapi.h" -#include "pcilib.h" -#include -#include -#include -#include - -/*------------------------- Global Variables ------------------------------*/ - -static int NumPCI = -1; -static PCIDeviceInfo *PCI; -static int *BridgeIndex; -static int *DeviceIndex; -static int NumBridges; -static PCIDeviceInfo *AGPBridge = NULL; -static int NumDevices; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -REMARKS: -Enumerates the PCI bus and dumps the PCI configuration information to the -log file. -****************************************************************************/ -static void EnumeratePCI(void) -{ - int i,index; - PCIDeviceInfo *info; - - printf("Displaying enumeration of PCI bus (%d devices, %d display devices)\n", - NumPCI, NumDevices); - for (index = 0; index < NumDevices; 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("\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("\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("\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("\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); - } - printf("\n"); -} - -/**************************************************************************** -RETURNS: -Number of display devices found. - -REMARKS: -This function enumerates the number of available display devices on the -PCI bus, and returns the number found. -****************************************************************************/ -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 (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; - - /* 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; - } - } - } - } - } - - /* Enumerate all PCI and bridge devices to standard output */ - EnumeratePCI(); - } - return NumDevices; -} - -int main(void) -{ - /* Enumerate all PCI devices */ - PM_init(); - if (PCI_enumerateDevices() < 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 deleted file mode 100644 index 378725ebe6..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/tick.c +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to check the ability to install a C based -* timer interrupt handler. -* -* Functions tested: PM_setTimerHandler() -* PM_chainPrevTimer(); -* PM_restoreTimerHandler() -* -****************************************************************************/ - -#include -#include -#include "pmapi.h" - -volatile long count = 0; - -#pragma off (check_stack) /* No stack checking under Watcom */ - -void PMAPI timerHandler(void) -{ - PM_chainPrevTimer(); /* Chain to previous handler */ - count++; -} - -int main(void) -{ - long oldCount; - PM_lockHandle lh; - - 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; - } - - /* 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 - * function is well less than 100 bytes (and an entire 4k page will - * need to be locked by the server anyway). - */ - PM_lockCodePages((__codePtr)timerHandler,100,&lh); - PM_lockDataPages((void*)&count,sizeof(count),&lh); - PM_installBreakHandler(); /* We *DONT* want Ctrl-Breaks! */ - PM_setTimerHandler(timerHandler); - 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; - } - } - - PM_restoreTimerHandler(); - PM_restoreBreakHandler(); - PM_unlockDataPages((void*)&count,sizeof(count),&lh); - PM_unlockCodePages((__codePtr)timerHandler,100,&lh); - printf("Timer handler was called %ld times\n", count); - return 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/timerc.c b/board/MAI/bios_emulator/scitech/src/pm/tests/timerc.c deleted file mode 100644 index 7fa77b77b8..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/timerc.c +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Test program for the Zen Timer Library. -* -****************************************************************************/ - -#include -#include "pmapi.h" -#include "ztimer.h" - -#define DELAY_SECS 10 - -/*-------------------------- Implementation -------------------------------*/ - -/* The following routine takes a long count in microseconds and outputs - * a string representing the count in seconds. It could be modified to - * return a pointer to a static string representing the count rather - * than printing it out. - */ - -void ReportTime(ulong count) -{ - ulong secs; - - secs = count / 1000000L; - count = count - secs * 1000000L; - printf("Time taken: %lu.%06lu seconds\n",secs,count); -} - -int i,j; /* NON register variables! */ - -int main(void) -{ -#ifdef LONG_TEST - ulong start,finish; -#endif - - printf("Processor type: %d %ld MHz\n", CPU_getProcessorType(), CPU_getProcessorSpeed(true)); - - ZTimerInit(); - - /* Test the long period Zen Timer (we don't check for overflow coz - * it would take tooooo long!) - */ - - LZTimerOn(); - for (j = 0; j < 10; j++) - for (i = 0; i < 20000; i++) - i = i; - LZTimerOff(); - ReportTime(LZTimerCount()); - - /* Test the ultra long period Zen Timer */ -#ifdef LONG_TEST - start = ULZReadTime(); - delay(DELAY_SECS * 1000); - finish = ULZReadTime(); - printf("Delay of %d secs took %d 1/10ths of a second\n", - DELAY_SECS,ULZElapsedTime(start,finish)); -#endif - - return 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/timercpp.cpp b/board/MAI/bios_emulator/scitech/src/pm/tests/timercpp.cpp deleted file mode 100644 index 1258a4bb10..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/timercpp.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: C++ 3.0 -* Environment: Any -* -* Description: Test program for the Zen Timer Library C++ interface. -* -****************************************************************************/ - -#include -#include "pmapi.h" -#include "ztimer.h" - -/*-------------------------- Implementation -------------------------------*/ - -int i,j,k; /* NON register variables! */ - -void dummy() {} - -int main(void) -{ - LZTimer ltimer; - ULZTimer ultimer; - - ZTimerInit(); - - /* Test the long period Zen Timer (we don't check for overflow coz - * it would take tooooo long!) - */ - - cout << endl; - ultimer.restart(); - ltimer.start(); - for (j = 0; j < 10; j++) - for (i = 0; i < 20000; i++) - dummy(); - ltimer.stop(); - ultimer.stop(); - cout << "LCount: " << ltimer.count() << endl; - cout << "Time: " << ltimer << " secs\n"; - cout << "ULCount: " << ultimer.count() << endl; - cout << "ULTime: " << ultimer << " secs\n"; - - cout << endl << "Timing ... \n"; - ultimer.restart(); - ltimer.restart(); - for (j = 0; j < 200; j++) - for (i = 0; i < 20000; i++) - dummy(); - ltimer.stop(); - ultimer.stop(); - cout << "LCount: " << ltimer.count() << endl; - cout << "Time: " << ltimer << " secs\n"; - cout << "ULCount: " << ultimer.count() << endl; - cout << "ULTime: " << ultimer << " secs\n"; - - /* Test the lap function of the long period Zen Timer */ - - cout << endl << "Timing ... \n"; - ultimer.restart(); - ltimer.restart(); - for (j = 0; j < 20; j++) { - for (k = 0; k < 10; k++) - for (i = 0; i < 20000; i++) - dummy(); - cout << "lap: " << ltimer.lap() << endl; - } - ltimer.stop(); - ultimer.stop(); - cout << "LCount: " << ltimer.count() << endl; - cout << "Time: " << ltimer << " secs\n"; - cout << "ULCount: " << ultimer.count() << endl; - cout << "ULTime: " << ultimer << " secs\n"; - -#ifdef LONG_TEST - /* Test the ultra long period Zen Timer */ - - ultimer.start(); - delay(DELAY_SECS * 1000); - ultimer.stop(); - cout << "Delay of " << DELAY_SECS << " secs took " << ultimer.count() - << " 1/10ths of a second\n"; - cout << "Time: " << ultimer << " secs\n"; -#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 deleted file mode 100644 index f0c7bd6311..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/uswc.c +++ /dev/null @@ -1,311 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: any -* -* Description: Simple test program to test the write combine functions. -* -* Note that this program should never be used in a production -* environment, because write combining needs to be handled -* with more intimate knowledge of the display hardware than -* you can obtain by simply examining the PCI configuration -* space. -* -****************************************************************************/ - -#include "pmapi.h" -#include "pcilib.h" -#include -#include -#include -#include - -/*------------------------- Global Variables ------------------------------*/ - -static int NumPCI = -1; -static PCIDeviceInfo *PCI; -static int *BridgeIndex; -static int *DeviceIndex; -static int NumBridges; -static PCIDeviceInfo *AGPBridge = NULL; -static int NumDevices; - -/*-------------------------- Implementation -------------------------------*/ - -/**************************************************************************** -RETURNS: -Number of display devices found. - -REMARKS: -This function enumerates the number of available display devices on the -PCI bus, and returns the number found. -****************************************************************************/ -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 (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; - - /* 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; - } - } - } - } - } - } - return NumDevices; -} - -/**************************************************************************** -REMARKS: -Enumerates useful information about attached display devices. -****************************************************************************/ -static void ShowDisplayDevices(void) -{ - int i,index; - - printf("Displaying enumeration of %d PCI display devices\n", NumDevices); - 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); - } - printf("\n"); -} - -/**************************************************************************** -REMARKS: -Dumps the value for a write combine region to the display. -****************************************************************************/ -static char *DecodeWCType( - uint type) -{ - static char *names[] = { - "UNCACHABLE", - "WRCOMB", - "UNKNOWN", - "UNKNOWN", - "WRTHROUGH", - "WRPROT", - "WRBACK", - }; - if (type <= PM_MTRR_MAX) - return names[type]; - return "UNKNOWN"; -} - -/**************************************************************************** -REMARKS: -Dumps the value for a write combine region to the display. -****************************************************************************/ -static void PMAPI EnumWriteCombine( - ulong base, - ulong length, - uint type) -{ - printf("%08lX %-10ld %s\n", base, length / 1024, DecodeWCType(type)); -} - -/**************************************************************************** -PARAMETERS: -err - Error to log - -REMARKS: -Function to log an error message if the MTRR write combining attempt failed. -****************************************************************************/ -static void LogMTRRError( - int err) -{ - if (err == PM_MTRR_ERR_OK) - 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; - } - exit(-1); -} - -/**************************************************************************** -REMARKS: -Shows all write combine regions. -****************************************************************************/ -static void ShowWriteCombine(void) -{ - printf("Base Length(KB) Type\n"); - LogMTRRError(PM_enumWriteCombine(EnumWriteCombine)); - printf("\n"); -} - -/**************************************************************************** -REMARKS: -Dumps the value for a write combine region to the display. -****************************************************************************/ -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)); - } - } - printf("\n"); - ShowDisplayDevices(); - ShowWriteCombine(); -} - -/**************************************************************************** -REMARKS: -Dumps the value for a write combine region to the display. -****************************************************************************/ -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)); - } - } - printf("\n"); - ShowDisplayDevices(); - ShowWriteCombine(); -} - -int main(int argc,char *argv[]) -{ - PM_init(); - if (PCI_enumerateDevices() < 1) { - printf("No PCI display devices found!\n"); - return -1; - } - if (argc < 2) { - printf("usage: uswc [-show -on -off]\n\n"); - ShowDisplayDevices(); - return -1; - } - if (stricmp(argv[1],"-show") == 0) - ShowWriteCombine(); - else if (stricmp(argv[1],"-on") == 0) - EnableWriteCombine(); - else if (stricmp(argv[1],"-off") == 0) - 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 deleted file mode 100644 index b7e3bb7846..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/vftest.c +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Filename: $Workfile$ -* Version: $Revision: 1.1 $ -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to test the VFlat virtual framebuffer functions. -* -* Functions tested: VF_available() -* VF_init() -* VF_exit() -* -* $Date: 2002/10/02 15:35:21 $ $Author: hfrieden $ -* -****************************************************************************/ - -#include -#include -#include "pmapi.h" - -uchar code[] = { - 0xC3, /* ret */ - }; - -int main(void) -{ - void *vfBuffer; - - 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; - } - - if (!VF_available()) { - 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); - } - 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 deleted file mode 100644 index 92adcddd49..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/video.c +++ /dev/null @@ -1,199 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: any -* -* Description: Test program to check the ability to generate real mode -* interrupts and to be able to obtain direct access to the -* video memory from protected mode. Compile and link with -* the appropriate command line for your DOS extender. -* -* Functions tested: PM_getBIOSSelector() -* PM_mapPhysicalAddr() -* PM_int86() -* -****************************************************************************/ - -#include -#include -#include "pmapi.h" - -uchar *bios; /* Pointer to BIOS data area */ -uchar *videoPtr; /* Pointer to VGA framebuffer */ -void *stateBuf; /* Console state save buffer */ - -/* Routine to return the current video mode number */ - -int getVideoMode(void) -{ - return PM_getByte(bios+0x49); -} - -/* Routine to set a specified video mode */ - -void setVideoMode(int mode) -{ - RMREGS r; - - r.x.ax = mode; - PM_int86(0x10, &r, &r); -} - -/* Routine to clear a rectangular region on the display by calling the - * video BIOS. - */ - -void clearScreen(int startx, int starty, int endx, int endy, unsigned char attr) -{ - RMREGS r; - - r.x.ax = 0x0600; - r.h.bh = attr; - r.h.cl = startx; - r.h.ch = starty; - r.h.dl = endx; - r.h.dh = endy; - PM_int86(0x10, &r, &r); -} - -/* Routine to fill a rectangular region on the display using direct - * video writes. - */ - -#define SCREEN(x,y) (videoPtr + ((y) * 160) + ((x) << 1)) - -void fill(int startx, int starty, int endx, int endy, unsigned char c, - unsigned char attr) -{ - unsigned char *v; - int x,y; - - for (y = starty; y <= endy; y++) { - v = SCREEN(startx,y); - for (x = startx; x <= endx; x++) { - *v++ = c; - *v++ = attr; - } - } -} - -/* Routine to display a single character using direct video writes */ - -void writeChar(int x, int y, unsigned char c, unsigned char attr) -{ - unsigned char *v = SCREEN(x,y); - *v++ = c; - *v = attr; -} - -/* Routine to draw a border around a rectangular area using direct video - * writes. - */ - -static unsigned char border_chars[] = { - 186, 205, 201, 187, 200, 188 /* double box chars */ - }; - -void border(int startx, int starty, int endx, int endy, unsigned char attr) -{ - unsigned char *v; - unsigned char *b; - int i; - - b = border_chars; - - for (i = starty+1; i < endy; i++) { - 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; - } - for (i = startx+1, v = SCREEN(startx+1, endy); i < endx; i++) { - *v++ = *b; - *v++ = attr; - } - b++; - writeChar(startx, starty, *b++, attr); - writeChar(endx, starty, *b++, attr); - writeChar(startx, endy, *b++, attr); - writeChar(endx, endy, *b++, attr); -} - -int main(void) -{ - int orgMode; - PM_HWND hwndConsole; - - 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; - } - - 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"); - PM_getch(); - - /* 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); - } - 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); - } - - /* Draw some text on the screen */ - fill(0, 0, 79, 24, 176, 0x1E); - border(0, 0, 79, 24, 0x1F); - PM_getch(); - clearScreen(0, 0, 79, 24, 0x7); - - /* Restore the console state on exit */ - PM_restoreConsoleState(stateBuf,0); - PM_free(stateBuf); - PM_closeConsole(hwndConsole); - - /* Display useful status information */ - printf("\n"); - printf("Original Video Mode = %02X\n", orgMode); - printf("BIOS Pointer = %08X\n", (int)bios); - printf("Video Memory = %08X\n", (int)videoPtr); - return 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/vdd/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/vdd/cpuinfo.c deleted file mode 100644 index 3460b72456..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/vdd/cpuinfo.c +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit OS/2 VDD -* -* Description: VDD specific code for the CPU detection module. -* -****************************************************************************/ - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Do nothing for VDD's -****************************************************************************/ -#define SetMaxThreadPriority() 0 - -/**************************************************************************** -REMARKS: -Do nothing for VDD's -****************************************************************************/ -#define RestoreThreadPriority(i) (void)(i) - -/**************************************************************************** -REMARKS: -Initialise the counter and return the frequency of the counter. -****************************************************************************/ -static void GetCounterFrequency( - CPU_largeInteger *freq) -{ - freq->low = 100000; - freq->high = 0; -} - -/**************************************************************************** -REMARKS: -Read the counter and return the counter value. -****************************************************************************/ -#define GetCounter(t) \ -{ \ - ULONG count; \ - count = VDHQuerySysValue(0, VDHGSV_MSECSBOOT); \ - (t)->low = count * 100; \ - (t)->high = 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 deleted file mode 100644 index 93742de914..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/vdd/fileio.c +++ /dev/null @@ -1,359 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit OS/2 VDD -* -* Description: C library compatible I/O functions for use within a VDD. -* -****************************************************************************/ - -#include "pmapi.h" -#include "vddfile.h" - -/*------------------------ Main Code Implementation -----------------------*/ - -#define EOF -1 - -/* NB: none of the file VDHs are available during the DOS session */ -/* initialzation context! */ - -/* Macros for Open/Close APIs to allow using this module in both VDDs and */ -/* normal OS/2 applications. Unfortunately VDHRead/Write/Seek don't map to */ -/* their Dos* counterparts so cleanly. */ -#ifdef __OS2_VDD__ -#define _OS2Open VDHOpen -#define _OS2Close VDHClose -#else -#define _OS2Open DosOpen -#define _OS2Close DosClose -#endif - -/**************************************************************************** -REMARKS: -VDD implementation of the ANSI C fopen function. -****************************************************************************/ -FILE * fopen( - const char *filename, - const char *mode) -{ - FILE *f = PM_malloc(sizeof(FILE)); - long oldpos; - ULONG rc, ulAction; - 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; - - 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 - - if (mode[0] == 'a') - fseek(f,0,2); - } - return f; -} - -/**************************************************************************** -REMARKS: -VDD implementation of the ANSI C fread function. Note that unlike Windows VxDs, -OS/2 VDDs are not limited to 64K reads or writes. -****************************************************************************/ -size_t fread( - void *ptr, - size_t size, - size_t n, - FILE *f) -{ - char *buf = ptr; - int bytes,readbytes,totalbytes = 0; - - /* 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; - } - else - 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; - } - return totalbytes / size; -} - -/**************************************************************************** -REMARKS: -VDD implementation of the ANSI C fwrite function. -****************************************************************************/ -size_t fwrite( - void *ptr, - size_t size, - size_t n, - FILE *f) -{ - char *buf = ptr; - int bytes,writtenbytes,totalbytes = 0; - - /* Flush anything already in the buffer */ - if (!f->writemode) - return 0; - fflush(f); - bytes = size * n; - #ifdef __OS2_VDD__ - writtenbytes = VDHWrite((HFILE)f->handle, buf, bytes); - #else - DosWrite((HFILE)f->handle, buf, bytes, &writtenbytes); - #endif - totalbytes += writtenbytes; - f->offset += writtenbytes; - if (f->offset > f->filesize) - f->filesize = f->offset; - return totalbytes / size; -} - -/**************************************************************************** -REMARKS: -VxD implementation of the ANSI C fflush function. -****************************************************************************/ -int fflush( - FILE *f) -{ - ULONG bytes; - - /* 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; - } - return 0; -} - -/**************************************************************************** -REMARKS: -VDD implementation of the ANSI C fseek function. -****************************************************************************/ -int fseek( - FILE *f, - long int offset, - int whence) -{ - fflush(f); - - if (whence == 0) - f->offset = offset; - else if (whence == 1) - f->offset += offset; - else if (whence == 2) - f->offset = f->filesize + offset; - - #ifdef __OS2_VDD__ - VDHSeek((HFILE)f->handle, f->offset, VDHSK_ABSOLUTE); - #else - DosSetFilePtr((HFILE)f->handle, f->offset, FILE_BEGIN, NULL); - #endif - - return 0; -} - -/**************************************************************************** -REMARKS: -VDD implementation of the ANSI C ftell function. -****************************************************************************/ -long ftell( - FILE *f) -{ - long offset; - - offset = (f->curp - f->startp); - offset += f->offset; - return offset; -} - -/**************************************************************************** -REMARKS: -VDD implementation of the ANSI C feof function. -****************************************************************************/ -int feof( - FILE *f) -{ - return (f->offset == f->filesize); -} - -/**************************************************************************** -REMARKS: -Read a single character from the input file buffer, including translation -of the character in text transation modes. -****************************************************************************/ -static int __getc( - FILE *f) -{ - int c; - - if (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; - } - } - return c; -} - -/**************************************************************************** -REMARKS: -Write a single character from to input buffer, including translation of the -character in text transation modes. -****************************************************************************/ -static int __putc(int c,FILE *f) -{ - int count = 1; - if (f->text && c == '\n') { - __putc('\r',f); - count = 2; - } - if (f->curp == f->endp) - fflush(f); - *f->curp++ = c; - return count; -} - -/**************************************************************************** -REMARKS: -VxD implementation of the ANSI C fgets function. -****************************************************************************/ -char *fgets( - char *s, - int n, - FILE *f) -{ - int c = 0; - char *cs; - - cs = s; - while (--n > 0 && (c = __getc(f)) != EOF) { - *cs++ = c; - if (c == '\n') - break; - } - if (c == EOF && cs == s) - return NULL; - *cs = '\0'; - return s; -} - -/**************************************************************************** -REMARKS: -VxD implementation of the ANSI C fputs function. -****************************************************************************/ -int fputs( - const char *s, - FILE *f) -{ - int r = 0; - int c; - - while ((c = *s++) != 0) - r = __putc(c, f); - return r; -} - -/**************************************************************************** -REMARKS: -VxD implementation of the ANSI C fclose function. -****************************************************************************/ -int fclose( - FILE *f) -{ - fflush(f); - _OS2Close((HFILE)f->handle); - PM_free(f); - return 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/vdd/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/vdd/oshdr.h deleted file mode 100644 index 03286bdc2e..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/vdd/oshdr.h +++ /dev/null @@ -1,29 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit OS/2 VDD -* -* Description: Include file to include all OS specific header files. -* -****************************************************************************/ diff --git a/board/MAI/bios_emulator/scitech/src/pm/vdd/pm.c b/board/MAI/bios_emulator/scitech/src/pm/vdd/pm.c deleted file mode 100644 index 6688babd0d..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/vdd/pm.c +++ /dev/null @@ -1,1050 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit OS/2 VDD -* -* Description: Implementation for the OS Portability Manager Library, which -* contains functions to implement OS specific services in a -* generic, cross platform API. Porting the OS Portability -* Manager library is the first step to porting any SciTech -* products to a new platform. -* -****************************************************************************/ - -#include "pmapi.h" -#include "drvlib/os/os.h" -#include "sdd/sddhelp.h" -#include "mtrr.h" - -#define TRACE(a) - -/*--------------------------- Global variables ----------------------------*/ - -#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. */ -typedef struct { - void *linear; - ulong global; - ulong length; - int npages; - } memshared; - -typedef struct { - ulong physical; - ulong linear; - ulong length; - int npages; - ibool isCached; - } mmapping; - -static int numMappings = 0; -static memshared shared[MAX_MEMORY_MAPPINGS] = {0}; -static mmapping maps[MAX_MEMORY_MAPPINGS]; -ibool _PM_haveBIOS = TRUE; -char _PM_cntPath[PM_MAX_PATH] = ""; /* there just isn't any */ -uchar *_PM_rmBufAddr = NULL; -ushort _VARAPI PM_savedDS = 0; /* why can't I use the underscore prefix? */ - -HVDHSEM hevFarCallRet = NULL; -HVDHSEM hevIRet = NULL; -HHOOK hhookUserReturnHook = NULL; -HHOOK hhookUserIRetHook = NULL; - -static void (PMAPIP fatalErrorCleanup)(void) = NULL; - -/*----------------------------- Implementation ----------------------------*/ - -/* Functions to read and write CMOS registers */ - -ulong PMAPI _PM_getPDB(void); -uchar PMAPI _PM_readCMOS(int index); -void PMAPI _PM_writeCMOS(int index,uchar value); - -VOID HOOKENTRY UserReturnHook(PVOID pRefData, PCRF pcrf); -VOID HOOKENTRY UserIRetHook(PVOID pRefData, PCRF pcrf); - -void PMAPI PM_init(void) -{ - MTRR_init(); - - /* 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! */ - } -} - -/* Do some cleaning up */ -void PMAPI PM_exit(void) -{ - /* Note: Hooks allocated during or after VDM creation are deallocated automatically */ - if (hevIRet != NULL) - VDHDestroySem(hevIRet); - - if (hevFarCallRet != NULL) - VDHDestroySem(hevFarCallRet); -} - -ibool PMAPI PM_haveBIOSAccess(void) -{ return _PM_haveBIOS; } - -long PMAPI PM_getOSType(void) -{ return /*_OS_OS2VDD*/ _OS_OS2; } /*FIX!! */ - -int PMAPI PM_getModeType(void) -{ return PM_386; } - -void PMAPI PM_backslash(char *s) -{ - uint pos = strlen(s); - if (s[pos-1] != '\\') { - s[pos] = '\\'; - s[pos+1] = '\0'; - } -} - -void PMAPI PM_setFatalErrorCleanup( - void (PMAPIP cleanup)(void)) -{ - fatalErrorCleanup = cleanup; -} - -void PMAPI PM_fatalError(const char *msg) -{ - if (fatalErrorCleanup) - fatalErrorCleanup(); -/* Fatal_Error_Handler(msg,0); TODO: implement somehow! */ -} - -/**************************************************************************** -PARAMETERS: -len - Place to store the length of the buffer -rseg - Place to store the real mode segment of the buffer -roff - Place to store the real mode offset of the buffer - -REMARKS: -This function returns the address and length of the global VESA transfer -buffer. -****************************************************************************/ -void * PMAPI PM_getVESABuf( - uint *len, - uint *rseg, - uint *roff) -{ - if (_PM_rmBufAddr) { - *len = 0; /*VESA_BUF_SIZE; */ - *rseg = (ulong)(_PM_rmBufAddr) >> 4; - *roff = (ulong)(_PM_rmBufAddr) & 0xF; - return _PM_rmBufAddr; - } - return NULL; -} - -int PMAPI PM_int386(int intno, PMREGS *in, PMREGS *out) -{ - /* Unused in VDDs */ - return 0; -} - -char * PMAPI PM_getCurrentPath(char *path,int maxLen) -{ - strncpy(path, _PM_cntPath, maxLen); - path[maxLen - 1] = 0; - return path; -} - -char PMAPI PM_getBootDrive(void) -{ - ulong boot = 3; - boot = VDHQuerySysValue(0, VDHGSV_BOOTDRV); - return (char)('a' + boot - 1); -} - -const char * PMAPI PM_getVBEAFPath(void) -{ - static char path[CCHMAXPATH]; - strcpy(path,"x:\\"); - path[0] = PM_getBootDrive(); - return path; -} - -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; -} - -const char * PMAPI PM_getNucleusConfigPath(void) -{ - static char path[256]; - strcpy(path,PM_getNucleusPath()); - PM_backslash(path); - strcat(path,"config"); - return path; -} - -const char * PMAPI PM_getUniqueID(void) -{ return PM_getMachineName(); } - -const char * PMAPI PM_getMachineName(void) -{ - return "Unknown"; -} - -int PMAPI PM_kbhit(void) -{ return 1; } - -int PMAPI PM_getch(void) -{ return 0; } - -PM_HWND PMAPI PM_openConsole(PM_HWND hwndUser,int device,int xRes,int yRes,int bpp,ibool fullScreen) -{ - /* Unused in VDDs */ - return NULL; -} - -int PMAPI PM_getConsoleStateSize(void) -{ - /* Unused in VDDs */ - return 1; -} - -void PMAPI PM_saveConsoleState(void *stateBuf,PM_HWND hwndConsole) -{ - /* Unused in VDDs */ -} - -void PMAPI PM_setSuspendAppCallback(int (_ASMAPIP saveState)(int flags)) -{ - /* Unused in VDDs */ -} - -void PMAPI PM_restoreConsoleState(const void *stateBuf,PM_HWND hwndConsole) -{ - /* Unused in VDDs */ -} - -void PMAPI PM_closeConsole(PM_HWND hwndConsole) -{ - /* Unused in VDDs */ -} - -void PMAPI PM_setOSCursorLocation(int x,int y) -{ - uchar *_biosPtr = PM_getBIOSPointer(); - PM_setByte(_biosPtr+0x50,x); - PM_setByte(_biosPtr+0x51,y); -} - -void PMAPI PM_setOSScreenWidth(int width,int height) -{ - uchar *_biosPtr = PM_getBIOSPointer(); - PM_setByte(_biosPtr+0x4A,width); - PM_setByte(_biosPtr+0x84,height-1); -} - -/**************************************************************************** -REMARKS: -Allocate a block of shared memory. For OS/2 VDD we allocate shared memory -as locked, global memory that is accessible from any memory context -(including interrupt time context), which allows us to load our important -data structure and code such that we can access it directly from a ring -0 interrupt context. -****************************************************************************/ -void * PMAPI PM_mallocShared(long size) -{ - ULONG nPages = (size + 0xFFF) >> 12; - int i; - - /* 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 (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; - } - return NULL; -} - -/**************************************************************************** -REMARKS: -Free a block of shared memory -****************************************************************************/ -void PMAPI PM_freeShared(void *p) -{ - int i; - - /* 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; - } - } -} - -void * PMAPI PM_mapToProcess(void *base,ulong limit) -{ return (void*)base; } - -ibool PMAPI PM_doBIOSPOST( - ushort axVal, - ulong BIOSPhysAddr, - void *mappedBIOS, - ulong BIOSLen) -{ - /* TODO: Figure out how to do this */ - return false; -} - -void * PMAPI PM_getBIOSPointer(void) -{ return (void*)0x400; } - -void * PMAPI PM_getA0000Pointer(void) -{ return PM_mapPhysicalAddr(0xA0000,0xFFFF,true); } - -/**************************************************************************** -PARAMETERS: -base - Physical base address of the memory to maps in -limit - Limit of physical memory to region to maps in - -RETURNS: -Linear address of the newly mapped memory. - -REMARKS: -Maps a physical memory range to a linear memory range. -****************************************************************************/ -ulong MapPhysicalToLinear( - ulong base, - ulong limit, - int *npages) -{ - ulong linear,length = limit+1; - int i,ppage,flags; -#if 0 - 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; - } - if ((linear = (ulong)PageReserve(PR_SYSTEM,*npages,flags)) == (ulong)-1) - return 0; - if (!PageCommitPhys(linear >> 12,*npages,ppage,PC_INCR | PC_USER | PC_WRITEABLE)) - return 0; -#endif - return linear + (base & 0xFFF); -} - -/**************************************************************************** -PARAMETERS: -base - Physical base address of the memory to map in -limit - Limit of physical memory to region to map in -isCached - True if the memory should be cached, false if not - -RETURNS: -Linear address of the newly mapped memory. - -REMARKS: -This function maps physical memory to linear memory, which can then be used -to create a selector or used directly from 32-bit protected mode programs. -This is better than DPMI 0x800, since it allows you to maps physical -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. -****************************************************************************/ -void * PMAPI PM_mapPhysicalAddr( - ulong base, - ulong limit, - ibool isCached) -{ - ulong linear,length = limit+1; - int i,npages; - ulong PDB,*pPDB; - - /* 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) - return (void*)maps[i].linear; - } - if (numMappings == MAX_MEMORY_MAPPINGS) - 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 - * to have problems mapping memory in the 1Mb physical address space. - * Hence we use PageReserve and PageCommitPhys. - */ - if ((linear = MapPhysicalToLinear(base,limit,&npages)) == 0) - return NULL; - maps[numMappings].physical = base; - maps[numMappings].length = length; - maps[numMappings].linear = linear; - maps[numMappings].npages = npages; - maps[numMappings].isCached = isCached; - numMappings++; - -#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); - } - } -#endif - return (void*)linear; -} - -void PMAPI PM_freePhysicalAddr(void *ptr,ulong limit) -{ - /* We never free the mappings */ -} - -void PMAPI PM_sleep(ulong milliseconds) -{ - /* We never sleep in a VDD */ -} - -int PMAPI PM_getCOMPort(int port) -{ - /* 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; - } - 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. */ - switch (port) { - 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; -} - -void PMAPI _PM_freeMemoryMappings(void) -{ - int i; -/* for (i = 0; i < numMappings; i++) */ -/* PageFree(maps[i].linear,PR_STATIC); */ -} - -void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) -{ return (void*)MK_PHYS(r_seg,r_off); } - -void * PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off) -{ return NULL; } - -void PMAPI PM_freeRealSeg(void *mem) -{ } - -void PMAPI DPMI_int86(int intno, DPMI_regs *regs) -{ - /* Unsed in VDDs */ -} - -/**************************************************************************** -REMARKS: -Load the V86 registers in the client state, and save the original state -before loading the registers. -****************************************************************************/ -static void LoadV86Registers( - PCRF saveRegs, - RMREGS *in, - RMSREGS *sregs) -{ - PCRF pcrf; /* current client register frame */ - - /* 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 */ - - 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; - pcrf->crf_esi = in->e.esi; - pcrf->crf_edi = in->e.edi; - pcrf->crf_es = sregs->es; - pcrf->crf_ds = sregs->ds; - -} - -/**************************************************************************** -REMARKS: -Read the V86 registers from the client state and restore the original state. -****************************************************************************/ -static void ReadV86Registers( - PCRF saveRegs, - RMREGS *out, - RMSREGS *sregs) -{ - PCRF pcrf; /* current client register frame */ - - /* get pointer to registers */ - pcrf = (PCRF)VDHQuerySysValue(CURRENT_VDM, VDHLSV_PCRF); - - /* read new register values */ - out->e.eax = pcrf->crf_eax; - out->e.ebx = pcrf->crf_ebx; - out->e.ecx = pcrf->crf_ecx; - out->e.edx = pcrf->crf_edx; - out->e.esi = pcrf->crf_esi; - out->e.edi = pcrf->crf_edi; - sregs->es = pcrf->crf_es; - sregs->ds = pcrf->crf_ds; - - /* restore original client registers */ - *pcrf = *saveRegs; -} - -/**************************************************************************** -REMARKS: Used for far calls into V86 code -****************************************************************************/ -VOID HOOKENTRY UserReturnHook( - PVOID pRefData, - PCRF pcrf ) -{ - VDHPostEventSem(hevFarCallRet); -} - -/**************************************************************************** -REMARKS: Used for calling BIOS interrupts -****************************************************************************/ -VOID HOOKENTRY UserIRetHook( - PVOID pRefData, - PCRF pcrf ) -{ - VDHPostEventSem(hevIRet); -} - -/**************************************************************************** -REMARKS: -Call a V86 real mode function with the specified register values -loaded before the call. The call returns with a far ret. -Must be called from within a DOS session context! -****************************************************************************/ -void PMAPI PM_callRealMode( - uint seg, - uint off, - RMREGS *regs, - RMSREGS *sregs) -{ - CRF saveRegs; - FPFN fnAddress; - ULONG rc; - - TRACE("SDDHELP: Entering PM_callRealMode()\n"); - LoadV86Registers(SSToDS(&saveRegs),regs,sregs); - - /* set up return hook for call */ - rc = VDHArmReturnHook(hhookUserReturnHook, VDHARH_CSEIP_HOOK); - - VDHResetEventSem(hevFarCallRet); - - /* 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 */ - rc = VDHWaitEventSem(hevFarCallRet, SEM_INDEFINITE_WAIT); - - ReadV86Registers(SSToDS(&saveRegs),regs,sregs); - TRACE("SDDHELP: Exiting PM_callRealMode()\n"); -} - -/**************************************************************************** -REMARKS: -Issue a V86 real mode interrupt with the specified register values -loaded before the interrupt. -Must be called from within a DOS session context! -****************************************************************************/ -int PMAPI PM_int86( - int intno, - RMREGS *in, - RMREGS *out) -{ - RMSREGS sregs = {0}; - CRF saveRegs; - ushort oldDisable; - ULONG rc; - - memset(SSToDS(&sregs), 0, sizeof(sregs)); - -#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; - } -#endif - - LoadV86Registers(SSToDS(&saveRegs), in, SSToDS(&sregs)); - - VDHResetEventSem(hevIRet); - rc = VDHPushInt(intno); - - /* 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); */ - - ReadV86Registers(SSToDS(&saveRegs), out, SSToDS(&sregs)); - -#if 0 - /* Re-enable pass-up to our VDD handler if previously enabled */ - if (disableTSRFlag) - *disableTSRFlag = oldDisable; -#endif - - TRACE("SDDHELP: Exiting PM_int86()\n"); - return out->x.ax; - -} - -/**************************************************************************** -REMARKS: -Issue a V86 real mode interrupt with the specified register values -loaded before the interrupt. -****************************************************************************/ -int PMAPI PM_int86x( - int intno, - RMREGS *in, - RMREGS *out, - RMSREGS *sregs) -{ - CRF saveRegs; - ushort oldDisable; - ULONG rc; - -#if 0 - /* Disable pass-up to our VxD handler so we directly call BIOS */ - TRACE("SDDHELP: Entering PM_int86x()\n"); - if (disableTSRFlag) { - oldDisable = *disableTSRFlag; - *disableTSRFlag = 0; - } -#endif - LoadV86Registers(SSToDS(&saveRegs), in, sregs); - - VDHResetEventSem(hevIRet); - rc = VDHPushInt(intno); - - /* 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); */ - - ReadV86Registers(SSToDS(&saveRegs), out, sregs); - -#if 0 - /* Re-enable pass-up to our VxD handler if previously enabled */ - if (disableTSRFlag) - *disableTSRFlag = oldDisable; -#endif - - TRACE("SDDHELP: Exiting PM_int86x()\n"); - return out->x.ax; -} - -void PMAPI PM_availableMemory(ulong *physical,ulong *total) -{ *physical = *total = 0; } - -/**************************************************************************** -REMARKS: -Allocates a block of locked physical memory. -****************************************************************************/ -void * PMAPI PM_allocLockedMem( - uint size, - ulong *physAddr, - ibool contiguous, - ibool below16M) -{ - ULONG flags = VDHAP_SYSTEM; - ULONG nPages = (size + 0xFFF) >> 12; - - flags |= (physAddr != NULL) ? VDHAP_PHYSICAL : VDHAP_FIXED; - - return VDHAllocPages(physAddr, nPages, VDHAP_SYSTEM | VDHAP_PHYSICAL); -} - -/**************************************************************************** -REMARKS: -Frees a block of locked physical memory. -****************************************************************************/ -void PMAPI PM_freeLockedMem( - void *p, - uint size, - ibool contiguous) -{ - if (p) - VDHFreePages((PVOID)p); -} - -/**************************************************************************** -REMARKS: -Lock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - ULONG lockHandle; - - /* TODO: the lock handle is essential for the unlock operation!! */ - lockHandle = VDHLockMem(p, len, 0, (PVOID)VDHLM_NO_ADDR, NULL); - - if (lockHandle != NULL) - return 0; - else - return 1; -} - -/**************************************************************************** -REMARKS: -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); */ - return 0; -} - -/**************************************************************************** -REMARKS: -Lock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_lockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - return PM_lockDataPages((void*)p,len,lh); -} - -/**************************************************************************** -REMARKS: -Unlock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_unlockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - return PM_unlockDataPages((void*)p,len,lh); -} - -/**************************************************************************** -REMARKS: -OS specific shared libraries not supported inside a VDD -****************************************************************************/ -PM_MODULE PMAPI PM_loadLibrary( - const char *szDLLName) -{ - (void)szDLLName; - return NULL; -} - -/**************************************************************************** -REMARKS: -OS specific shared libraries not supported inside a VDD -****************************************************************************/ -void * PMAPI PM_getProcAddress( - PM_MODULE hModule, - const char *szProcName) -{ - (void)hModule; - (void)szProcName; - return NULL; -} - -/**************************************************************************** -REMARKS: -OS specific shared libraries not supported inside a VDD -****************************************************************************/ -void PMAPI PM_freeLibrary( - PM_MODULE hModule) -{ - (void)hModule; -} - -/**************************************************************************** -REMARKS: -Function to find the first file matching a search criteria in a directory. -****************************************************************************/ -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. */ - (void)filename; - (void)findData; - return PM_FILE_INVALID; -} - -/**************************************************************************** -REMARKS: -Function to find the next file matching a search criteria in a directory. -****************************************************************************/ -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. */ - (void)handle; - (void)findData; - return false; -} - -/**************************************************************************** -REMARKS: -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. */ - (void)handle; -} - -/**************************************************************************** -REMARKS: -Function to determine if a drive is a valid drive or not. Under Unix this -function will return false for anything except a value of 3 (considered -the root drive, and equivalent to C: for non-Unix systems). The drive -numbering is: - - 1 - Drive A: - 2 - Drive B: - 3 - Drive C: - etc - -****************************************************************************/ -ibool PMAPI PM_driveValid( - char drive) -{ - /* Not applicable in a VDD */ - (void)drive; - return false; -} - -/**************************************************************************** -REMARKS: -Function to get the current working directory for the specififed drive. -Under Unix this will always return the current working directory regardless -of what the value of 'drive' is. -****************************************************************************/ -void PMAPI PM_getdcwd( - int drive, - char *dir, - int len) -{ - /* Not applicable in a VDD */ - (void)drive; - (void)dir; - (void)len; -} - -/**************************************************************************** -PARAMETERS: -base - The starting physical base address of the region -size - The size in bytes of the region -type - Type to place into the MTRR register - -RETURNS: -Error code describing the result. - -REMARKS: -Function to enable write combining for the specified region of memory. -****************************************************************************/ -int PMAPI PM_enableWriteCombine( - ulong base, - ulong size, - uint type) -{ - return MTRR_enableWriteCombine(base,size,type); -} - -/**************************************************************************** -REMARKS: -Function to change the file attributes for a specific file. -****************************************************************************/ -void PMAPI PM_setFileAttr( - const char *filename, - uint attrib) -{ - /* TODO: Implement this ? */ - (void)filename; - (void)attrib; - PM_fatalError("PM_setFileAttr not implemented!"); -} - -/**************************************************************************** -REMARKS: -Function to get the file attributes for a specific file. -****************************************************************************/ -uint PMAPI PM_getFileAttr( - const char *filename) -{ - /* TODO: Implement this ? */ - (void)filename; - PM_fatalError("PM_getFileAttr not implemented!"); - return 0; -} - -/**************************************************************************** -REMARKS: -Function to create a directory. -****************************************************************************/ -ibool PMAPI PM_mkdir( - const char *filename) -{ - /* TODO: Implement this ? */ - (void)filename; - PM_fatalError("PM_mkdir not implemented!"); - return false; -} - -/**************************************************************************** -REMARKS: -Function to remove a directory. -****************************************************************************/ -ibool PMAPI PM_rmdir( - const char *filename) -{ - /* TODO: Implement this ? */ - (void)filename; - PM_fatalError("PM_rmdir not implemented!"); - return false; -} - -/**************************************************************************** -REMARKS: -Function to get the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_getFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - /* TODO: Implement this ? */ - (void)filename; - (void)gmTime; - (void)time; - PM_fatalError("PM_getFileTime not implemented!"); - return false; -} - -/**************************************************************************** -REMARKS: -Function to set the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_setFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - /* TODO: Implement this ? */ - (void)filename; - (void)gmTime; - (void)time; - PM_fatalError("PM_setFileTime not implemented!"); - return false; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/vdd/vflat.c b/board/MAI/bios_emulator/scitech/src/pm/vdd/vflat.c deleted file mode 100644 index 21639281a7..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/vdd/vflat.c +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Dummy module; no virtual framebuffer for this OS -* -****************************************************************************/ - -#include "pmapi.h" - -ibool PMAPI VF_available(void) -{ - return false; -} - -void * PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) -{ - return NULL; -} - -void PMAPI VF_exit(void) -{ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/vdd/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/vdd/ztimer.c deleted file mode 100644 index 631f6558ee..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/vdd/ztimer.c +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit OS/2 VDD -* -* Description: OS specific implementation for the Zen Timer functions. -* -****************************************************************************/ - -/*---------------------------- Global variables ---------------------------*/ - -static ulong frequency = 1193180; - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Initialise the Zen Timer module internals. -****************************************************************************/ -#define __ZTimerInit() - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerOn(tm) VTD_Get_Real_Time(&tm->start.high,&tm->start.low) - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -static ulong __LZTimerLap( - LZTimerObject *tm) -{ - CPU_largeInteger lap,count; - VTD_Get_Real_Time(&lap.high,&lap.low); - _CPU_diffTime64(&tm->start,&lap,&count); - return _CPU_calcMicroSec(&count,frequency); -} - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerOff(tm) VTD_Get_Real_Time(&tm->end.high,&tm->end.low) - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -static ulong __LZTimerCount( - LZTimerObject *tm) -{ - CPU_largeInteger tmCount; - _CPU_diffTime64(&tm->start,&tm->end,&tmCount); - return _CPU_calcMicroSec(&tmCount,frequency); -} - -/**************************************************************************** -REMARKS: -Define the resolution of the long period timer as microseconds per timer tick. -****************************************************************************/ -#define ULZTIMER_RESOLUTION 1000 - -/**************************************************************************** -REMARKS: -Read the Long Period timer value from the BIOS timer tick. -****************************************************************************/ -static ulong __ULZReadTime(void) -{ - return VDHQuerySysValue(0, VDHGSV_MSECSBOOT); -} - -/**************************************************************************** -REMARKS: -Compute the elapsed time from the BIOS timer tick. Note that we check to see -whether a midnight boundary has passed, and if so adjust the finish time to -account for this. We cannot detect if more that one midnight boundary has -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/vxd/_pm.asm b/board/MAI/bios_emulator/scitech/src/pm/vxd/_pm.asm deleted file mode 100644 index 64a7cecb2d..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/vxd/_pm.asm +++ /dev/null @@ -1,299 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: 80386 Assembler, TASM 4.0 or NASM -;* Environment: 32-bit Windows VxD -;* -;* Description: Low level assembly support for the PM library specific to -;* Windows VxDs. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -header _pm ; Set up memory model - -begdataseg _pm - - cextern _PM_savedDS,USHORT - -enddataseg _pm - -P586 - -begcodeseg _pm ; Start of code segment - -;---------------------------------------------------------------------------- -; void PM_segread(PMSREGS *sregs) -;---------------------------------------------------------------------------- -; Read the current value of all segment registers -;---------------------------------------------------------------------------- -cprocstart PM_segread - - ARG sregs:DPTR - - enter_c - - mov ax,es - _les _si,[sregs] - mov [_ES _si],ax - mov [_ES _si+2],cs - mov [_ES _si+4],ss - mov [_ES _si+6],ds - mov [_ES _si+8],fs - mov [_ES _si+10],gs - - leave_c - ret - -cprocend - -;---------------------------------------------------------------------------- -; int PM_int386x(int intno, PMREGS *in, PMREGS *out,PMSREGS *sregs) -;---------------------------------------------------------------------------- -; Issues a software interrupt in protected mode. This routine has been -; written to allow user programs to load CS and DS with different values -; other than the default. -;---------------------------------------------------------------------------- -cprocstart PM_int386x - -; Not used for VxDs - - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_saveDS(void) -;---------------------------------------------------------------------------- -; Save the value of DS into a section of the code segment, so that we can -; quickly load this value at a later date in the PM_loadDS() routine from -; inside interrupt handlers etc. The method to do this is different -; depending on the DOS extender being used. -;---------------------------------------------------------------------------- -cprocstart PM_saveDS - - mov [_PM_savedDS],ds ; Store away in data segment - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_loadDS(void) -;---------------------------------------------------------------------------- -; Routine to load the DS register with the default value for the current -; DOS extender. Only the DS register is loaded, not the ES register, so -; if you wish to call C code, you will need to also load the ES register -; in 32 bit protected mode. -;---------------------------------------------------------------------------- -cprocstart PM_loadDS - - mov ds,[cs:_PM_savedDS] ; We can access the proper DS through CS - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_setBankA(int bank) -;---------------------------------------------------------------------------- -cprocstart PM_setBankA - -; Not used for VxDs - - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_setBankAB(int bank) -;---------------------------------------------------------------------------- -cprocstart PM_setBankAB - -; Not used for VxDs - - ret - -cprocend - -;---------------------------------------------------------------------------- -; void PM_setCRTStart(int x,int y,int waitVRT) -;---------------------------------------------------------------------------- -cprocstart PM_setCRTStart - -; Not used for VxDs - - ret - -cprocend - -; Macro to delay briefly to ensure that enough time has elapsed between -; successive I/O accesses so that the device being accessed can respond -; to both accesses even on a very fast PC. - -ifdef USE_NASM -%macro DELAY 0 - jmp short $+2 - jmp short $+2 - jmp short $+2 -%endmacro -%macro IODELAYN 1 -%rep %1 - DELAY -%endrep -%endmacro -else -macro DELAY - jmp short $+2 - jmp short $+2 - jmp short $+2 -endm -macro IODELAYN N - rept N - DELAY - endm -endm -endif - -;---------------------------------------------------------------------------- -; uchar _PM_readCMOS(int index) -;---------------------------------------------------------------------------- -; Read the value of a specific CMOS register. We do this with both -; normal interrupts and NMI disabled. -;---------------------------------------------------------------------------- -cprocstart _PM_readCMOS - - ARG index:UINT - - push _bp - mov _bp,_sp - pushfd - mov al,[BYTE index] - or al,80h ; Add disable NMI flag - cli - out 70h,al - IODELAYN 5 - in al,71h - mov ah,al - xor al,al - IODELAYN 5 - out 70h,al ; Re-enable NMI - mov al,ah ; Return value in AL - popfd - pop _bp - ret - -cprocend - -;---------------------------------------------------------------------------- -; void _PM_writeCMOS(int index,uchar value) -;---------------------------------------------------------------------------- -; Read the value of a specific CMOS register. We do this with both -; normal interrupts and NMI disabled. -;---------------------------------------------------------------------------- -cprocstart _PM_writeCMOS - - ARG index:UINT, value:UCHAR - - push _bp - mov _bp,_sp - pushfd - mov al,[BYTE index] - or al,80h ; Add disable NMI flag - cli - out 70h,al - IODELAYN 5 - mov al,[value] - out 71h,al - xor al,al - IODELAYN 5 - out 70h,al ; Re-enable NMI - popfd - pop _bp - ret - -cprocend - -;---------------------------------------------------------------------------- -; double _ftol(double f) -;---------------------------------------------------------------------------- -; Calls to __ftol are generated by the Borland C++ compiler for code -; that needs to convert a floating point type to an integral type. -; -; Input: floating point number on the top of the '87. -; -; Output: a (signed or unsigned) long in EAX -; All other registers preserved. -;----------------------------------------------------------------------- -cprocstart _ftol - - LOCAL temp1:WORD, temp2:QWORD = LocalSize - - push ebp - mov ebp,esp - sub esp,LocalSize - - fstcw [temp1] ; save the control word - fwait - mov al,[BYTE temp1+1] - or [BYTE temp1+1],0Ch ; set rounding control to chop - fldcw [temp1] - fistp [temp2] ; convert to 64-bit integer - mov [BYTE temp1+1],al - fldcw [temp1] ; restore the control word - mov eax,[DWORD temp2] ; return LS 32 bits - mov edx,[DWORD temp2+4] ; MS 32 bits - - mov esp,ebp - pop ebp - ret - -cprocend - -;---------------------------------------------------------------------------- -; _PM_getPDB - Return the Page Table Directory Base address -;---------------------------------------------------------------------------- -cprocstart _PM_getPDB - - mov eax,cr3 - and eax,0FFFFF000h - ret - -cprocend - -;---------------------------------------------------------------------------- -; Flush the Translation Lookaside buffer -;---------------------------------------------------------------------------- -cprocstart PM_flushTLB - - wbinvd ; Flush the CPU cache - mov eax,cr3 - mov cr3,eax ; Flush the TLB - ret - -cprocend - -endcodeseg _pm - - END ; End of module diff --git a/board/MAI/bios_emulator/scitech/src/pm/vxd/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/vxd/cpuinfo.c deleted file mode 100644 index 3c7eaaeaac..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/vxd/cpuinfo.c +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit Windows VxD -* -* Description: VxD specific code for the CPU detection module. -* -****************************************************************************/ - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Do nothing for VxD's -****************************************************************************/ -#define SetMaxThreadPriority() 0 - -/**************************************************************************** -REMARKS: -Do nothing for VxD's -****************************************************************************/ -#define RestoreThreadPriority(i) (void)(i) - -/**************************************************************************** -REMARKS: -Initialise the counter and return the frequency of the counter. -****************************************************************************/ -static void GetCounterFrequency( - CPU_largeInteger *freq) -{ - freq->low = 1193180; - freq->high = 0; -} - -/**************************************************************************** -REMARKS: -Read the counter and return the counter value. -****************************************************************************/ -#define GetCounter(t) \ -{ \ - CPU_largeInteger count; \ - VTD_Get_Real_Time(&count.high,&count.low); \ - (t)->low = count.low; \ - (t)->high = count.high; \ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/vxd/fileio.c b/board/MAI/bios_emulator/scitech/src/pm/vxd/fileio.c deleted file mode 100644 index 3c6ce99208..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/vxd/fileio.c +++ /dev/null @@ -1,304 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit Windows VxD -* -* Description: C library compatible I/O functions for use within a VxD. -* -****************************************************************************/ - -#include "pmapi.h" -#include "vxdfile.h" - -/*------------------------ Main Code Implementation -----------------------*/ - -#define EOF -1 - -/**************************************************************************** -REMARKS: -VxD implementation of the ANSI C fopen function. -****************************************************************************/ -FILE * fopen( - const char *filename, - const char *mode) -{ - FILE *f = PM_malloc(sizeof(FILE)); - 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; - - 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); - } - } - return f; -} - -/**************************************************************************** -REMARKS: -VxD implementation of the ANSI C fread function. Note that the VxD file I/O -functions are layered on DOS, so can only read up to 64K at a time. Since -we are expected to handle much larger chunks than this, we handle larger -blocks automatically in here. -****************************************************************************/ -size_t fread( - void *ptr, - size_t size, - size_t n, - FILE *f) -{ - char *buf = ptr; - WORD error; - int bytes = size * n; - 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 (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; - } - return totalbytes / size; -} - -/**************************************************************************** -REMARKS: -VxD implementation of the ANSI C fwrite function. Note that the VxD file I/O -functions are layered on DOS, so can only read up to 64K at a time. Since -we are expected to handle much larger chunks than this, we handle larger -blocks automatically in here. -****************************************************************************/ -size_t fwrite( - const void *ptr, - size_t size, - size_t n, - FILE *f) -{ - const char *buf = ptr; - WORD error; - int bytes = size * n; - int writtenbytes,totalbytes = 0; - - if (!f->writemode) - 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,bytes,f->offset,&error); - else - writtenbytes = i_write(f->handle,buf,bytes); - totalbytes += writtenbytes; - f->offset += writtenbytes; - if (f->offset > f->filesize) - f->filesize = f->offset; - return totalbytes / size; -} - -/**************************************************************************** -REMARKS: -VxD implementation of the ANSI C fflush function. -****************************************************************************/ -int fflush( - FILE *f) -{ - /* Nothing to do since we are not doing buffered file I/O */ - (void)f; - return 0; -} - -/**************************************************************************** -REMARKS: -VxD implementation of the ANSI C fseek function. -****************************************************************************/ -int fseek( - FILE *f, - long int offset, - int whence) -{ - if (whence == 0) - f->offset = offset; - else if (whence == 1) - f->offset += offset; - else if (whence == 2) - f->offset = f->filesize + offset; - if (!initComplete) - i_lseek(f->handle,f->offset,0); - return 0; -} - -/**************************************************************************** -REMARKS: -VxD implementation of the ANSI C ftell function. -****************************************************************************/ -long ftell( - FILE *f) -{ - return f->offset; -} - -/**************************************************************************** -REMARKS: -VxD implementation of the ANSI C feof function. -****************************************************************************/ -int feof( - FILE *f) -{ - return (f->offset == f->filesize); -} - -/**************************************************************************** -REMARKS: -NT driver implementation of the ANSI C fgets function. -****************************************************************************/ -char *fgets( - char *s, - int n, - FILE *f) -{ - int len; - char *cs; - - /* Read the entire buffer into memory (our functions are unbuffered!) */ - if ((len = fread(s,1,n,f)) == 0) - return NULL; - - /* Search for '\n' or end of string */ - if (n > len) - n = len; - cs = s; - while (--n > 0) { - if (*cs == '\n') - break; - cs++; - } - *cs = '\0'; - return s; -} - -/**************************************************************************** -REMARKS: -NT driver implementation of the ANSI C fputs function. -****************************************************************************/ -int fputs( - const char *s, - FILE *f) -{ - return fwrite(s,1,strlen(s),f); -} - -/**************************************************************************** -REMARKS: -VxD implementation of the ANSI C fclose function. -****************************************************************************/ -int fclose( - FILE *f) -{ - WORD error; - - if (initComplete) - R0_CloseFile((HANDLE)f->handle,&error); - else - i_close(f->handle); - PM_free(f); - return 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/vxd/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/vxd/oshdr.h deleted file mode 100644 index 7efc0f9f85..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/vxd/oshdr.h +++ /dev/null @@ -1,29 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit Windows VxD -* -* Description: Include file to include all OS specific header files. -* -****************************************************************************/ diff --git a/board/MAI/bios_emulator/scitech/src/pm/vxd/pm.c b/board/MAI/bios_emulator/scitech/src/pm/vxd/pm.c deleted file mode 100644 index 4cb7f19ed4..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/vxd/pm.c +++ /dev/null @@ -1,1359 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit Windows VxD -* -* Description: Implementation for the OS Portability Manager Library, which -* contains functions to implement OS specific services in a -* generic, cross platform API. Porting the OS Portability -* Manager library is the first step to porting any SciTech -* products to a new platform. -* -****************************************************************************/ - -#include "pmapi.h" -#include "drvlib/os/os.h" -#include "sdd/sddhelp.h" -#include "mtrr.h" - -/*--------------------------- Global variables ----------------------------*/ - -#define MAX_MEMORY_SHARED 100 -#define MAX_MEMORY_MAPPINGS 100 - -typedef struct { - void *linear; - ulong global; - ulong length; - int npages; - } memshared; - -typedef struct { - ulong physical; - ulong linear; - ulong length; - int npages; - ibool isCached; - } mmapping; - -static int numMappings = 0; -static memshared shared[MAX_MEMORY_MAPPINGS] = {0}; -static mmapping maps[MAX_MEMORY_MAPPINGS]; -extern ibool _PM_haveBIOS; -char _PM_cntPath[PM_MAX_PATH] = ""; -char _PM_nucleusPath[PM_MAX_PATH] = ""; -uchar *_PM_rmBufAddr = NULL; -ushort _VARAPI _PM_savedDS = 0; -static uchar _PM_oldCMOSRegA; -static uchar _PM_oldCMOSRegB; -PM_intHandler _PM_rtcHandler = NULL; -IRQHANDLE RTCIRQHandle = 0; -VPICD_HWInt_THUNK RTCInt_Thunk; - -static char *szWindowsKey = "Software\\Microsoft\\Windows\\CurrentVersion"; -static char *szSystemRoot = "SystemRoot"; -static char *szMachineNameKey = "System\\CurrentControlSet\\control\\ComputerName\\ComputerName"; -static char *szMachineName = "ComputerName"; -static void (PMAPIP fatalErrorCleanup)(void) = NULL; - -/*----------------------------- Implementation ----------------------------*/ - -/* Functions to read and write CMOS registers */ - -ulong PMAPI _PM_getPDB(void); -uchar PMAPI _PM_readCMOS(int index); -void PMAPI _PM_writeCMOS(int index,uchar value); - -/**************************************************************************** -REMARKS: -PM_malloc override function for Nucleus drivers loaded in VxD's. -****************************************************************************/ -void * VXD_malloc( - size_t size) -{ - return PM_mallocShared(size); -} - -/**************************************************************************** -REMARKS: -PM_calloc override function for Nucleus drivers loaded in VxD's. -****************************************************************************/ -void * VXD_calloc( - size_t nelem, - size_t size) -{ - void *p = PM_mallocShared(nelem * size); - if (p) - memset(p,0,nelem * size); - return p; -} - -/**************************************************************************** -REMARKS: -PM_realloc override function for Nucleus drivers loaded in VxD's. -****************************************************************************/ -void * VXD_realloc( - void *ptr, - size_t size) -{ - void *p = PM_mallocShared(size); - if (p) { - memcpy(p,ptr,size); - PM_freeShared(ptr); - } - return p; -} - -/**************************************************************************** -REMARKS: -PM_free override function for Nucleus drivers loaded in VxD's. -****************************************************************************/ -void VXD_free( - void *p) -{ - PM_freeShared(p); -} - -/**************************************************************************** -REMARKS: -Initialise the PM library. -****************************************************************************/ -void PMAPI PM_init(void) -{ - /* Override the default memory allocators for all Nucleus drivers - * loaded in SDDHELP/PMHELP. We do this so that we can ensure all memory - * dynamically allocated by Nucleus drivers and internal C runtime - * library functions are shared memory blocks that all processes - * connecting to SDDHELP can see. - */ - PM_useLocalMalloc(VXD_malloc,VXD_calloc,VXD_realloc,VXD_free); - - /* Initialiase the MTRR module */ - MTRR_init(); -} - -ibool PMAPI PM_haveBIOSAccess(void) -{ return _PM_haveBIOS; } - -long PMAPI PM_getOSType(void) -{ return _OS_WIN32VXD; } - -int PMAPI PM_getModeType(void) -{ return PM_386; } - -void PMAPI PM_backslash(char *s) -{ - uint pos = strlen(s); - if (s[pos-1] != '\\') { - s[pos] = '\\'; - s[pos+1] = '\0'; - } -} - -void PMAPI PM_setFatalErrorCleanup( - void (PMAPIP cleanup)(void)) -{ - fatalErrorCleanup = cleanup; -} - -void PMAPI PM_fatalError(const char *msg) -{ - if (fatalErrorCleanup) - fatalErrorCleanup(); - Fatal_Error_Handler(msg,0); -} - -/**************************************************************************** -PARAMETERS: -len - Place to store the length of the buffer -rseg - Place to store the real mode segment of the buffer -roff - Place to store the real mode offset of the buffer - -REMARKS: -This function returns the address and length of the global VESA transfer -buffer that is used for communicating with the VESA BIOS functions from -Win16 and Win32 programs under Windows. -****************************************************************************/ -void * PMAPI PM_getVESABuf( - uint *len, - uint *rseg, - uint *roff) -{ - /* If the VxD is dynamically loaded we will not have a real mode - * 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; - } - return NULL; -} - -int PMAPI PM_int386( - int intno, - PMREGS *in, - PMREGS *out) -{ - /* Unused in VxDs */ - return 0; -} - -void PMAPI _PM_getRMvect( - int intno, - long *realisr) -{ - WORD seg; - DWORD off; - - Get_V86_Int_Vector(intno,&seg,&off); - *realisr = ((long)seg << 16) | (off & 0xFFFF); -} - -void PMAPI _PM_setRMvect( - int intno, - long realisr) -{ - Set_V86_Int_Vector(intno,realisr >> 16,realisr & 0xFFFF); -} - -char * PMAPI PM_getCurrentPath( - char *path, - int maxLen) -{ - strncpy(path,_PM_cntPath,maxLen); - path[maxLen-1] = 0; - return path; -} - -char PMAPI PM_getBootDrive(void) -{ return 'c'; } - -const char * PMAPI PM_getVBEAFPath(void) -{ return "c:\\"; } - -/**************************************************************************** -PARAMETERS: -szKey - Key to query (can contain version number formatting) -szValue - Value to get information for -value - Place to store the registry key data read -size - Size of the string buffer to read into - -RETURNS: -true if the key was found, false if not. -****************************************************************************/ -static ibool REG_queryString( - char *szKey, - char *szValue, - char *value, - ulong size) -{ - HKEY hKey; - ulong type; - ibool status = false; - - 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); - } - return status; -} - -const char * PMAPI PM_getNucleusPath(void) -{ - static char path[256]; - - if (strlen(_PM_nucleusPath) > 0) { - strcpy(path,_PM_nucleusPath); - PM_backslash(path); - return path; - } - if (!REG_queryString(szWindowsKey,szSystemRoot,path,sizeof(path))) - strcpy(path,"c:\\windows"); - PM_backslash(path); - strcat(path,"system\\nucleus"); - return path; -} - -const char * PMAPI PM_getNucleusConfigPath(void) -{ - static char path[256]; - strcpy(path,PM_getNucleusPath()); - PM_backslash(path); - strcat(path,"config"); - return path; -} - -const char * PMAPI PM_getUniqueID(void) -{ return PM_getMachineName(); } - -const char * PMAPI PM_getMachineName(void) -{ - static char name[256]; - if (REG_queryString(szMachineNameKey,szMachineName,name,sizeof(name))) - return name; - return "Unknown"; -} - -int PMAPI PM_kbhit(void) -{ return 1; } - -int PMAPI PM_getch(void) -{ return 0; } - -PM_HWND PMAPI PM_openConsole( - PM_HWND hwndUser, - int device, - int xRes, - int yRes, - int bpp, - ibool fullScreen) -{ - /* Unused in VxDs */ - return NULL; -} - -int PMAPI PM_getConsoleStateSize(void) -{ - /* Unused in VxDs */ - return 1; -} - -void PMAPI PM_saveConsoleState( - void *stateBuf, - PM_HWND hwndConsole) -{ - /* Unused in VxDs */ -} - -void PMAPI PM_setSuspendAppCallback( - int (_ASMAPIP saveState)( - int flags)) -{ - /* Unused in VxDs */ -} - -void PMAPI PM_restoreConsoleState( - const void *stateBuf, - PM_HWND hwndConsole) -{ - /* Unused in VxDs */ -} - -void PMAPI PM_closeConsole( - PM_HWND hwndConsole) -{ - /* Unused in VxDs */ -} - -void PM_setOSCursorLocation( - int x, - int y) -{ - uchar *_biosPtr = PM_getBIOSPointer(); - PM_setByte(_biosPtr+0x50,x); - PM_setByte(_biosPtr+0x51,y); -} - -void PM_setOSScreenWidth( - int width, - int height) -{ - uchar *_biosPtr = PM_getBIOSPointer(); - PM_setByte(_biosPtr+0x4A,width); - PM_setByte(_biosPtr+0x84,height-1); -} - -/**************************************************************************** -REMARKS: -Allocate a block of shared memory. For Win9x we allocate shared memory -as locked, global memory that is accessible from any memory context -(including interrupt time context), which allows us to load our important -data structure and code such that we can access it directly from a ring -0 interrupt context. -****************************************************************************/ -void * PMAPI PM_mallocShared( - long size) -{ - MEMHANDLE hMem; - DWORD pgNum,nPages = (size + 0xFFF) >> 12; - int i; - - /* 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 (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; - } - return NULL; -} - -/**************************************************************************** -REMARKS: -Free a block of shared memory -****************************************************************************/ -void PMAPI PM_freeShared(void *p) -{ - int i; - - /* 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; - } - } -} - -/**************************************************************************** -REMARKS: -Maps a shared memory block into process address space. Does nothing since -the memory blocks are already globally7 mapped into all processes. -****************************************************************************/ -void * PMAPI PM_mapToProcess( - void *base, - ulong limit) -{ - return (void*)base; -} - -ibool PMAPI PM_doBIOSPOST( - ushort axVal, - ulong BIOSPhysAddr, - void *mappedBIOS, - ulong BIOSLen) -{ - /* TODO: Figure out how to do this */ - return false; -} - -void * PMAPI PM_getBIOSPointer(void) -{ return (void*)0x400; } - -void * PMAPI PM_getA0000Pointer(void) -{ return PM_mapPhysicalAddr(0xA0000,0xFFFF,true); } - -/**************************************************************************** -PARAMETERS: -base - Physical base address of the memory to maps in -limit - Limit of physical memory to region to maps in - -RETURNS: -Linear address of the newly mapped memory. - -REMARKS: -Maps a physical memory range to a linear memory range. -****************************************************************************/ -ulong _PM_mapPhysicalToLinear( - ulong base, - ulong limit, - int *npages) -{ - ulong linear,length = limit+1; - int i,ppage,flags; - - if (base < 0x100000) { - /* 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; - } - if ((linear = (ulong)PageReserve(PR_SYSTEM,*npages,flags)) == (ulong)-1) - return 0xFFFFFFFF; - if (!PageCommitPhys(linear >> 12,*npages,ppage,PC_INCR | PC_USER | PC_WRITEABLE)) - return 0xFFFFFFFF; - return linear + (base & 0xFFF); -} - -/* Page table flags */ - -#define PAGE_FLAGS_PRESENT 0x00000001 -#define PAGE_FLAGS_WRITEABLE 0x00000002 -#define PAGE_FLAGS_USER 0x00000004 -#define PAGE_FLAGS_WRITE_THROUGH 0x00000008 -#define PAGE_FLAGS_CACHE_DISABLE 0x00000010 -#define PAGE_FLAGS_ACCESSED 0x00000020 -#define PAGE_FLAGS_DIRTY 0x00000040 -#define PAGE_FLAGS_4MB 0x00000080 - -/**************************************************************************** -PARAMETERS: -base - Physical base address of the memory to maps in -limit - Limit of physical memory to region to maps in -isCached - True if the memory should be cached, false if not - -RETURNS: -Linear address of the newly mapped memory. - -REMARKS: -This function maps physical memory to linear memory, which can then be used -to create a selector or used directly from 32-bit protected mode programs. -This is better than DPMI 0x800, since it allows you to maps physical -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. -****************************************************************************/ -void * PMAPI PM_mapPhysicalAddr( - ulong base, - ulong limit, - ibool isCached) -{ - ulong linear,length = limit+1; - int i,npages; - ulong PDB,*pPDB; - - /* 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) - return (void*)maps[i].linear; - } - if (numMappings == MAX_MEMORY_MAPPINGS) - 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 - * to have problems mapping memory in the 1Mb physical address space. - * Hence we use PageReserve and PageCommitPhys. - */ - if ((linear = _PM_mapPhysicalToLinear(base,limit,&npages)) == 0xFFFFFFFF) - return NULL; - maps[numMappings].physical = base; - maps[numMappings].length = length; - maps[numMappings].linear = linear; - maps[numMappings].npages = npages; - maps[numMappings].isCached = isCached; - numMappings++; - - /* 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(); - } - } - return (void*)linear; -} - -void PMAPI PM_freePhysicalAddr( - void *ptr, - ulong limit) -{ - /* We never free the mappings */ -} - -void PMAPI PM_sleep(ulong milliseconds) -{ - /* We never sleep in a VxD */ -} - -int PMAPI PM_getCOMPort(int port) -{ - /* 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; - } - 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. */ - switch (port) { - case 0: return 0x3BC; - case 1: return 0x378; - case 2: return 0x278; - } - return 0; -} - -ulong PMAPI PM_getPhysicalAddr( - void *p) -{ - 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 ;-) */ - pte = *((ulong*)p); - - /* 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 failure to the caller! */ - return 0xFFFFFFFFUL; -} - -ibool PMAPI PM_getPhysicalAddrRange( - void *p, - ulong length, - ulong *physAddress) -{ - int i; - ulong linear = (ulong)p & ~0xFFF; - - for (i = (length + 0xFFF) >> 12; i > 0; i--) { - if ((*physAddress++ = PM_getPhysicalAddr((void*)linear)) == 0xFFFFFFFF) - return false; - linear += 4096; - } - return true; -} - -void PMAPI _PM_freeMemoryMappings(void) -{ - int i; - for (i = 0; i < numMappings; i++) - PageFree(maps[i].linear,PR_STATIC); -} - -void * PMAPI PM_mapRealPointer( - uint r_seg, - uint r_off) -{ - return (void*)MK_PHYS(r_seg,r_off); -} - -void * PMAPI PM_allocRealSeg( - uint size, - uint *r_seg, - uint *r_off) -{ - return NULL; -} - -void PMAPI PM_freeRealSeg( - void *mem) -{ -} - -void PMAPI DPMI_int86( - int intno, - DPMI_regs *regs) -{ - /* Unsed in VxD's */ -} - -/**************************************************************************** -REMARKS: -Load the V86 registers in the client state, and save the original state -before loading the registers. -****************************************************************************/ -static void LoadV86Registers( - CLIENT_STRUCT *saveRegs, - RMREGS *in, - RMSREGS *sregs) -{ - CLIENT_STRUCT newRegs; - - Save_Client_State(saveRegs); - newRegs = *saveRegs; - newRegs.CRS.Client_EAX = in->e.eax; - newRegs.CRS.Client_EBX = in->e.ebx; - newRegs.CRS.Client_ECX = in->e.ecx; - newRegs.CRS.Client_EDX = in->e.edx; - newRegs.CRS.Client_ESI = in->e.esi; - newRegs.CRS.Client_EDI = in->e.edi; - newRegs.CRS.Client_ES = sregs->es; - newRegs.CRS.Client_DS = sregs->ds; - Restore_Client_State(&newRegs); -} - -/**************************************************************************** -REMARKS: -Read the V86 registers from the client state and restore the original state. -****************************************************************************/ -static void ReadV86Registers( - CLIENT_STRUCT *saveRegs, - RMREGS *out, - RMSREGS *sregs) -{ - CLIENT_STRUCT newRegs; - - Save_Client_State(&newRegs); - out->e.eax = newRegs.CRS.Client_EAX; - out->e.ebx = newRegs.CRS.Client_EBX; - out->e.ecx = newRegs.CRS.Client_ECX; - out->e.edx = newRegs.CRS.Client_EDX; - out->e.esi = newRegs.CRS.Client_ESI; - out->e.edi = newRegs.CRS.Client_EDI; - sregs->es = newRegs.CRS.Client_ES; - sregs->ds = newRegs.CRS.Client_DS; - Restore_Client_State(saveRegs); -} - -/**************************************************************************** -REMARKS: -Call a V86 real mode function with the specified register values -loaded before the call. The call returns with a far ret. -****************************************************************************/ -void PMAPI PM_callRealMode( - uint seg, - uint off, - RMREGS *regs, - RMSREGS *sregs) -{ - CLIENT_STRUCT saveRegs; - - /* Bail if we do not have BIOS access (ie: the VxD was dynamically - * loaded, and not statically loaded. - */ - if (!_PM_haveBIOS) - return; - - _TRACE("SDDHELP: Entering PM_callRealMode()\n"); - Begin_Nest_V86_Exec(); - LoadV86Registers(&saveRegs,regs,sregs); - Simulate_Far_Call(seg, off); - Resume_Exec(); - ReadV86Registers(&saveRegs,regs,sregs); - End_Nest_Exec(); - _TRACE("SDDHELP: Exiting PM_callRealMode()\n"); -} - -/**************************************************************************** -REMARKS: -Issue a V86 real mode interrupt with the specified register values -loaded before the interrupt. -****************************************************************************/ -int PMAPI PM_int86( - int intno, - RMREGS *in, - RMREGS *out) -{ - RMSREGS sregs = {0}; - CLIENT_STRUCT saveRegs; - ushort oldDisable; - - /* Bail if we do not have BIOS access (ie: the VxD was dynamically - * loaded, and not statically loaded. - */ - if (!_PM_haveBIOS) { - *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; - } - Begin_Nest_V86_Exec(); - LoadV86Registers(&saveRegs,in,&sregs); - Exec_Int(intno); - ReadV86Registers(&saveRegs,out,&sregs); - End_Nest_Exec(); - - /* Re-enable pass-up to our VxD handler if previously enabled */ - if (disableTSRFlag) - *disableTSRFlag = oldDisable; - - _TRACE("SDDHELP: Exiting PM_int86()\n"); - return out->x.ax; -} - -/**************************************************************************** -REMARKS: -Issue a V86 real mode interrupt with the specified register values -loaded before the interrupt. -****************************************************************************/ -int PMAPI PM_int86x( - int intno, - RMREGS *in, - RMREGS *out, - RMSREGS *sregs) -{ - CLIENT_STRUCT saveRegs; - ushort oldDisable; - - /* Bail if we do not have BIOS access (ie: the VxD was dynamically - * loaded, and not statically loaded. - */ - if (!_PM_haveBIOS) { - *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; - } - Begin_Nest_V86_Exec(); - LoadV86Registers(&saveRegs,in,sregs); - Exec_Int(intno); - ReadV86Registers(&saveRegs,out,sregs); - End_Nest_Exec(); - - /* Re-enable pass-up to our VxD handler if previously enabled */ - if (disableTSRFlag) - *disableTSRFlag = oldDisable; - - _TRACE("SDDHELP: Exiting PM_int86x()\n"); - return out->x.ax; -} - -/**************************************************************************** -REMARKS: -Returns available memory. Not possible under Windows. -****************************************************************************/ -void PMAPI PM_availableMemory( - ulong *physical, - ulong *total) -{ - *physical = *total = 0; -} - -/**************************************************************************** -REMARKS: -Allocates a block of locked physical memory. -****************************************************************************/ -void * PMAPI PM_allocLockedMem( - uint size, - ulong *physAddr, - ibool contiguous, - ibool below16M) -{ - MEMHANDLE hMem; - DWORD nPages = (size + 0xFFF) >> 12; - DWORD flags = PAGEFIXED | PAGEUSEALIGN | (contiguous ? PAGECONTIG : 0); - 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. */ - 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! */ - return p; -} - -/**************************************************************************** -REMARKS: -Frees a block of locked physical memory. -****************************************************************************/ -void PMAPI PM_freeLockedMem( - void *p, - uint size, - ibool contiguous) -{ - if (p) - PageFree((ulong)p,0); -} - -/**************************************************************************** -REMARKS: -Allocates a page aligned and page sized block of memory -****************************************************************************/ -void * PMAPI PM_allocPage( - ibool locked) -{ - 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. */ - PageAllocate(1,PG_SYS,0,0,0,0,0,PAGEFIXED,&hMem,&p); - return p; -} - -/**************************************************************************** -REMARKS: -Free a page aligned and page sized block of memory -****************************************************************************/ -void PMAPI PM_freePage( - void *p) -{ - if (p) - PageFree((ulong)p,0); -} - -/**************************************************************************** -REMARKS: -Lock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_lockDataPages( - void *p, - uint len, - PM_lockHandle *lh) -{ - DWORD pgNum = (ulong)p >> 12; - DWORD nPages = (len + (ulong)p - (pgNum << 12) + 0xFFF) >> 12; - return LinPageLock(pgNum,nPages,0); -} - -/**************************************************************************** -REMARKS: -Unlock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_unlockDataPages( - void *p, - uint len, - PM_lockHandle *lh) -{ - DWORD pgNum = (ulong)p >> 12; - DWORD nPages = (len + (ulong)p - (pgNum << 12) + 0xFFF) >> 12; - return LinPageUnLock(pgNum,nPages,0); -} - -/**************************************************************************** -REMARKS: -Lock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_lockCodePages( - void (*p)(), - uint len, - PM_lockHandle *lh) -{ - return PM_lockDataPages((void*)p,len,lh); -} - -/**************************************************************************** -REMARKS: -Unlock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_unlockCodePages( - void (*p)(), - uint len, - PM_lockHandle *lh) -{ - return PM_unlockDataPages((void*)p,len,lh); -} - -/**************************************************************************** -REMARKS: -Set the real time clock frequency (for stereo modes). -****************************************************************************/ -void PMAPI PM_setRealTimeClockFrequency( - int frequency) -{ - static short convert[] = { - 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); - } - 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,0x20 | (i+3)); - _PM_writeCMOS(0x0B,(_PM_oldCMOSRegB & 0x0F) | 0x40); - } -} - -/**************************************************************************** -REMARKS: -Real time clock interrupt handler, which calls the user registered C code. -****************************************************************************/ -static BOOL __stdcall RTCInt_Handler( - VMHANDLE hVM, - IRQHANDLE hIRQ) -{ - static char inside = 0; - - /* Clear priority interrupt controller and re-enable interrupts so we - * dont lock things up for long. - */ - VPICD_Phys_EOI(hIRQ); - - /* Clear real-time clock timeout */ - _PM_readCMOS(0x0C); - - /* Now call the C based interrupt handler (but check for mutual - * exclusion since we may still be servicing an old interrupt when a - * new one comes along; if that happens we ignore the old one). - */ - if (!inside) { - inside = 1; - enable(); - _PM_rtcHandler(); - inside = 0; - } - return TRUE; -} - -/**************************************************************************** -REMARKS: -Set the real time clock handler (used for software stereo modes). -****************************************************************************/ -ibool PMAPI PM_setRealTimeClockHandler( - PM_intHandler ih, - int frequency) -{ - struct VPICD_IRQ_Descriptor IRQdesc; - - /* Save the old CMOS real time clock values */ - _PM_oldCMOSRegA = _PM_readCMOS(0x0A); - _PM_oldCMOSRegB = _PM_readCMOS(0x0B); - - /* Set the real time clock interrupt handler */ - CHECK(ih != NULL); - _PM_rtcHandler = ih; - IRQdesc.VID_IRQ_Number = 0x8; - IRQdesc.VID_Options = 0; - IRQdesc.VID_Hw_Int_Proc = (DWORD)VPICD_Thunk_HWInt(RTCInt_Handler, &RTCInt_Thunk); - IRQdesc.VID_EOI_Proc = 0; - IRQdesc.VID_Virt_Int_Proc = 0; - IRQdesc.VID_Mask_Change_Proc= 0; - IRQdesc.VID_IRET_Proc = 0; - IRQdesc.VID_IRET_Time_Out = 500; - if ((RTCIRQHandle = VPICD_Virtualize_IRQ(&IRQdesc)) == 0) - return false; - - /* Program the real time clock default frequency */ - PM_setRealTimeClockFrequency(frequency); - - /* Unmask IRQ8 in the PIC */ - VPICD_Physically_Unmask(RTCIRQHandle); - return true; -} - -/**************************************************************************** -REMARKS: -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 the interrupt vector */ - VPICD_Set_Auto_Masking(RTCIRQHandle); - VPICD_Force_Default_Behavior(RTCIRQHandle); - RTCIRQHandle = 0; - } -} - -/**************************************************************************** -REMARKS: -OS specific shared libraries not supported inside a VxD -****************************************************************************/ -PM_MODULE PMAPI PM_loadLibrary( - const char *szDLLName) -{ - (void)szDLLName; - return NULL; -} - -/**************************************************************************** -REMARKS: -OS specific shared libraries not supported inside a VxD -****************************************************************************/ -void * PMAPI PM_getProcAddress( - PM_MODULE hModule, - const char *szProcName) -{ - (void)hModule; - (void)szProcName; - return NULL; -} - -/**************************************************************************** -REMARKS: -OS specific shared libraries not supported inside a VxD -****************************************************************************/ -void PMAPI PM_freeLibrary( - PM_MODULE hModule) -{ - (void)hModule; -} - -/**************************************************************************** -REMARKS: -Function to find the first file matching a search criteria in a directory. -****************************************************************************/ -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. */ - (void)filename; - (void)findData; - return PM_FILE_INVALID; -} - -/**************************************************************************** -REMARKS: -Function to find the next file matching a search criteria in a directory. -****************************************************************************/ -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. */ - (void)handle; - (void)findData; - return false; -} - -/**************************************************************************** -REMARKS: -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. */ - (void)handle; -} - -/**************************************************************************** -REMARKS: -Function to determine if a drive is a valid drive or not. Under Unix this -function will return false for anything except a value of 3 (considered -the root drive, and equivalent to C: for non-Unix systems). The drive -numbering is: - - 1 - Drive A: - 2 - Drive B: - 3 - Drive C: - etc - -****************************************************************************/ -ibool PMAPI PM_driveValid( - char drive) -{ - /* Not supported in a VxD */ - (void)drive; - return false; -} - -/**************************************************************************** -REMARKS: -Function to get the current working directory for the specififed drive. -Under Unix this will always return the current working directory regardless -of what the value of 'drive' is. -****************************************************************************/ -void PMAPI PM_getdcwd( - int drive, - char *dir, - int len) -{ - /* Not supported in a VxD */ - (void)drive; - (void)dir; - (void)len; -} - -/**************************************************************************** -PARAMETERS: -base - The starting physical base address of the region -size - The size in bytes of the region -type - Type to place into the MTRR register - -RETURNS: -Error code describing the result. - -REMARKS: -Function to enable write combining for the specified region of memory. -****************************************************************************/ -int PMAPI PM_enableWriteCombine( - ulong base, - ulong size, - uint type) -{ - return MTRR_enableWriteCombine(base,size,type); -} - -/**************************************************************************** -REMARKS: -Function to change the file attributes for a specific file. -****************************************************************************/ -void PMAPI PM_setFileAttr( - const char *filename, - uint attrib) -{ - /* TODO: Implement this */ - (void)filename; - (void)attrib; - PM_fatalError("PM_setFileAttr not implemented yet!"); -} - -/**************************************************************************** -REMARKS: -Function to get the file attributes for a specific file. -****************************************************************************/ -uint PMAPI PM_getFileAttr( - const char *filename) -{ - /* TODO: Implement this */ - (void)filename; - PM_fatalError("PM_getFileAttr not implemented yet!"); - return 0; -} - -/**************************************************************************** -REMARKS: -Function to create a directory. -****************************************************************************/ -ibool PMAPI PM_mkdir( - const char *filename) -{ - /* TODO: Implement this */ - (void)filename; - PM_fatalError("PM_mkdir not implemented yet!"); - return false; -} - -/**************************************************************************** -REMARKS: -Function to remove a directory. -****************************************************************************/ -ibool PMAPI PM_rmdir( - const char *filename) -{ - /* TODO: Implement this */ - (void)filename; - PM_fatalError("PM_rmdir not implemented yet!"); - return false; -} - -/**************************************************************************** -REMARKS: -Function to get the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_getFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - /* TODO: Implement this! */ - (void)filename; - (void)gmTime; - (void)time; - PM_fatalError("PM_getFileTime not implemented yet!"); - return false; -} - -/**************************************************************************** -REMARKS: -Function to set the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_setFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - /* 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/vxd/vflat.c b/board/MAI/bios_emulator/scitech/src/pm/vxd/vflat.c deleted file mode 100644 index 901ce1cf03..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/vxd/vflat.c +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Dummy module; no virtual framebuffer for this OS -* -****************************************************************************/ - -#include "pmapi.h" - -ibool PMAPI VF_available(void) -{ - return false; -} - -void * PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) -{ - return NULL; -} - -void PMAPI VF_exit(void) -{ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/vxd/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/vxd/ztimer.c deleted file mode 100644 index 76df48c38b..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/vxd/ztimer.c +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: 32-bit Windows VxD -* -* Description: OS specific implementation for the Zen Timer functions. -* -****************************************************************************/ - -/*---------------------------- Global variables ---------------------------*/ - -static ulong frequency = 1193180; - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Initialise the Zen Timer module internals. -****************************************************************************/ -#define __ZTimerInit() - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerOn(tm) VTD_Get_Real_Time(&tm->start.high,&tm->start.low) - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -static ulong __LZTimerLap( - LZTimerObject *tm) -{ - CPU_largeInteger lap,count; - VTD_Get_Real_Time(&lap.high,&lap.low); - _CPU_diffTime64(&tm->start,&lap,&count); - return _CPU_calcMicroSec(&count,frequency); -} - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -#define __LZTimerOff(tm) VTD_Get_Real_Time(&tm->end.high,&tm->end.low) - -/**************************************************************************** -REMARKS: -Call the assembler Zen Timer functions to do the timing. -****************************************************************************/ -static ulong __LZTimerCount( - LZTimerObject *tm) -{ - CPU_largeInteger tmCount; - _CPU_diffTime64(&tm->start,&tm->end,&tmCount); - return _CPU_calcMicroSec(&tmCount,frequency); -} - -/**************************************************************************** -REMARKS: -Define the resolution of the long period timer as microseconds per timer tick. -****************************************************************************/ -#define ULZTIMER_RESOLUTION 1000 - -/**************************************************************************** -REMARKS: -Read the Long Period timer value from the BIOS timer tick. -****************************************************************************/ -static ulong __ULZReadTime(void) -{ - CPU_largeInteger count; - VTD_Get_Real_Time(&count.high,&count.low); - return (count.low * 1000.0 / frequency); -} - -/**************************************************************************** -REMARKS: -Compute the elapsed time from the BIOS timer tick. Note that we check to see -whether a midnight boundary has passed, and if so adjust the finish time to -account for this. We cannot detect if more that one midnight boundary has -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/win32/_pmwin32.asm b/board/MAI/bios_emulator/scitech/src/pm/win32/_pmwin32.asm deleted file mode 100644 index 7c242b5724..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/_pmwin32.asm +++ /dev/null @@ -1,78 +0,0 @@ -;**************************************************************************** -;* -;* SciTech OS Portability Manager Library -;* -;* ======================================================================== -;* -;* The contents of this file are subject to the SciTech MGL Public -;* License Version 1.0 (the "License"); you may not use this file -;* except in compliance with the License. You may obtain a copy of -;* the License at http://www.scitechsoft.com/mgl-license.txt -;* -;* Software distributed under the License is distributed on an -;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -;* implied. See the License for the specific language governing -;* rights and limitations under the License. -;* -;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -;* -;* The Initial Developer of the Original Code is SciTech Software, Inc. -;* All Rights Reserved. -;* -;* ======================================================================== -;* -;* Language: 80386 Assembler, TASM 4.0 or NASM -;* Environment: Win32 -;* -;* Description: Low level assembly support for the PM library specific -;* to Windows. -;* -;**************************************************************************** - - IDEAL - -include "scitech.mac" ; Memory model macros - -header _pmwin32 ; Set up memory model - -begdataseg _pmwin32 - - cglobal _PM_ioentry - cglobal _PM_gdt -_PM_ioentry dd 0 ; Offset to call gate -_PM_gdt dw 0 ; Selector to call gate - -enddataseg _pmwin32 - -begcodeseg _pmwin32 ; Start of code segment - -;---------------------------------------------------------------------------- -; int PM_setIOPL(int iopl) -;---------------------------------------------------------------------------- -; Change the IOPL level for the 32-bit task. Returns the previous level -; so it can be restored for the task correctly. -;---------------------------------------------------------------------------- -cprocstart _PM_setIOPLViaCallGate - - ARG iopl:UINT - - enter_c - pushfd ; Save the old EFLAGS for later - mov ecx,[iopl] ; ECX := IOPL level - xor ebx,ebx ; Change IOPL level function code -ifdef USE_NASM - call far dword [_PM_ioentry] -else - call [FWORD _PM_ioentry] -endif - pop eax - and eax,0011000000000000b - shr eax,12 - leave_c - ret - -cprocend - -endcodeseg _pmwin32 - - END ; End of module diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/win32/cpuinfo.c deleted file mode 100644 index 7da9752051..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/cpuinfo.c +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Win32 -* -* Description: Module to implement OS specific services to measure the -* CPU frequency. -* -****************************************************************************/ - -/*---------------------------- Global variables ---------------------------*/ - -static ibool havePerformanceCounter; - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Increase the thread priority to maximum, if possible. -****************************************************************************/ -static int SetMaxThreadPriority(void) -{ - int oldPriority; - HANDLE hThread = GetCurrentThread(); - - oldPriority = GetThreadPriority(hThread); - if (oldPriority != THREAD_PRIORITY_ERROR_RETURN) - SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); - return oldPriority; -} - -/**************************************************************************** -REMARKS: -Restore the original thread priority. -****************************************************************************/ -static void RestoreThreadPriority( - int oldPriority) -{ - HANDLE hThread = GetCurrentThread(); - - if (oldPriority != THREAD_PRIORITY_ERROR_RETURN) - SetThreadPriority(hThread, oldPriority); -} - -/**************************************************************************** -REMARKS: -Initialise the counter and return the frequency of the counter. -****************************************************************************/ -static void GetCounterFrequency( - CPU_largeInteger *freq) -{ - if (!QueryPerformanceFrequency((LARGE_INTEGER*)freq)) { - havePerformanceCounter = false; - freq->low = 100000; - freq->high = 0; - } - else - havePerformanceCounter = true; -} - -/**************************************************************************** -REMARKS: -Read the counter and return the counter value. -****************************************************************************/ -#define GetCounter(t) \ -{ \ - if (havePerformanceCounter) \ - QueryPerformanceCounter((LARGE_INTEGER*)t); \ - else { \ - (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 deleted file mode 100644 index d6c3f60e84..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/ddraw.c +++ /dev/null @@ -1,582 +0,0 @@ -/**************************************************************************** -* -* SciTech Multi-platform Graphics Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Win32 -* -* Description: Win32 implementation for the SciTech cross platform -* event library. -* -****************************************************************************/ - -#include "event.h" -#include "pmapi.h" -#include "win32/oshdr.h" -#include "nucleus/graphics.h" - -/*---------------------------- Global Variables ---------------------------*/ - -/* Publicly accessible variables */ - -int _PM_deskX,_PM_deskY;/* Desktop dimentions */ -HWND _PM_hwndConsole; /* Window handle for console */ -#ifdef __INTEL__ -uint _PM_cw_default; /* Default FPU control word */ -#endif - -/* Private internal variables */ - -static HINSTANCE hInstApp = NULL;/* Application instance handle */ -static HWND hwndUser = NULL;/* User window handle */ -static HINSTANCE hInstDD = NULL; /* Handle to DirectDraw DLL */ -static LPDIRECTDRAW lpDD = NULL; /* DirectDraw object */ -static LONG oldWndStyle; /* Info about old user window */ -static LONG oldExWndStyle; /* Info about old user window */ -static int oldWinPosX; /* Old window position X coordinate */ -static int oldWinPosY; /* Old window pisition Y coordinate */ -static int oldWinSizeX; /* Old window size X */ -static int oldWinSizeY; /* Old window size Y */ -static WNDPROC oldWinProc = NULL; -static PM_saveState_cb suspendApp = NULL; -static ibool waitActive = false; -static ibool isFullScreen = false; -static ibool backInGDI = false; - -/* Internal strings */ - -static char *szWinClassName = "SciTechDirectDrawWindow"; -static char *szAutoPlayKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"; -static char *szAutoPlayValue = "NoDriveTypeAutoRun"; - -/* Dynalinks to DirectDraw functions */ - -static HRESULT (WINAPI *pDirectDrawCreate)(GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter); - -/*---------------------------- Implementation -----------------------------*/ - -/**************************************************************************** -REMARKS: -Temporarily disables AutoPlay operation while we are running in fullscreen -graphics modes. -****************************************************************************/ -static void DisableAutoPlay(void) -{ - DWORD dwAutoPlay,dwSize = sizeof(dwAutoPlay); - 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); - } -} - -/**************************************************************************** -REMARKS: -Re-enables AutoPlay operation when we return to regular GDI mode. -****************************************************************************/ -static void RestoreAutoPlay(void) -{ - DWORD dwAutoPlay,dwSize = sizeof(dwAutoPlay); - 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); - } -} - -/**************************************************************************** -REMARKS: -Suspends the application by switching back to the GDI desktop, allowing -normal application code to be processed, and then waiting for the -application activate command to bring us back to fullscreen mode with our -window minimised. -****************************************************************************/ -static void LeaveFullScreen(void) -{ - int retCode = PM_SUSPEND_APP; - - if (backInGDI) - return; - if (suspendApp) - 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); - } - } -} - -/**************************************************************************** -REMARKS: -Reactivate all the surfaces for DirectDraw and set the system back up for -fullscreen rendering. -****************************************************************************/ -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); - } - } -} - -/**************************************************************************** -REMARKS: -This function suspends the application by switching back to the GDI desktop, -allowing normal application code to be processed and then waiting for the -application activate command to bring us back to fullscreen mode with our -window minimised. - -This version only gets called if we have not captured the screen switch in -our activate message loops and will occur if the DirectDraw drivers lose a -surface for some reason while rendering. This should not normally happen, -but it is included just to be sure (it can happen on WinNT/2000 if the user -hits the Ctrl-Alt-Del key combination). Note that this code will always -spin loop, and we cannot disable the spin looping from this version (ie: -if the user hits Ctrl-Alt-Del under WinNT/2000 the application main loop -will cease to be executed until the user switches back to the application). -****************************************************************************/ -void PMAPI PM_doSuspendApp(void) -{ - static ibool firstTime = true; - - /* Call system DLL version if found */ - if (_PM_imports.PM_doSuspendApp != PM_doSuspendApp) { - _PM_imports.PM_doSuspendApp(); - return; - } - - if (firstTime) { - if (suspendApp) - suspendApp(PM_DEACTIVATE); - RestoreAutoPlay(); - firstTime = false; - backInGDI = true; - } - RestoreFullScreen(); - firstTime = true; -} - -/**************************************************************************** -REMARKS: -Main Window proc for the full screen DirectDraw Window that we create while -running in full screen mode. Here we capture all mouse and keyboard events -for the window and plug them into our event queue. -****************************************************************************/ -static LONG CALLBACK PM_winProc( - HWND hwnd, - UINT msg, - WPARAM wParam, - 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_PM_RESTORE_FULLSCREEN: - RestoreFullScreen(); - break; - case WM_PM_LEAVE_FULLSCREEN: - LeaveFullScreen(); - break; - } - return 0; - } - if (oldWinProc) - return oldWinProc(hwnd,msg,wParam,lParam); - return DefWindowProc(hwnd,msg,wParam,lParam); -} - -/**************************************************************************** -PARAMETERS: -hwnd - User window to convert -width - Window of the fullscreen window -height - Height of the fullscreen window - -RETURNS: -Handle to converted fullscreen Window. - -REMARKS: -This function takes the original user window handle and modifies the size, -position and attributes for the window to convert it into a fullscreen -window that we can use. -****************************************************************************/ -static PM_HWND _PM_convertUserWindow( - HWND hwnd, - int width, - int height) -{ - RECT window; - - GetWindowRect(hwnd,&window); - oldWinPosX = window.left; - oldWinPosY = window.top; - oldWinSizeX = window.right - window.left; - oldWinSizeY = window.bottom - window.top; - oldWndStyle = SetWindowLong(hwnd,GWL_STYLE,WS_POPUP | WS_SYSMENU); - oldExWndStyle = SetWindowLong(hwnd,GWL_EXSTYLE,WS_EX_APPWINDOW); - ShowWindow(hwnd,SW_SHOW); - MoveWindow(hwnd,0,0,width,height,TRUE); - SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); - oldWinProc = (WNDPROC)SetWindowLong(hwnd,GWL_WNDPROC, (LPARAM)PM_winProc); - return hwnd; -} - -/**************************************************************************** -PARAMETERS: -hwnd - User window to restore - -REMARKS: -This function restores the original attributes of the user window and put's -it back into it's original state before it was converted to a fullscreen -window. -****************************************************************************/ -static void _PM_restoreUserWindow( - HWND hwnd) -{ - SetWindowLong(hwnd,GWL_WNDPROC, (LPARAM)oldWinProc); - SetWindowLong(hwnd,GWL_EXSTYLE,oldExWndStyle); - SetWindowLong(hwnd,GWL_STYLE,oldWndStyle); - SetWindowPos(hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); - ShowWindow(hwnd,SW_SHOW); - MoveWindow(hwnd,oldWinPosX,oldWinPosY,oldWinSizeX,oldWinSizeY,TRUE); - oldWinProc = NULL; -} - -/**************************************************************************** -PARAMETERS: -device - Index of the device to load DirectDraw for (0 for primary) - -REMARKS: -Attempts to dynamically load the DirectDraw DLL's and create the DirectDraw -objects that we need. -****************************************************************************/ -void * PMAPI PM_loadDirectDraw( - int device) -{ - HDC hdc; - int bits; - - /* Call system DLL version if found */ - if (_PM_imports.PM_loadDirectDraw != PM_loadDirectDraw) - return _PM_imports.PM_loadDirectDraw(device); - - /* TODO: Handle multi-monitor!! */ - if (device != 0) - 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; - } - - /* Create the DirectDraw object */ - if (!lpDD && pDirectDrawCreate(NULL, &lpDD, NULL) != DD_OK) { - lpDD = NULL; - return NULL; - } - RESET_DEFAULT_CW(); - return lpDD; -} - -/**************************************************************************** -PARAMETERS: -device - Index of the device to unload DirectDraw for (0 for primary) - -REMARKS: -Frees any DirectDraw objects for the device. We never actually explicitly -unload the ddraw.dll library, since unloading and reloading it is -unnecessary since we only want to unload it when the application exits and -that happens automatically. -****************************************************************************/ -void PMAPI PM_unloadDirectDraw( - int device) -{ - /* Call system DLL version if found */ - if (_PM_imports.PM_unloadDirectDraw != PM_unloadDirectDraw) { - _PM_imports.PM_unloadDirectDraw(device); - return; - } - if (lpDD) { - IDirectDraw_Release(lpDD); - lpDD = NULL; - } - (void)device; -} - -/**************************************************************************** -REMARKS: -Open a console for output to the screen, creating the main event handling -window if necessary. -****************************************************************************/ -PM_HWND PMAPI PM_openConsole( - PM_HWND hWndUser, - int device, - int xRes, - int yRes, - int bpp, - ibool fullScreen) -{ - WNDCLASS cls; - static ibool classRegistered = false; - - /* 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); - } - - /* 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; - } - else { - _PM_hwndConsole = hwndUser; - isFullScreen = false; - } - SetFocus(_PM_hwndConsole); - SetForegroundWindow(_PM_hwndConsole); - DisableAutoPlay(); - (void)bpp; - return _PM_hwndConsole; -} - -/**************************************************************************** -REMARKS: -Find the size of the console state buffer. -****************************************************************************/ -int PMAPI PM_getConsoleStateSize(void) -{ - /* Call system DLL version if found */ - if (_PM_imports.PM_getConsoleStateSize != PM_getConsoleStateSize) - return _PM_imports.PM_getConsoleStateSize(); - - /* Not used in Windows */ - return 1; -} - -/**************************************************************************** -REMARKS: -Save the state of the console. -****************************************************************************/ -void PMAPI PM_saveConsoleState( - void *stateBuf, - PM_HWND hwndConsole) -{ - /* Call system DLL version if found */ - if (_PM_imports.PM_saveConsoleState != PM_saveConsoleState) { - _PM_imports.PM_saveConsoleState(stateBuf,hwndConsole); - return; - } - - /* Not used in Windows */ - (void)stateBuf; - (void)hwndConsole; -} - -/**************************************************************************** -REMARKS: -Set the suspend application callback for the fullscreen console. -****************************************************************************/ -void PMAPI PM_setSuspendAppCallback( - PM_saveState_cb saveState) -{ - /* Call system DLL version if found */ - if (_PM_imports.PM_setSuspendAppCallback != PM_setSuspendAppCallback) { - _PM_imports.PM_setSuspendAppCallback(saveState); - return; - } - suspendApp = saveState; -} - -/**************************************************************************** -REMARKS: -Restore the console state. -****************************************************************************/ -void PMAPI PM_restoreConsoleState( - const void *stateBuf, - PM_HWND hwndConsole) -{ - /* Call system DLL version if found */ - if (_PM_imports.PM_restoreConsoleState != PM_restoreConsoleState) { - _PM_imports.PM_restoreConsoleState(stateBuf,hwndConsole); - return; - } - - /* Not used in Windows */ - (void)stateBuf; - (void)hwndConsole; -} - -/**************************************************************************** -REMARKS: -Close the fullscreen console. -****************************************************************************/ -void PMAPI PM_closeConsole( - PM_HWND hwndConsole) -{ - /* Call system DLL version if found */ - if (_PM_imports.PM_closeConsole != PM_closeConsole) { - _PM_imports.PM_closeConsole(hwndConsole); - return; - } - ShowCursor(true); - RestoreAutoPlay(); - if (hwndUser) - _PM_restoreUserWindow(hwndConsole); - else - DestroyWindow(hwndConsole); - hwndUser = NULL; - _PM_hwndConsole = NULL; -} - -/**************************************************************************** -REMARKS: -Return the DirectDraw window handle used by the application. -****************************************************************************/ -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_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 deleted file mode 100644 index 6388052ce7..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/event.c +++ /dev/null @@ -1,459 +0,0 @@ -/**************************************************************************** -* -* SciTech Multi-platform Graphics Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Win32 -* -* Description: Win32 implementation for the SciTech cross platform -* event library. -* -****************************************************************************/ - -/*---------------------------- Global Variables ---------------------------*/ - -static ushort keyUpMsg[256] = {0}; /* Table of key up messages */ -static int rangeX,rangeY; /* Range of mouse coordinates */ - -/*---------------------------- Implementation -----------------------------*/ - -/* These are not used under Win32 */ -#define _EVT_disableInt() 1 -#define _EVT_restoreInt(flags) (void)(flags) - -/**************************************************************************** -PARAMETERS: -scanCode - Scan code to test - -REMARKS: -This macro determines if a specified key is currently down at the -time that the call is made. -****************************************************************************/ -#define _EVT_isKeyDown(scanCode) (keyUpMsg[scanCode] != 0) - -/**************************************************************************** -REMARKS: -This function is used to return the number of ticks since system -startup in milliseconds. This should be the same value that is placed into -the time stamp fields of events, and is used to implement auto mouse down -events. -****************************************************************************/ -ulong _EVT_getTicks(void) -{ return timeGetTime(); } - -/**************************************************************************** -REMARKS: -Pumps all messages in the message queue from Win32 into our event queue. -****************************************************************************/ -void _EVT_pumpMessages(void) -{ - MSG msg; - MSG charMsg; - event_t evt; - - /* 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); - } -} - -/**************************************************************************** -REMARKS: -This macro/function is used to converts the scan codes reported by the -keyboard to our event libraries normalised format. We only have one scan -code for the 'A' key, and use shift modifiers to determine if it is a -Ctrl-F1, Alt-F1 etc. The raw scan codes from the keyboard work this way, -but the OS gives us 'cooked' scan codes, we have to translate them back -to the raw format. -****************************************************************************/ -#define _EVT_maskKeyCode(evt) - -/**************************************************************************** -REMARKS: -Safely abort the event module upon catching a fatal error. -****************************************************************************/ -void _EVT_abort( - int signal) -{ - (void)signal; - EVT_exit(); - PM_fatalError("Unhandled exception!"); -} - -/**************************************************************************** -PARAMETERS: -mouseMove - Callback function to call wheneve the mouse needs to be moved - -REMARKS: -Initiliase the event handling module. Here we install our mouse handling ISR -to be called whenever any button's are pressed or released. We also build -the free list of events in the event queue. - -We use handler number 2 of the mouse libraries interrupt handlers for our -event handling routines. -****************************************************************************/ -void EVTAPI EVT_init( - _EVT_mouseMoveHandler mouseMove) -{ - /* Initialise the event queue */ - EVT.mouseMove = mouseMove; - initEventQueue(); - memset(keyUpMsg,0,sizeof(keyUpMsg)); - - /* Catch program termination signals so we can clean up properly */ - signal(SIGABRT, _EVT_abort); - signal(SIGFPE, _EVT_abort); - signal(SIGINT, _EVT_abort); -} - -/**************************************************************************** -REMARKS -Changes the range of coordinates returned by the mouse functions to the -specified range of values. This is used when changing between graphics -modes set the range of mouse coordinates for the new display mode. -****************************************************************************/ -void EVTAPI EVT_setMouseRange( - int xRes, - int yRes) -{ - rangeX = xRes; - rangeY = yRes; -} - -/**************************************************************************** -REMARKS -Modifes the mouse coordinates as necessary if scaling to OS coordinates, -and sets the OS mouse cursor position. -****************************************************************************/ -void _EVT_setMousePos( - int *x, - int *y) -{ - /* Scale coordinates up to desktop coordinates first */ - int scaledX = (*x * _PM_deskX) / rangeX; - int scaledY = (*y * _PM_deskY) / rangeY; - - /* Scale coordinates back to screen coordinates again */ - *x = (scaledX * rangeX) / _PM_deskX; - *y = (scaledY * rangeY) / _PM_deskY; - SetCursorPos(scaledX,scaledY); -} - -/**************************************************************************** -REMARKS: -Initiailises the internal event handling modules. The EVT_suspend function -can be called to suspend event handling (such as when shelling out to DOS), -and this function can be used to resume it again later. -****************************************************************************/ -void EVT_resume(void) -{ - /* Do nothing for Win32 */ -} - -/**************************************************************************** -REMARKS -Suspends all of our event handling operations. This is also used to -de-install the event handling code. -****************************************************************************/ -void EVT_suspend(void) -{ - /* Do nothing for Win32 */ -} - -/**************************************************************************** -REMARKS -Exits the event module for program terminatation. -****************************************************************************/ -void EVT_exit(void) -{ - /* Restore signal handlers */ - signal(SIGABRT, SIG_DFL); - signal(SIGFPE, SIG_DFL); - signal(SIGINT, SIG_DFL); -} - -/**************************************************************************** -DESCRIPTION: -Returns the mask indicating what joystick axes are attached. - -HEADER: -event.h - -REMARKS: -This function is used to detect the attached joysticks, and determine -what axes are present and functioning. This function will re-detect any -attached joysticks when it is called, so if the user forgot to attach -the joystick when the application started, you can call this function to -re-detect any newly attached joysticks. - -SEE ALSO: -EVT_joySetLowerRight, EVT_joySetCenter, EVT_joyIsPresent -****************************************************************************/ -int EVTAPI EVT_joyIsPresent(void) -{ - /* TODO: Implement joystick code based on DirectX! */ - return 0; -} - -/**************************************************************************** -DESCRIPTION: -Polls the joystick for position and button information. - -HEADER: -event.h - -REMARKS: -This routine is used to poll analogue joysticks for button and position -information. It should be called once for each main loop of the user -application, just before processing all pending events via EVT_getNext. -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. - -SEE ALSO: -EVT_getNext, EVT_peekNext, EVT_joySetUpperLeft, EVT_joySetLowerRight, -EVT_joySetCenter, EVT_joyIsPresent -****************************************************************************/ -void EVTAPI EVT_pollJoystick(void) -{ -} - -/**************************************************************************** -DESCRIPTION: -Calibrates the joystick upper left position - -HEADER: -event.h - -REMARKS: -This function can be used to zero in on better joystick calibration factors, -which may work better than the default simplistic calibration (which assumes -the joystick is centered when the event library is initialised). -To use this function, ask the user to hold the stick in the upper left -position and then have them press a key or button. and then call this -function. This function will then read the joystick and update the -calibration factors. - -Usually, assuming that the stick was centered when the event library was -initialized, you really only need to call EVT_joySetLowerRight since the -upper left position is usually always 0,0 on most joysticks. However, the -safest procedure is to call all three calibration functions. - -SEE ALSO: -EVT_joySetUpperLeft, EVT_joySetLowerRight, EVT_joyIsPresent -****************************************************************************/ -void EVTAPI EVT_joySetUpperLeft(void) -{ -} - -/**************************************************************************** -DESCRIPTION: -Calibrates the joystick lower right position - -HEADER: -event.h - -REMARKS: -This function can be used to zero in on better joystick calibration factors, -which may work better than the default simplistic calibration (which assumes -the joystick is centered when the event library is initialised). -To use this function, ask the user to hold the stick in the lower right -position and then have them press a key or button. and then call this -function. This function will then read the joystick and update the -calibration factors. - -Usually, assuming that the stick was centered when the event library was -initialized, you really only need to call EVT_joySetLowerRight since the -upper left position is usually always 0,0 on most joysticks. However, the -safest procedure is to call all three calibration functions. - -SEE ALSO: -EVT_joySetUpperLeft, EVT_joySetCenter, EVT_joyIsPresent -****************************************************************************/ -void EVTAPI EVT_joySetLowerRight(void) -{ -} - -/**************************************************************************** -DESCRIPTION: -Calibrates the joystick center position - -HEADER: -event.h - -REMARKS: -This function can be used to zero in on better joystick calibration factors, -which may work better than the default simplistic calibration (which assumes -the joystick is centered when the event library is initialised). -To use this function, ask the user to hold the stick in the center -position and then have them press a key or button. and then call this -function. This function will then read the joystick and update the -calibration factors. - -Usually, assuming that the stick was centered when the event library was -initialized, you really only need to call EVT_joySetLowerRight since the -upper left position is usually always 0,0 on most joysticks. However, the -safest procedure is to call all three calibration functions. - -SEE ALSO: -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 deleted file mode 100644 index 59d9aa0c7c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/ntservc.c +++ /dev/null @@ -1,258 +0,0 @@ -/**************************************************************************** -* -* SciTech Display Doctor -* -* Copyright (C) 1991-2001 SciTech Software, Inc. -* All rights reserved. -* -* ====================================================================== -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* | | -* |This copyrighted computer code is a proprietary trade secret of | -* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 | -* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, | -* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS | -* |STRICTLY PROHIBITED BY LAW. Unless you have current, express | -* |written authorization from SciTech to possess or use this code, you | -* |may be subject to civil and/or criminal penalties. | -* | | -* |If you received this code in error or you would like to report | -* |improper use, please immediately contact SciTech Software, Inc. at | -* |530-894-8400. | -* | | -* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW| -* ====================================================================== -* -* Language: ANSI C -* Environment: Windows NT, Windows 2K or Windows XP. -* -* Description: Main module to do the installation of the SDD and GLDirect -* device driver components under Windows NT/2K/XP. -* -****************************************************************************/ - -#include "pmapi.h" -#include "win32/oshdr.h" - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -PARAMETERS: -szDriverName - Actual name of the driver to install in the system -szServiceName - Name of the service to create -szLoadGroup - Load group for the driver (NULL for normal drivers) -dwServiceType - Service type to create - -RETURNS: -True on success, false on failure. - -REMARKS: -This function does all the work to install the driver into the system. -The driver is not however activated; for that you must use the Start_SddFilt -function. -****************************************************************************/ -ulong PMAPI PM_installService( - const char *szDriverName, - const char *szServiceName, - const char *szLoadGroup, - ulong dwServiceType) -{ - SC_HANDLE scmHandle; - SC_HANDLE driverHandle; - char szDriverPath[MAX_PATH]; - HKEY key; - char keyPath[MAX_PATH]; - ulong status; - - /* Obtain a handle to the service control manager requesting all access */ - if ((scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) - return GetLastError(); - - /* 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. */ - 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. */ - if (!driverHandle) { - status = GetLastError(); - CloseServiceHandle(scmHandle); - return status; - } - - /* 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. */ - 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 */ - RegCloseKey(key); - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return ERROR_SUCCESS; -} - -/**************************************************************************** -PARAMETERS: -szServiceName - Name of the service to start - -RETURNS: -True on success, false on failure. - -REMARKS: -This function is used to start the specified service and make it active. -****************************************************************************/ -ulong PMAPI PM_startService( - const char *szServiceName) -{ - SC_HANDLE scmHandle; - SC_HANDLE driverHandle; - SERVICE_STATUS serviceStatus; - ulong status; - - /* Obtain a handle to the service control manager requesting all access */ - if ((scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) - return GetLastError(); - - /* Open the service with the Service Control Manager. */ - if ((driverHandle = OpenService(scmHandle,szServiceName,SERVICE_ALL_ACCESS)) == NULL) { - status = GetLastError(); - CloseServiceHandle(scmHandle); - return status; - } - - /* 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; - } - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return ERROR_SUCCESS; -} - -/**************************************************************************** -PARAMETERS: -szServiceName - Name of the service to stop - -RETURNS: -True on success, false on failure. - -REMARKS: -This function is used to stop the specified service and disable it. -****************************************************************************/ -ulong PMAPI PM_stopService( - const char *szServiceName) -{ - SC_HANDLE scmHandle; - SC_HANDLE driverHandle; - SERVICE_STATUS serviceStatus; - ulong status; - - /* Obtain a handle to the service control manager requesting all access */ - if ((scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) - return GetLastError(); - - /* Open the service with the Service Control Manager. */ - if ((driverHandle = OpenService(scmHandle,szServiceName,SERVICE_ALL_ACCESS)) == NULL) { - status = GetLastError(); - CloseServiceHandle(scmHandle); - return status; - } - - /* Stop the service from running */ - if (!ControlService(driverHandle, SERVICE_CONTROL_STOP, &serviceStatus)) { - status = GetLastError(); - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return status; - } - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return ERROR_SUCCESS; -} - -/**************************************************************************** -PARAMETERS: -szServiceName - Name of the service to remove - -RETURNS: -True on success, false on failure. - -REMARKS: -This function is used to remove a service completely from the system. -****************************************************************************/ -ulong PMAPI PM_removeService( - const char *szServiceName) -{ - SC_HANDLE scmHandle; - SC_HANDLE driverHandle; - ulong status; - - /* Obtain a handle to the service control manager requesting all access */ - if ((scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) - return GetLastError(); - - /* Open the service with the Service Control Manager. */ - if ((driverHandle = OpenService(scmHandle,szServiceName,SERVICE_ALL_ACCESS)) == NULL) { - status = GetLastError(); - CloseServiceHandle(scmHandle); - return status; - } - - /* Remove the service */ - if (!DeleteService(driverHandle)) { - 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 deleted file mode 100644 index 0c59e9006f..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/oshdr.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Win32 -* -* Description: Include file to include all OS specific header files. -* -****************************************************************************/ - -#define WIN32_LEAN_AND_MEAN -#define STRICT -#include -#include -#include -#define NONAMELESSUNION -#include "pm/ddraw.h" - -/* Macros to save and restore the default control word. Windows 9x has - * some bugs in it such that calls to load any DLL's which load 16-bit - * DLL's cause the floating point control word to get trashed. We fix - * this by saving and restoring the control word across problematic - * calls. - */ - -#if defined(__INTEL__) -#define GET_DEFAULT_CW() \ -{ \ - if (_PM_cw_default == 0) \ - _PM_cw_default = _control87(0,0); \ -} -#define RESET_DEFAULT_CW() \ - _control87(_PM_cw_default,0xFFFFFFFF) -#else -#define GET_DEFAULT_CW() -#define RESET_DEFAULT_CW() -#endif - -/* Custom window messages */ - -#define WM_DO_SUSPEND_APP WM_USER -#define WM_PM_LEAVE_FULLSCREEN 0 -#define WM_PM_RESTORE_FULLSCREEN 1 - -/* Macro for disabling AutoPlay on a use system */ - -#define AUTOPLAY_DRIVE_CDROM 0x20 - -/*--------------------------- Global Variables ----------------------------*/ - -#ifdef __INTEL__ -extern uint _PM_cw_default; /* Default FPU control word */ -#endif -extern int _PM_deskX,_PM_deskY; /* Desktop dimensions */ -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 deleted file mode 100644 index 1ffdbccabc..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/pm.c +++ /dev/null @@ -1,1459 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Win32 -* -* Description: Implementation for the OS Portability Manager Library, which -* contains functions to implement OS specific services in a -* generic, cross platform API. Porting the OS Portability -* Manager library is the first step to porting any SciTech -* products to a new platform. -* -****************************************************************************/ - -#define WIN32_LEAN_AND_MEAN -#define STRICT -#include -#include -#include -#include -#include -#include -#include "pmapi.h" -#include "drvlib/os/os.h" -#include "pm_help.h" - -/*--------------------------- Global variables ----------------------------*/ - -ibool _PM_haveWinNT; /* True if we are running on NT */ -static uint VESABuf_len = 1024; /* Length of the VESABuf buffer */ -static void *VESABuf_ptr = NULL;/* Near pointer to VESABuf */ -static uint VESABuf_rseg; /* Real mode segment of VESABuf */ -static uint VESABuf_roff; /* Real mode offset of VESABuf */ -HANDLE _PM_hDevice = NULL; /* Handle to Win32 VxD */ -static ibool inited = false; /* Flags if we are initialised */ -static void (PMAPIP fatalErrorCleanup)(void) = NULL; - -static char *szMachineNameKey = "System\\CurrentControlSet\\control\\ComputerName\\ComputerName"; -static char *szMachineNameKeyNT = "System\\CurrentControlSet\\control\\ComputerName\\ActiveComputerName"; -static char *szMachineName = "ComputerName"; - -/*----------------------------- Implementation ----------------------------*/ - -/* Macro to check for a valid, loaded version of PMHELP. We check this - * on demand when we need these services rather than when PM_init() is - * called because if we are running on DirectDraw we don't need PMHELP.VXD. - */ - -#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!"); \ -} - -/**************************************************************************** -REMARKS: -Initialise the PM library and connect to our helper device driver. If we -cannot connect to our helper device driver, we bail out with an error -message. Our Windows 9x VxD is dynamically loadable, so it can be loaded -after the system has started. -****************************************************************************/ -void PMAPI PM_init(void) -{ - DWORD inBuf[1]; /* Buffer to receive data from VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - char cntPath[PM_MAX_PATH]; - char *env; - - /* Create a file handle for the static VxD if possible, otherwise - * dynamically load the PMHELP helper VxD. Note that if an old version - * 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; - } -} - -/**************************************************************************** -REMARKS: -We do have BIOS access under Windows 9x, but not under Windows NT. -****************************************************************************/ -int PMAPI PM_setIOPL( - int iopl) -{ - DWORD inBuf[1]; /* Buffer to receive data from VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - static int cntIOPL = 0; - int oldIOPL = cntIOPL; - - /* 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; - } - - /* We always have IOPL on Windows 9x */ - return 3; -} - -/**************************************************************************** -REMARKS: -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; - else - return _PM_hDevice != INVALID_HANDLE_VALUE; -} - -/**************************************************************************** -REMARKS: -Return the operating system type identifier. -****************************************************************************/ -long PMAPI PM_getOSType(void) -{ - if ((GetVersion() & 0x80000000UL) == 0) - return ___drv_os_type = _OS_WINNT; - else - return ___drv_os_type = _OS_WIN95; -} - -/**************************************************************************** -REMARKS: -Return the runtime type identifier. -****************************************************************************/ -int PMAPI PM_getModeType(void) -{ - return PM_386; -} - -/**************************************************************************** -REMARKS: -Add a file directory separator to the end of the filename. -****************************************************************************/ -void PMAPI PM_backslash( - char *s) -{ - uint pos = strlen(s); - if (s[pos-1] != '\\') { - s[pos] = '\\'; - s[pos+1] = '\0'; - } -} - -/**************************************************************************** -REMARKS: -Add a user defined PM_fatalError cleanup function. -****************************************************************************/ -void PMAPI PM_setFatalErrorCleanup( - void (PMAPIP cleanup)(void)) -{ - fatalErrorCleanup = cleanup; -} - -/**************************************************************************** -REMARKS: -Report a fatal error condition and halt the program. -****************************************************************************/ -void PMAPI PM_fatalError( - const char *msg) -{ - if (fatalErrorCleanup) - fatalErrorCleanup(); - MessageBox(NULL,msg,"Fatal Error!", MB_ICONEXCLAMATION); - exit(1); -} - -/**************************************************************************** -REMARKS: -Allocate the real mode VESA transfer buffer for communicating with the BIOS. -****************************************************************************/ -void * PMAPI PM_getVESABuf( - uint *len, - uint *rseg, - uint *roff) -{ - DWORD outBuf[4]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - /* We require the helper VxD to be loaded staticly in order to support - * the VESA transfer buffer. We do not support dynamically allocating - * real mode memory buffers from Win32 programs (we need a 16-bit DLL - * for this, and Windows 9x becomes very unstable if you free the - * memory blocks out of order). - */ - if (!inited) - 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]; - } - } - *len = VESABuf_len; - *rseg = VESABuf_rseg; - *roff = VESABuf_roff; - return VESABuf_ptr; -} - -/**************************************************************************** -REMARKS: -Check if a key has been pressed. -****************************************************************************/ -int PMAPI PM_kbhit(void) -{ - /* Not used in Windows */ - return true; -} - -/**************************************************************************** -REMARKS: -Wait for and return the next keypress. -****************************************************************************/ -int PMAPI PM_getch(void) -{ - /* Not used in Windows */ - return 0xD; -} - -/**************************************************************************** -REMARKS: -Set the location of the OS console cursor. -****************************************************************************/ -void PM_setOSCursorLocation( - int x, - int y) -{ - /* Nothing to do for Windows */ - (void)x; - (void)y; -} - -/**************************************************************************** -REMARKS: -Set the width of the OS console. -****************************************************************************/ -void PM_setOSScreenWidth( - int width, - int height) -{ - /* Nothing to do for Windows */ - (void)width; - (void)height; -} - -/**************************************************************************** -REMARKS: -Set the real time clock handler (used for software stereo modes). -****************************************************************************/ -ibool PMAPI PM_setRealTimeClockHandler( - PM_intHandler ih, - int frequency) -{ - /* We do not support this from Win32 programs. Rather the VxD handles - * this stuff it will take care of hooking the stereo flip functions at - * the VxD level. - */ - (void)ih; - (void)frequency; - return false; -} - -/**************************************************************************** -REMARKS: -Set the real time clock frequency (for stereo modes). -****************************************************************************/ -void PMAPI PM_setRealTimeClockFrequency( - int frequency) -{ - /* Not supported under Win32 */ - (void)frequency; -} - -/**************************************************************************** -REMARKS: -Restore the original real time clock handler. -****************************************************************************/ -void PMAPI PM_restoreRealTimeClockHandler(void) -{ - /* Not supported under Win32 */ -} - -/**************************************************************************** -REMARKS: -Return the current operating system path or working directory. -****************************************************************************/ -char * PMAPI PM_getCurrentPath( - char *path, - int maxLen) -{ - return getcwd(path,maxLen); -} - -/**************************************************************************** -REMARKS: -Query a string from the registry (extended version). -****************************************************************************/ -static ibool REG_queryStringEx( - HKEY hKey, - const char *szValue, - char *value, - ulong size) -{ - DWORD type; - - if (RegQueryValueEx(hKey,(PCHAR)szValue,(PDWORD)NULL,(PDWORD)&type,(LPBYTE)value,(PDWORD)&size) == ERROR_SUCCESS) - return true; - return false; -} - -/**************************************************************************** -REMARKS: -Query a string from the registry. -****************************************************************************/ -static ibool REG_queryString( - const char *szKey, - const char *szValue, - char *value, - DWORD size) -{ - HKEY hKey; - ibool status = false; - - memset(value,0,sizeof(value)); - if (RegOpenKey(HKEY_LOCAL_MACHINE,szKey,&hKey) == ERROR_SUCCESS) { - status = REG_queryStringEx(hKey,szValue,value,size); - RegCloseKey(hKey); - } - return status; -} - -/**************************************************************************** -REMARKS: -Return the drive letter for the boot drive. -****************************************************************************/ -char PMAPI PM_getBootDrive(void) -{ - static char path[256]; - GetSystemDirectory(path,sizeof(path)); - return path[0]; -} - -/**************************************************************************** -REMARKS: -Return the path to the VBE/AF driver files. -****************************************************************************/ -const char * PMAPI PM_getVBEAFPath(void) -{ - return "c:\\"; -} - -/**************************************************************************** -REMARKS: -Return the path to the Nucleus driver files. -****************************************************************************/ -const char * PMAPI PM_getNucleusPath(void) -{ - static char path[256]; - char *env; - - if ((env = getenv("NUCLEUS_PATH")) != NULL) - return env; - GetSystemDirectory(path,sizeof(path)); - strcat(path,"\\nucleus"); - return path; -} - -/**************************************************************************** -REMARKS: -Return the path to the Nucleus configuration files. -****************************************************************************/ -const char * PMAPI PM_getNucleusConfigPath(void) -{ - static char path[256]; - strcpy(path,PM_getNucleusPath()); - PM_backslash(path); - strcat(path,"config"); - return path; -} - -/**************************************************************************** -REMARKS: -Return a unique identifier for the machine if possible. -****************************************************************************/ -const char * PMAPI PM_getUniqueID(void) -{ - return PM_getMachineName(); -} - -/**************************************************************************** -REMARKS: -Get the name of the machine on the network. -****************************************************************************/ -const char * PMAPI PM_getMachineName(void) -{ - static char name[256]; - - if (REG_queryString(szMachineNameKey,szMachineName,name,sizeof(name))) - return name; - if (REG_queryString(szMachineNameKeyNT,szMachineName,name,sizeof(name))) - return name; - return "Unknown"; -} - -/**************************************************************************** -REMARKS: -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 */ - return PM_mapPhysicalAddr(0x400, 0x1000, true); - } - else { - /* For Windows 9x we can access this memory directly */ - return (void*)0x400; - } -} - -/**************************************************************************** -REMARKS: -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 */ - 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; - } -} - -/**************************************************************************** -REMARKS: -Map a physical address to a linear address in the callers process. -****************************************************************************/ -void * PMAPI PM_mapPhysicalAddr( - ulong base, - ulong limit, - ibool isCached) -{ - DWORD inBuf[3]; /* Buffer to send data to VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - if (!inited) - 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]; - return NULL; -} - -/**************************************************************************** -REMARKS: -Free a physical address mapping allocated by PM_mapPhysicalAddr. -****************************************************************************/ -void PMAPI PM_freePhysicalAddr( - void *ptr, - ulong limit) -{ - /* We never free the mappings under Win32 (the VxD tracks them and - * reissues the same mappings until the system is rebooted). - */ - (void)ptr; - (void)limit; -} - -/**************************************************************************** -REMARKS: -Find the physical address of a linear memory address in current process. -****************************************************************************/ -ulong PMAPI PM_getPhysicalAddr( - void *p) -{ - DWORD inBuf[1]; /* Buffer to send data to VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - if (!inited) - 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]; - return 0xFFFFFFFFUL; -} - -/**************************************************************************** -REMARKS: -Find the physical address of a linear memory address in current process. -****************************************************************************/ -ibool PMAPI PM_getPhysicalAddrRange( - void *p, - ulong length, - ulong *physAddress) -{ - DWORD inBuf[3]; /* Buffer to send data to VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - if (!inited) - 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]; - return false; -} - -/**************************************************************************** -REMARKS: -Sleep for the specified number of milliseconds. -****************************************************************************/ -void PMAPI PM_sleep( - ulong milliseconds) -{ - Sleep(milliseconds); -} - -/**************************************************************************** -REMARKS: -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. */ - switch (port) { - case 0: return 0x3F8; - case 1: return 0x2F8; - case 2: return 0x3E8; - case 3: return 0x2E8; - } - return 0; -} - -/**************************************************************************** -REMARKS: -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. */ - switch (port) { - case 0: return 0x3BC; - case 1: return 0x378; - case 2: return 0x278; - } - return 0; -} - -/**************************************************************************** -REMARKS: -Allocate a block of shared memory. For Win9x we allocate shared memory -as locked, global memory that is accessible from any memory context -(including interrupt time context), which allows us to load our important -data structure and code such that we can access it directly from a ring -0 interrupt context. -****************************************************************************/ -void * PMAPI PM_mallocShared( - long size) -{ - DWORD inBuf[1]; /* Buffer to send data to VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - inBuf[0] = size; - CHECK_FOR_PMHELP(); - if (DeviceIoControl(_PM_hDevice, PMHELP_MALLOCSHARED32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return (void*)outBuf[0]; - return NULL; -} - -/**************************************************************************** -REMARKS: -Free a block of shared memory. -****************************************************************************/ -void PMAPI PM_freeShared( - void *ptr) -{ - DWORD inBuf[1]; /* Buffer to send data to VxD */ - - inBuf[0] = (ulong)ptr; - CHECK_FOR_PMHELP(); - DeviceIoControl(_PM_hDevice, PMHELP_FREESHARED32, inBuf, sizeof(inBuf), NULL, 0, NULL, NULL); -} - -/**************************************************************************** -REMARKS: -Map a linear memory address to the calling process address space. The -address will have been allocated in another process using the -PM_mapPhysicalAddr function. -****************************************************************************/ -void * PMAPI PM_mapToProcess( - void *base, - ulong limit) -{ - (void)base; - (void)limit; - return base; -} - -/**************************************************************************** -REMARKS: -Map a real mode pointer to a protected mode pointer. -****************************************************************************/ -void * PMAPI PM_mapRealPointer( - uint r_seg, - uint r_off) -{ - return (void*)(MK_PHYS(r_seg,r_off)); -} - -/**************************************************************************** -REMARKS: -Allocate a block of real mode memory -****************************************************************************/ -void * PMAPI PM_allocRealSeg( - uint size, - uint *r_seg, - uint *r_off) -{ - /* We do not support dynamically allocating real mode memory buffers - * from Win32 programs (we need a 16-bit DLL for this, and Windows - * 9x becomes very unstable if you free the memory blocks out of order). - */ - (void)size; - (void)r_seg; - (void)r_off; - return NULL; -} - -/**************************************************************************** -REMARKS: -Free a block of real mode memory. -****************************************************************************/ -void PMAPI PM_freeRealSeg( - void *mem) -{ - /* Not supported in Windows */ - (void)mem; -} - -/**************************************************************************** -REMARKS: -Issue a real mode interrupt (parameters in DPMI compatible structure) -****************************************************************************/ -void PMAPI DPMI_int86( - int intno, - DPMI_regs *regs) -{ - DWORD inBuf[2]; /* Buffer to send data to VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - if (!inited) - PM_init(); - inBuf[0] = intno; - inBuf[1] = (ulong)regs; - CHECK_FOR_PMHELP(); - DeviceIoControl(_PM_hDevice, PMHELP_DPMIINT8632, inBuf, sizeof(inBuf), - NULL, 0, &count, NULL); -} - -/**************************************************************************** -REMARKS: -Issue a real mode interrupt. -****************************************************************************/ -int PMAPI PM_int86( - int intno, - RMREGS *in, - RMREGS *out) -{ - DWORD inBuf[3]; /* Buffer to send data to VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - if (!inited) - 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]; - return 0; -} - -/**************************************************************************** -REMARKS: -Issue a real mode interrupt. -****************************************************************************/ -int PMAPI PM_int86x( - int intno, - RMREGS *in, - RMREGS *out, - RMSREGS *sregs) -{ - DWORD inBuf[4]; /* Buffer to send data to VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - if (!inited) - 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]; - return 0; -} - -/**************************************************************************** -REMARKS: -Call a real mode far function. -****************************************************************************/ -void PMAPI PM_callRealMode( - uint seg, - uint off, - RMREGS *in, - RMSREGS *sregs) -{ - DWORD inBuf[4]; /* Buffer to send data to VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - if (!inited) - 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); -} - -/**************************************************************************** -REMARKS: -Return the amount of available memory. -****************************************************************************/ -void PMAPI PM_availableMemory( - ulong *physical, - ulong *total) -{ - /* We don't support this under Win32 at the moment */ - *physical = *total = 0; -} - -/**************************************************************************** -REMARKS: -Allocate a block of locked, physical memory for DMA operations. -****************************************************************************/ -void * PMAPI PM_allocLockedMem( - uint size, - ulong *physAddr, - ibool contiguous, - ibool below16M) -{ - DWORD inBuf[4]; /* Buffer to send data to VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - if (!inited) - 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]; - return NULL; -} - -/**************************************************************************** -REMARKS: -Free a block of locked physical memory. -****************************************************************************/ -void PMAPI PM_freeLockedMem( - void *p, - uint size, - ibool contiguous) -{ - DWORD inBuf[3]; /* Buffer to send data to VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - if (!inited) - 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); -} - -/**************************************************************************** -REMARKS: -Allocates a page aligned and page sized block of memory -****************************************************************************/ -void * PMAPI PM_allocPage( - ibool locked) -{ - DWORD inBuf[2]; /* Buffer to send data to VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - if (!inited) - 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]; - return NULL; -} - -/**************************************************************************** -REMARKS: -Free a page aligned and page sized block of memory -****************************************************************************/ -void PMAPI PM_freePage( - void *p) -{ - DWORD inBuf[1]; /* Buffer to send data to VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - if (!inited) - PM_init(); - inBuf[0] = (ulong)p; - CHECK_FOR_PMHELP(); - DeviceIoControl(_PM_hDevice, PMHELP_FREEPAGE32, inBuf, sizeof(inBuf), - NULL, 0, &count, NULL); -} - -/**************************************************************************** -REMARKS: -Lock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - DWORD inBuf[2]; /* Buffer to send data to VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - inBuf[0] = (ulong)p; - inBuf[1] = len; - inBuf[2] = (ulong)lh; - CHECK_FOR_PMHELP(); - if (DeviceIoControl(_PM_hDevice, PMHELP_LOCKDATAPAGES32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; - return 0; -} - -/**************************************************************************** -REMARKS: -Unlock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_unlockDataPages(void *p,uint len,PM_lockHandle *lh) -{ - DWORD inBuf[2]; /* Buffer to send data to VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - inBuf[0] = (ulong)p; - inBuf[1] = len; - inBuf[2] = (ulong)lh; - CHECK_FOR_PMHELP(); - if (DeviceIoControl(_PM_hDevice, PMHELP_UNLOCKDATAPAGES32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; - return 0; -} - -/**************************************************************************** -REMARKS: -Lock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_lockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - DWORD inBuf[2]; /* Buffer to send data to VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - inBuf[0] = (ulong)p; - inBuf[1] = len; - inBuf[2] = (ulong)lh; - CHECK_FOR_PMHELP(); - if (DeviceIoControl(_PM_hDevice, PMHELP_LOCKCODEPAGES32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; - return 0; -} - -/**************************************************************************** -REMARKS: -Unlock linear memory so it won't be paged. -****************************************************************************/ -int PMAPI PM_unlockCodePages(void (*p)(),uint len,PM_lockHandle *lh) -{ - DWORD inBuf[2]; /* Buffer to send data to VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - inBuf[0] = (ulong)p; - inBuf[1] = len; - inBuf[2] = (ulong)lh; - CHECK_FOR_PMHELP(); - if (DeviceIoControl(_PM_hDevice, PMHELP_UNLOCKCODEPAGES32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; - return 0; -} - -/**************************************************************************** -REMARKS: -Call the VBE/Core software interrupt to change display banks. -****************************************************************************/ -void PMAPI PM_setBankA( - int bank) -{ - RMREGS regs; - regs.x.ax = 0x4F05; - regs.x.bx = 0x0000; - regs.x.dx = bank; - PM_int86(0x10,®s,®s); -} - -/**************************************************************************** -REMARKS: -Call the VBE/Core software interrupt to change display banks. -****************************************************************************/ -void PMAPI PM_setBankAB( - int bank) -{ - RMREGS regs; - regs.x.ax = 0x4F05; - regs.x.bx = 0x0000; - regs.x.dx = bank; - PM_int86(0x10,®s,®s); - regs.x.ax = 0x4F05; - regs.x.bx = 0x0001; - regs.x.dx = bank; - PM_int86(0x10,®s,®s); -} - -/**************************************************************************** -REMARKS: -Call the VBE/Core software interrupt to change display start address. -****************************************************************************/ -void PMAPI PM_setCRTStart( - int x, - int y, - int waitVRT) -{ - RMREGS regs; - regs.x.ax = 0x4F07; - regs.x.bx = waitVRT; - regs.x.cx = x; - regs.x.dx = y; - PM_int86(0x10,®s,®s); -} - -/**************************************************************************** -REMARKS: -Enable write combining for the memory region. -****************************************************************************/ -ibool PMAPI PM_enableWriteCombine( - ulong base, - ulong length, - uint type) -{ - DWORD inBuf[3]; /* Buffer to send data to VxD */ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - if (!inited) - 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]; - return false; -} - -/**************************************************************************** -REMARKS: -Get the page directory base register value -****************************************************************************/ -ulong PMAPI _PM_getPDB(void) -{ - DWORD outBuf[1]; /* Buffer to receive data from VxD */ - DWORD count; /* Count of bytes returned from VxD */ - - CHECK_FOR_PMHELP(); - if (DeviceIoControl(_PM_hDevice, PMHELP_GETPDB32, NULL, 0, - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; - return 0; -} - -/**************************************************************************** -REMARKS: -Flush the translation lookaside buffer. -****************************************************************************/ -void PMAPI PM_flushTLB(void) -{ - CHECK_FOR_PMHELP(); - DeviceIoControl(_PM_hDevice, PMHELP_FLUSHTLB32, NULL, 0, NULL, 0, NULL, NULL); -} - -/**************************************************************************** -REMARKS: -Execute the POST on the secondary BIOS for a controller. -****************************************************************************/ -ibool PMAPI PM_doBIOSPOST( - ushort axVal, - ulong BIOSPhysAddr, - void *mappedBIOS, - ulong BIOSLen) -{ - /* This is never done by Win32 programs, but rather done by the VxD - * when the system boots. - */ - (void)axVal; - (void)BIOSPhysAddr; - (void)mappedBIOS; - (void)BIOSLen; - return false; -} - -/**************************************************************************** -REMARKS: -Load an OS specific shared library or DLL. If the OS does not support -shared libraries, simply return NULL. -****************************************************************************/ -PM_MODULE PMAPI PM_loadLibrary( - const char *szDLLName) -{ - return (PM_MODULE)LoadLibrary(szDLLName); -} - -/**************************************************************************** -REMARKS: -Get the address of a named procedure from a shared library. -****************************************************************************/ -void * PMAPI PM_getProcAddress( - PM_MODULE hModule, - const char *szProcName) -{ - return (void*)GetProcAddress((HINSTANCE)hModule,szProcName); -} - -/**************************************************************************** -REMARKS: -Unload a shared library. -****************************************************************************/ -void PMAPI PM_freeLibrary( - PM_MODULE hModule) -{ - FreeLibrary((HINSTANCE)hModule); -} - -/**************************************************************************** -REMARKS: -Internal function to convert the find data to the generic interface. -****************************************************************************/ -static void convertFindData( - PM_findData *findData, - WIN32_FIND_DATA *blk) -{ - ulong dwSize = findData->dwSize; - - memset(findData,0,findData->dwSize); - findData->dwSize = dwSize; - if (blk->dwFileAttributes & FILE_ATTRIBUTE_READONLY) - findData->attrib |= PM_FILE_READONLY; - if (blk->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - findData->attrib |= PM_FILE_DIRECTORY; - if (blk->dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) - findData->attrib |= PM_FILE_ARCHIVE; - if (blk->dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) - findData->attrib |= PM_FILE_HIDDEN; - if (blk->dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) - findData->attrib |= PM_FILE_SYSTEM; - findData->sizeLo = blk->nFileSizeLow; - findData->sizeHi = blk->nFileSizeHigh; - strncpy(findData->name,blk->cFileName,PM_MAX_PATH); - findData->name[PM_MAX_PATH-1] = 0; -} - -/**************************************************************************** -REMARKS: -Function to find the first file matching a search criteria in a directory. -****************************************************************************/ -void *PMAPI PM_findFirstFile( - const char *filename, - PM_findData *findData) -{ - WIN32_FIND_DATA blk; - HANDLE hfile; - - if ((hfile = FindFirstFile(filename,&blk)) != INVALID_HANDLE_VALUE) { - convertFindData(findData,&blk); - return (void*)hfile; - } - return PM_FILE_INVALID; -} - -/**************************************************************************** -REMARKS: -Function to find the next file matching a search criteria in a directory. -****************************************************************************/ -ibool PMAPI PM_findNextFile( - void *handle, - PM_findData *findData) -{ - WIN32_FIND_DATA blk; - - if (FindNextFile((HANDLE)handle,&blk)) { - convertFindData(findData,&blk); - return true; - } - return false; -} - -/**************************************************************************** -REMARKS: -Function to close the find process -****************************************************************************/ -void PMAPI PM_findClose( - void *handle) -{ - FindClose((HANDLE)handle); -} - -/**************************************************************************** -REMARKS: -Function to determine if a drive is a valid drive or not. Under Unix this -function will return false for anything except a value of 3 (considered -the root drive, and equivalent to C: for non-Unix systems). The drive -numbering is: - - 1 - Drive A: - 2 - Drive B: - 3 - Drive C: - etc - -****************************************************************************/ -ibool PMAPI PM_driveValid( - char drive) -{ - char buf[5]; - int type; - - sprintf(buf,"%c:\\", drive); - return ((type = GetDriveType(buf)) != 0 && type != 1); -} - -/**************************************************************************** -REMARKS: -Function to get the current working directory for the specififed drive. -Under Unix this will always return the current working directory regardless -of what the value of 'drive' is. -****************************************************************************/ -void PMAPI PM_getdcwd( - int drive, - 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. */ - char envname[4]; - - envname[0] = '='; - envname[1] = drive - 1 + 'A'; - 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); - } -} - -/**************************************************************************** -REMARKS: -Function to change the file attributes for a specific file. -****************************************************************************/ -void PMAPI PM_setFileAttr( - const char *filename, - uint attrib) -{ - DWORD attr = 0; - - if (attrib & PM_FILE_READONLY) - attr |= FILE_ATTRIBUTE_READONLY; - if (attrib & PM_FILE_ARCHIVE) - attr |= FILE_ATTRIBUTE_ARCHIVE; - if (attrib & PM_FILE_HIDDEN) - attr |= FILE_ATTRIBUTE_HIDDEN; - if (attrib & PM_FILE_SYSTEM) - attr |= FILE_ATTRIBUTE_SYSTEM; - SetFileAttributes((LPSTR)filename, attr); -} - -/**************************************************************************** -REMARKS: -Function to get the file attributes for a specific file. -****************************************************************************/ -uint PMAPI PM_getFileAttr( - const char *filename) -{ - DWORD attr = GetFileAttributes(filename); - uint attrib = 0; - - if (attr & FILE_ATTRIBUTE_READONLY) - attrib |= PM_FILE_READONLY; - if (attr & FILE_ATTRIBUTE_ARCHIVE) - attrib |= PM_FILE_ARCHIVE; - if (attr & FILE_ATTRIBUTE_HIDDEN) - attrib |= PM_FILE_HIDDEN; - if (attr & FILE_ATTRIBUTE_SYSTEM) - attrib |= PM_FILE_SYSTEM; - return attrib; -} - -/**************************************************************************** -REMARKS: -Function to create a directory. -****************************************************************************/ -ibool PMAPI PM_mkdir( - const char *filename) -{ - return CreateDirectory(filename,NULL); -} - -/**************************************************************************** -REMARKS: -Function to remove a directory. -****************************************************************************/ -ibool PMAPI PM_rmdir( - const char *filename) -{ - return RemoveDirectory(filename); -} - -/**************************************************************************** -REMARKS: -Function to get the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_getFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - HFILE f; - OFSTRUCT of; - FILETIME utcTime,localTime; - SYSTEMTIME sysTime; - ibool status = false; - - of.cBytes = sizeof(of); - if ((f = OpenFile(filename,&of,OF_READ)) == HFILE_ERROR) - return false; - if (!GetFileTime((HANDLE)f,NULL,NULL,&utcTime)) - goto Exit; - if (!gmTime) { - if (!FileTimeToLocalFileTime(&utcTime,&localTime)) - goto Exit; - } - else - localTime = utcTime; - if (!FileTimeToSystemTime(&localTime,&sysTime)) - goto Exit; - time->year = sysTime.wYear; - time->mon = sysTime.wMonth-1; - time->day = sysTime.wYear; - time->hour = sysTime.wHour; - time->min = sysTime.wMinute; - time->sec = sysTime.wSecond; - status = true; - -Exit: - CloseHandle((HANDLE)f); - return status; -} - -/**************************************************************************** -REMARKS: -Function to set the file time and date for a specific file. -****************************************************************************/ -ibool PMAPI PM_setFileTime( - const char *filename, - ibool gmTime, - PM_time *time) -{ - HFILE f; - OFSTRUCT of; - FILETIME utcTime,localTime; - SYSTEMTIME sysTime; - ibool status = false; - - of.cBytes = sizeof(of); - if ((f = OpenFile(filename,&of,OF_WRITE)) == HFILE_ERROR) - return false; - sysTime.wYear = time->year; - sysTime.wMonth = time->mon+1; - sysTime.wYear = time->day; - sysTime.wHour = time->hour; - sysTime.wMinute = time->min; - sysTime.wSecond = time->sec; - if (!SystemTimeToFileTime(&sysTime,&localTime)) - goto Exit; - if (!gmTime) { - if (!LocalFileTimeToFileTime(&localTime,&utcTime)) - goto Exit; - } - else - utcTime = localTime; - if (!SetFileTime((HANDLE)f,NULL,NULL,&utcTime)) - goto Exit; - status = true; - -Exit: - CloseHandle((HANDLE)f); - return status; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/vflat.c b/board/MAI/bios_emulator/scitech/src/pm/win32/vflat.c deleted file mode 100644 index 70491cdb80..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/vflat.c +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Dummy module; no virtual framebuffer for this OS -* -****************************************************************************/ - -#include "pmapi.h" - -ibool PMAPI VF_available(void) -{ - return false; -} - -void * PMAPI VF_init( - ulong baseAddr, - int bankSize, - int codeLen, - void *bankFunc) -{ - (void)baseAddr; - (void)bankSize; - (void)codeLen; - (void)bankFunc; - return NULL; -} - -void PMAPI VF_exit(void) -{ -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/win32/ztimer.c deleted file mode 100644 index 5a901a4422..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/ztimer.c +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** -* -* Ultra Long Period Timer -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Win32 -* -* Description: OS specific implementation for the Zen Timer functions. -* -****************************************************************************/ - -/*---------------------------- Global variables ---------------------------*/ - -static CPU_largeInteger countFreq; -static ibool havePerformanceCounter; -static ulong start,finish; - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Initialise the Zen Timer module internals. -****************************************************************************/ -void __ZTimerInit(void) -{ -#ifdef NO_ASSEMBLER - havePerformanceCounter = false; -#else - havePerformanceCounter = QueryPerformanceFrequency((LARGE_INTEGER*)&countFreq); -#endif -} - -/**************************************************************************** -REMARKS: -Start the Zen Timer counting. -****************************************************************************/ -static void __LZTimerOn( - LZTimerObject *tm) -{ - if (havePerformanceCounter) - QueryPerformanceCounter((LARGE_INTEGER*)&tm->start); - else - tm->start.low = timeGetTime(); -} - -/**************************************************************************** -REMARKS: -Compute the lap time since the timer was started. -****************************************************************************/ -static ulong __LZTimerLap( - LZTimerObject *tm) -{ - CPU_largeInteger tmLap,tmCount; - - if (havePerformanceCounter) { - 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; - } -} - -/**************************************************************************** -REMARKS: -Stop the Zen Timer counting. -****************************************************************************/ -static void __LZTimerOff( - LZTimerObject *tm) -{ - if (havePerformanceCounter) - QueryPerformanceCounter((LARGE_INTEGER*)&tm->end); - else - tm->end.low = timeGetTime(); -} - -/**************************************************************************** -REMARKS: -Compute the elapsed time in microseconds between start and end timings. -****************************************************************************/ -static ulong __LZTimerCount( - LZTimerObject *tm) -{ - CPU_largeInteger tmCount; - - if (havePerformanceCounter) { - _CPU_diffTime64(&tm->start,&tm->end,&tmCount); - return _CPU_calcMicroSec(&tmCount,countFreq.low); - } - else - return (tm->end.low - tm->start.low) * 1000L; -} - -/**************************************************************************** -REMARKS: -Define the resolution of the long period timer as microseconds per timer tick. -****************************************************************************/ -#define ULZTIMER_RESOLUTION 1000 - -/**************************************************************************** -REMARKS: -Read the Long Period timer from the OS -****************************************************************************/ -static ulong __ULZReadTime(void) -{ return timeGetTime(); } - -/**************************************************************************** -REMARKS: -Compute the elapsed time from the BIOS timer tick. Note that we check to see -whether a midnight boundary has passed, and if so adjust the finish time to -account for this. We cannot detect if more that one midnight boundary has -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/x11/event.c b/board/MAI/bios_emulator/scitech/src/pm/x11/event.c deleted file mode 100644 index b34bfac22f..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/x11/event.c +++ /dev/null @@ -1,307 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Unix / X11 -* -* Description: X11 event queue implementation for the MGL. -* This can be used both for windowed and fullscreen (DGA) modes. -* -****************************************************************************/ - -/*---------------------------- Global Variables ---------------------------*/ - -static ushort keyUpMsg[256] = {0};/* Table of key up messages */ -static int rangeX,rangeY; /* Range of mouse coordinates */ - -static Display *_EVT_dpy; -static Window _EVT_win; - -typedef struct { - int keycode; - int scancode; -} xkeymap; - -xkeymap xkeymaps[] = { - { 9, KB_esc}, - {24, KB_Q}, - {25, KB_W}, - {26, KB_E}, - {27, KB_R}, - {28, KB_T}, - {29, KB_Y}, - {30, KB_U}, - {31, KB_I}, - {32, KB_O}, - {33, KB_P}, -}; - -/*---------------------------- Implementation -----------------------------*/ - -/* These are not used under non-DOS systems */ -#define _EVT_disableInt() 1 -#define _EVT_restoreInt(flags) - -/**************************************************************************** -PARAMETERS: -scanCode - Scan code to test - -REMARKS: -This macro determines if a specified key is currently down at the -time that the call is made. -****************************************************************************/ -#define _EVT_isKeyDown(scanCode) (keyUpMsg[scanCode] != 0) - -/**************************************************************************** -REMARKS: -This function is used to return the number of ticks since system -startup in milliseconds. This should be the same value that is placed into -the time stamp fields of events, and is used to implement auto mouse down -events. -****************************************************************************/ -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); - return ((t.tv_sec * 1000 + (t.tv_usec/1000)) - starttime); -} - -static int getScancode(int keycode) -{ - return keycode-8; -} - -/**************************************************************************** -REMARKS: -Pumps all messages in the application message queue into our event queue. -****************************************************************************/ -#ifdef X11_CORE -static void _EVT_pumpX11Messages(void) -#else -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. */ - 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(); - - switch(ev.type){ - case KeyPress: - c = getScancode(ev.xkey.keycode); - evt.what = EVT_KEYDOWN; - evt.message = c << 8; - XLookupString(&ev.xkey, buf, 2, NULL, NULL); - evt.message |= buf[0]; - break; - case KeyRelease: - c = getScancode(ev.xkey.keycode); - evt.what = EVT_KEYUP; - evt.message = keyUpMsg[c]; - if(count < EVENTQSIZE) - 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; - }else if(ev.xbutton.button == 2){ - buts |= EVT_MIDDLEBUT; - evt.message = EVT_MIDDLEBMASK; - }else if(ev.xbutton.button == 3){ - 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; - }else if(ev.xbutton.button == 2){ - buts &= ~EVT_MIDDLEBUT; - evt.message = EVT_MIDDLEBMASK; - }else if(ev.xbutton.button == 3){ - buts &= ~EVT_RIGHTBUT; - evt.message = EVT_RIGHTBMASK; - } - evt.modifiers = modifiers | buts; - - break; - case MotionNotify: - evt.what = EVT_MOUSEMOVE; - evt.where_x = ev.xmotion.x; - evt.where_y = ev.xmotion.y; - evt.relative_x = evt.where_x - old_mx; - evt.relative_y = evt.where_y - old_my; - old_mx = evt.where_x; - old_my = evt.where_y; - break; - } - if (count < EVENTQSIZE) - addEvent(&evt); - } - -} - -/**************************************************************************** -REMARKS: -This macro/function is used to converts the scan codes reported by the -keyboard to our event libraries normalised format. We only have one scan -code for the 'A' key, and use shift modifiers to determine if it is a -Ctrl-F1, Alt-F1 etc. The raw scan codes from the keyboard work this way, -but the OS gives us 'cooked' scan codes, we have to translate them back -to the raw format. -****************************************************************************/ -#define _EVT_maskKeyCode(evt) - -/**************************************************************************** -REMARKS: -Safely abort the event module upon catching a fatal error. -****************************************************************************/ -void _EVT_abort() -{ - EVT_exit(); - PM_fatalError("Unhandled exception!"); -} - -/**************************************************************************** -PARAMETERS: -mouseMove - Callback function to call wheneve the mouse needs to be moved - -REMARKS: -Initiliase the event handling module. Here we install our mouse handling ISR -to be called whenever any button's are pressed or released. We also build -the free list of events in the event queue. - -We use handler number 2 of the mouse libraries interrupt handlers for our -event handling routines. -****************************************************************************/ -#ifdef X11_CORE -void EVTAPI EVT_initX11( -#else -void EVTAPI EVT_init( -#endif - _EVT_mouseMoveHandler mouseMove) -{ - int result, i,j,k; - XDeviceInfoPtr list,slist; - - /* Initialise the event queue */ - _mouseMove = mouseMove; - initEventQueue(); - memset(keyUpMsg,0,sizeof(keyUpMsg)); - - - /* query server for input extensions */ - result =XQueryExtension(_EVT_dpy,"XInputExtension",&i,&j,&k); - if(!result) { - fprintf(stderr,"Your server doesn't support XInput Extensions\n"); - fprintf(stderr,"X11 Joystick disabled\n"); - } - list = XListInputDevices(_EVT_dpy,&result); - if (!list) { - fprintf(stderr,"No extended input devices found !!\n"); - fprintf(stderr,"X11 Joystick disabled\n"); - } - - - /* Catch program termination signals so we can clean up properly */ - signal(SIGABRT, _EVT_abort); - signal(SIGFPE, _EVT_abort); - signal(SIGINT, _EVT_abort); -} - -/**************************************************************************** -REMARKS -Changes the range of coordinates returned by the mouse functions to the -specified range of values. This is used when changing between graphics -modes set the range of mouse coordinates for the new display mode. -****************************************************************************/ -void EVTAPI EVT_setMouseRange( - int xRes, - int yRes) -{ - rangeX = xRes; - rangeY = yRes; -} - -/**************************************************************************** -REMARKS: -Initiailises the internal event handling modules. The EVT_suspend function -can be called to suspend event handling (such as when shelling out to DOS), -and this function can be used to resume it again later. -****************************************************************************/ -void EVT_resume(void) -{ - /* Do nothing for non DOS systems */ -} - -/**************************************************************************** -REMARKS -Suspends all of our event handling operations. This is also used to -de-install the event handling code. -****************************************************************************/ -void EVT_suspend(void) -{ - /* Do nothing for non DOS systems */ -} - -/**************************************************************************** -REMARKS -Exits the event module for program terminatation. -****************************************************************************/ -void EVT_exit(void) -{ - /* Restore signal handlers */ - signal(SIGABRT, SIG_DFL); - signal(SIGFPE, SIG_DFL); - signal(SIGINT, SIG_DFL); - - /* TODO: Do any OS specific cleanup in here */ -} - -/**************************************************************************** -REMARKS -Sets the current X11 display -****************************************************************************/ -void EVT_setX11Display(Display *dpy, Window win) -{ - _EVT_dpy = dpy; - _EVT_win = win; -} diff --git a/board/MAI/bios_emulator/scitech/src/pm/x11/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/x11/oshdr.h deleted file mode 100644 index 45d7451be5..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/x11/oshdr.h +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: BeOS -* -* Description: Include file to include all OS specific header files. -* -****************************************************************************/ - -#include -#include -#include -#include -#ifdef USE_OS_JOYSTICK -#include -#include -#endif diff --git a/board/MAI/bios_emulator/scitech/src/pm/z_samples.vpj b/board/MAI/bios_emulator/scitech/src/pm/z_samples.vpj deleted file mode 100644 index 0c6c80f054..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/z_samples.vpj +++ /dev/null @@ -1,74 +0,0 @@ -[SciTech] -compiler=wc10- -targetos=d32 -[COMPILER] -version=5.0b -MACRO=enable_current_compiler\n -activeconfig=,getch.exe -FILTERNAME=Source Files\n -FILTERPATTERN=*.c;*.cpp;*.cxx;*.prg;*.pas;*.dpr;*.bas;*.java;*.sc;*.e;*.cob;*.html;*.rc\n -FILTERASSOCIATEFILETYPES=0 -FILTERAPPCOMMAND=\n -vcsproject=SCC:Perforce SCM://depot -vcslocalpath=SCC:Perforce SCM:c:\ -compile=concur|capture|:Compile:&Compile,dmake %n.obj -make=concur|capture|clear|saveall|:Build:&Build,dmake %b -rebuild=concur|capture|clear|saveall|:Rebuild:&Rebuild,dmake -u %b -debug=concur|capture|savenone|nochangedir|:Debug:&Debug,wdn %b -execute=hide|savenone|nochangedir|:Execute:E&xecute, -user1=hide|nochangedir|:User 1:User 1, -user2=hide|nochangedir|:User 2:User 2, -usertool_build_all=concur|capture|clear|savenone|:Build All:Build All,dmake all -usertool_rebuild_all=concur|capture|clear|savenone|:Rebuild All:Rebuild All,dmake -u all -usertool_clean_directory=concur|capture|savenone|:Clean Directory:&Clean Directory,dmake cleanexe -workingdir=. -includedirs=%(SCITECH)\include;%(PRIVATE)\include -reffile= -[FILES] -tests\altbrk.c -tests\altcrit.c -tests\biosptr.c -tests\block.c -tests\brk.c -tests\callreal.c -tests\checks.c -tests\cpu.c -tests\critical.c -tests\getch.c -tests\isvesa.c -tests\key.c -tests\key15.c -tests\memtest.c -tests\mouse.c -tests\rtc.c -tests\showpci.c -tests\tick.c -tests\timerc.c -tests\timercpp.cpp -tests\uswc.c -tests\vftest.c -tests\video.c -[ASSOCIATION] -[CONFIGURATIONS] -config=,altbrk.exe -config=,altcrit.exe -config=,biosptr.exe -config=,block.exe -config=,brk.exe -config=,callreal.exe -config=,cpu.exe -config=,critical.exe -config=,getch.exe -config=,isvesa.exe -config=,key.exe -config=,key15.exe -config=,memtest.exe -config=,mouse.exe -config=,rtc.exe -config=,showpci.exe -config=,tick.exe -config=,timerc.exe -config=,timercpp.exe -config=,uswc.exe -config=,vftest.exe -config=,video.exe diff --git a/board/MAI/bios_emulator/scitech/src/pm/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/ztimer.c deleted file mode 100644 index 5acf7b1f0c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/pm/ztimer.c +++ /dev/null @@ -1,516 +0,0 @@ -/**************************************************************************** -* -* SciTech OS Portability Manager Library -* -* ======================================================================== -* -* The contents of this file are subject to the SciTech MGL Public -* License Version 1.0 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.scitechsoft.com/mgl-license.txt -* -* Software distributed under the License is distributed on an -* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. -* -* The Initial Developer of the Original Code is SciTech Software, Inc. -* All Rights Reserved. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* -* Description: Module to implement high precision timing on each OS. -* -****************************************************************************/ - -#include "ztimer.h" -#include "pmapi.h" -#include "oshdr.h" - -/*---------------------------- Global variables ---------------------------*/ - -static LZTimerObject LZTimer; -static ulong start,finish; -#ifdef __INTEL__ -static long cpuSpeed = -1; -static ibool haveRDTSC = false; -#endif - -/*----------------------------- Implementation ----------------------------*/ - -/* External Intel assembler functions */ -#ifdef __INTEL__ -/* {secret} */ -void _ASMAPI _CPU_readTimeStamp(CPU_largeInteger *time); -/* {secret} */ -ulong _ASMAPI _CPU_diffTime64(CPU_largeInteger *t1,CPU_largeInteger *t2,CPU_largeInteger *t); -/* {secret} */ -ulong _ASMAPI _CPU_calcMicroSec(CPU_largeInteger *count,ulong freq); -#endif - -#if defined(__SMX32__) -#include "smx/ztimer.c" -#elif defined(__RTTARGET__) -#include "rttarget/ztimer.c" -#elif defined(__REALDOS__) -#include "dos/ztimer.c" -#elif defined(__NT_DRIVER__) -#include "ntdrv/ztimer.c" -#elif defined(__WIN32_VXD__) -#include "vxd/ztimer.c" -#elif defined(__WINDOWS32__) -#include "win32/ztimer.c" -#elif defined(__OS2_VDD__) -#include "vdd/ztimer.c" -#elif defined(__OS2__) -#include "os2/ztimer.c" -#elif defined(__LINUX__) -#include "linux/ztimer.c" -#elif defined(__QNX__) -#include "qnx/ztimer.c" -#elif defined(__BEOS__) -#include "beos/ztimer.c" -#else -#error Timer library not ported to this platform yet! -#endif - -/*------------------------ Public interface routines ----------------------*/ - -/**************************************************************************** -DESCRIPTION: -Initializes the Zen Timer library (extended) - -PARAMETERS: -accurate - True of the speed should be measured accurately - -HEADER: -ztimer.h - -REMARKS: -This function initializes the Zen Timer library, and /must/ be called before -any of the remaining Zen Timer library functions are called. The accurate -parameter is used to determine whether highly accurate timing should be -used or not. If high accuracy is needed, more time is spent profiling the -actual speed of the CPU so that we can obtain highly accurate timing -results, but the time spent in the initialisation routine will be -significantly longer (on the order of 5 seconds). -****************************************************************************/ -void ZAPI ZTimerInitExt( - ibool accurate) -{ - if (cpuSpeed == -1) { - __ZTimerInit(); -#ifdef __INTEL__ - cpuSpeed = CPU_getProcessorSpeedInHZ(accurate); - haveRDTSC = CPU_haveRDTSC() && (cpuSpeed > 0); -#endif - } -} - -/**************************************************************************** -DESCRIPTION: -Initializes the Zen Timer library. - -HEADER: -ztimer.h - -REMARKS: -This function initializes the Zen Timer library, and /must/ be called before -any of the remaining Zen Timer library functions are called. -****************************************************************************/ -void ZAPI ZTimerInit(void) -{ - ZTimerInitExt(false); -} - -/**************************************************************************** -DESCRIPTION: -Starts the Long Period Zen Timer counting. - -HEADER: -ztimer.h - -PARAMETERS: -tm - Timer object to start timing with - -REMARKS: -Starts the Long Period Zen Timer counting. Once you have started the timer, -you can stop it with LZTimerOff or you can latch the current count with -LZTimerLap. - -The Long Period Zen Timer uses a number of different high precision timing -mechanisms to obtain microsecond accurate timings results whenever possible. -The following different techniques are used depending on the operating -system, runtime environment and CPU on the target machine. If the target -system has a Pentium CPU installed which supports the Read Time Stamp -Counter instruction (RDTSC), the Zen Timer library will use this to -obtain the maximum timing precision available. - -Under 32-bit Windows, if the Pentium RDTSC instruction is not available, we -first try to use the Win32 QueryPerformanceCounter API, and if that is not -available we fall back on the timeGetTime API which is always supported. - -Under 32-bit DOS, if the Pentium RDTSC instruction is not available, we -then do all timing using the old style 8253 timer chip. The 8253 timer -routines provide highly accurate timings results in pure DOS mode, however -in a DOS box under Windows or other Operating Systems the virtualization -of the timer can produce inaccurate results. - -Note: Because the Long Period Zen Timer stores the results in a 32-bit - unsigned integer, you can only time periods of up to 2^32 microseconds, - or about 1hr 20mins. For timing longer periods use the Ultra Long - Period Zen Timer. - -SEE ALSO: -LZTimerOff, LZTimerLap, LZTimerCount -****************************************************************************/ -void ZAPI LZTimerOnExt( - LZTimerObject *tm) -{ -#ifdef __INTEL__ - if (haveRDTSC) { - _CPU_readTimeStamp(&tm->start); - } - else -#endif - __LZTimerOn(tm); -} - -/**************************************************************************** -DESCRIPTION: -Returns the current count for the Long Period Zen Timer and keeps it -running. - -HEADER: -ztimer.h - -PARAMETERS: -tm - Timer object to do lap timing with - -RETURNS: -Count that has elapsed in microseconds. - -REMARKS: -Returns the current count that has elapsed since the last call to -LZTimerOn in microseconds. The time continues to run after this function is -called so you can call this function repeatedly. - -SEE ALSO: -LZTimerOn, LZTimerOff, LZTimerCount -****************************************************************************/ -ulong ZAPI LZTimerLapExt( - LZTimerObject *tm) -{ -#ifdef __INTEL__ - CPU_largeInteger tmLap,tmCount; - - if (haveRDTSC) { - _CPU_readTimeStamp(&tmLap); - _CPU_diffTime64(&tm->start,&tmLap,&tmCount); - return _CPU_calcMicroSec(&tmCount,cpuSpeed); - } - else -#endif - return __LZTimerLap(tm); -} - -/**************************************************************************** -DESCRIPTION: -Stops the Long Period Zen Timer counting. - -HEADER: -ztimer.h - -PARAMETERS: -tm - Timer object to stop timing with - -REMARKS: -Stops the Long Period Zen Timer counting and latches the count. Once you -have stopped the timer you can read the count with LZTimerCount. If you need -highly accurate timing, you should use the on and off functions rather than -the lap function since the lap function does not subtract the overhead of -the function calls from the timed count. - -SEE ALSO: -LZTimerOn, LZTimerLap, LZTimerCount -****************************************************************************/ -void ZAPI LZTimerOffExt( - LZTimerObject *tm) -{ -#ifdef __INTEL__ - if (haveRDTSC) { - _CPU_readTimeStamp(&tm->end); - } - else -#endif - __LZTimerOff(tm); -} - -/**************************************************************************** -DESCRIPTION: -Returns the current count for the Long Period Zen Timer. - -HEADER: -ztimer.h - -PARAMETERS: -tm - Timer object to compute the elapsed time with. - -RETURNS: -Count that has elapsed in microseconds. - -REMARKS: -Returns the current count that has elapsed between calls to -LZTimerOn and LZTimerOff in microseconds. - -SEE ALSO: -LZTimerOn, LZTimerOff, LZTimerLap -****************************************************************************/ -ulong ZAPI LZTimerCountExt( - LZTimerObject *tm) -{ -#ifdef __INTEL__ - CPU_largeInteger tmCount; - - if (haveRDTSC) { - _CPU_diffTime64(&tm->start,&tm->end,&tmCount); - return _CPU_calcMicroSec(&tmCount,cpuSpeed); - } - else -#endif - return __LZTimerCount(tm); -} - -/**************************************************************************** -DESCRIPTION: -Starts the Long Period Zen Timer counting. - -HEADER: -ztimer.h - -REMARKS: -Obsolete function. You should use the LZTimerOnExt function instead -which allows for multiple timers running at the same time. -****************************************************************************/ -void ZAPI LZTimerOn(void) -{ LZTimerOnExt(&LZTimer); } - -/**************************************************************************** -DESCRIPTION: -Returns the current count for the Long Period Zen Timer and keeps it -running. - -HEADER: -ztimer.h - -RETURNS: -Count that has elapsed in microseconds. - -REMARKS: -Obsolete function. You should use the LZTimerLapExt function instead -which allows for multiple timers running at the same time. -****************************************************************************/ -ulong ZAPI LZTimerLap(void) -{ return LZTimerLapExt(&LZTimer); } - -/**************************************************************************** -DESCRIPTION: -Stops the Long Period Zen Timer counting. - -HEADER: -ztimer.h - -REMARKS: -Obsolete function. You should use the LZTimerOffExt function instead -which allows for multiple timers running at the same time. -****************************************************************************/ -void ZAPI LZTimerOff(void) -{ LZTimerOffExt(&LZTimer); } - -/**************************************************************************** -DESCRIPTION: -Returns the current count for the Long Period Zen Timer. - -HEADER: -ztimer.h - -RETURNS: -Count that has elapsed in microseconds. - -REMARKS: -Obsolete function. You should use the LZTimerCountExt function instead -which allows for multiple timers running at the same time. -****************************************************************************/ -ulong ZAPI LZTimerCount(void) -{ return LZTimerCountExt(&LZTimer); } - -/**************************************************************************** -DESCRIPTION: -Starts the Ultra Long Period Zen Timer counting. - -HEADER: -ztimer.h - -REMARKS: -Starts the Ultra Long Period Zen Timer counting. Once you have started the -timer, you can stop it with ULZTimerOff or you can latch the current count -with ULZTimerLap. - -The Ultra Long Period Zen Timer uses the available operating system services -to obtain accurate timings results with as much precision as the operating -system provides, but with enough granularity to time longer periods of -time than the Long Period Zen Timer. Note that the resolution of the timer -ticks is not constant between different platforms, and you should use the -ULZTimerResolution function to determine the number of seconds in a single -tick of the timer, and use this to convert the timer counts to seconds. - -Under 32-bit Windows, we use the timeGetTime function which provides a -resolution of 1 millisecond (0.001 of a second). Given that the timer -count is returned as an unsigned 32-bit integer, this we can time intervals -that are a maximum of 2^32 milliseconds in length (or about 1,200 hours or -50 days!). - -Under 32-bit DOS, we use the system timer tick which runs at 18.2 times per -second. Given that the timer count is returned as an unsigned 32-bit integer, -this we can time intervals that are a maximum of 2^32 * (1/18.2) in length -(or about 65,550 hours or 2731 days!). - -SEE ALSO: -ULZTimerOff, ULZTimerLap, ULZTimerCount, ULZElapsedTime, ULZReadTime -****************************************************************************/ -void ZAPI ULZTimerOn(void) -{ start = __ULZReadTime(); } - -/**************************************************************************** -DESCRIPTION: -Returns the current count for the Ultra Long Period Zen Timer and keeps it -running. - -HEADER: -ztimer.h - -RETURNS: -Count that has elapsed in resolution counts. - -REMARKS: -Returns the current count that has elapsed since the last call to -ULZTimerOn in microseconds. The time continues to run after this function is -called so you can call this function repeatedly. - -SEE ALSO: -ULZTimerOn, ULZTimerOff, ULZTimerCount -****************************************************************************/ -ulong ZAPI ULZTimerLap(void) -{ return (__ULZReadTime() - start); } - -/**************************************************************************** -DESCRIPTION: -Stops the Long Period Zen Timer counting. - -HEADER: -ztimer.h - -REMARKS: -Stops the Ultra Long Period Zen Timer counting and latches the count. Once -you have stopped the timer you can read the count with ULZTimerCount. - -SEE ALSO: -ULZTimerOn, ULZTimerLap, ULZTimerCount -****************************************************************************/ -void ZAPI ULZTimerOff(void) -{ finish = __ULZReadTime(); } - -/**************************************************************************** -DESCRIPTION: -Returns the current count for the Ultra Long Period Zen Timer. - -HEADER: -ztimer.h - -RETURNS: -Count that has elapsed in resolution counts. - -REMARKS: -Returns the current count that has elapsed between calls to -ULZTimerOn and ULZTimerOff in resolution counts. - -SEE ALSO: -ULZTimerOn, ULZTimerOff, ULZTimerLap, ULZTimerResolution -****************************************************************************/ -ulong ZAPI ULZTimerCount(void) -{ return (finish - start); } - -/**************************************************************************** -DESCRIPTION: -Reads the current time from the Ultra Long Period Zen Timer. - -HEADER: -ztimer.h - -RETURNS: -Current timer value in resolution counts. - -REMARKS: -Reads the current Ultra Long Period Zen Timer and returns it’s current -count. You can use the ULZElapsedTime function to find the elapsed time -between two timer count readings. - -SEE ALSO: -ULZElapsedTime, ULZTimerResolution -****************************************************************************/ -ulong ZAPI ULZReadTime(void) -{ return __ULZReadTime(); } - -/**************************************************************************** -DESCRIPTION: -Compute the elapsed time between two timer counts. - -HEADER: -ztimer.h - -PARAMETERS: -start - Starting time for elapsed count -finish - Ending time for elapsed count - -RETURNS: -Elapsed timer in resolution counts. - -REMARKS: -Returns the elapsed time for the Ultra Long Period Zen Timer in units of the -timers resolution (1/18th of a second under DOS). This function correctly -computes the difference even if a midnight boundary has been crossed -during the timing period. - -SEE ALSO: -ULZReadTime, ULZTimerResolution -****************************************************************************/ -ulong ZAPI ULZElapsedTime( - ulong start, - ulong finish) -{ return __ULZElapsedTime(start,finish); } - -/**************************************************************************** -DESCRIPTION: -Returns the resolution of the Ultra Long Period Zen Timer. - -HEADER: -ztimer.h - -PARAMETERS: -resolution - Place to store the timer in microseconds per timer count. - -REMARKS: -Returns the resolution of the Ultra Long Period Zen Timer as a 32-bit -integer value measured in microseconds per timer count. - -SEE ALSO: -ULZReadTime, ULZElapsedTime, ULZTimerCount -****************************************************************************/ -void ZAPI ULZTimerResolution( - ulong *resolution) -{ *resolution = ULZTIMER_RESOLUTION; } diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/AsmMacros.h b/board/MAI/bios_emulator/scitech/src/v86bios/AsmMacros.h deleted file mode 100644 index 77c545aef4..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/AsmMacros.h +++ /dev/null @@ -1,450 +0,0 @@ -/* $XConsortium: AsmMacros.h /main/13 1996/10/25 11:33:12 kaleb $ */ -/* - * (c) Copyright 1993,1994 by David Wexelblat - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID WEXELBLAT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of David Wexelblat shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from David Wexelblat. - * - */ -/* - * Copyright 1997 - * Digital Equipment Corporation. All rights reserved. - * This software is furnished under license and may be used and copied only in - * accordance with the following terms and conditions. Subject to these - * conditions, you may download, copy, install, use, modify and distribute - * this software in source and/or binary form. No title or ownership is - * transferred hereby. - * - * 1) Any source code used, modified or distributed must reproduce and retain - * this copyright notice and list of conditions as they appear in the source - * file. - * - * 2) No right is granted to use any trade name, trademark, or logo of Digital - * Equipment Corporation. Neither the "Digital Equipment Corporation" name - * nor any trademark or logo of Digital Equipment Corporation may be used - * to endorse or promote products derived from this software without the - * prior written permission of Digital Equipment Corporation. - * - * 3) This software is provided "AS-IS" and any express or implied warranties, - * including but not limited to, any implied warranties of merchantability, - * fitness for a particular purpose, or non-infringement are disclaimed. In - * no event shall DIGITAL be liable for any damages whatsoever, and in - * particular, DIGITAL shall not be liable for special, indirect, - * consequential, or incidental damages or damages for - * lost profits, loss of revenue or loss of use, whether such damages arise - * in contract, - * negligence, tort, under statute, in equity, at law or otherwise, even if - * advised of the possibility of such damage. - * - */ - -/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/AsmMacros.h,v 3.14 1999/09/25 14:36:58 dawes Exp $ */ - -#if defined(__GNUC__) -#if defined(linux) && (defined(__alpha__) || defined(__ia64__)) -#undef inb -#define inb _inb -#undef inw -#define inw _inw -#undef inl -#define inl _inl -#undef outb -#define outb(p,v) _outb((v),(p)) -#undef outw -#define outw(p,v) _outw((v),(p)) -#undef outl -#define outl(p,v) _outl((v),(p)) -#else -#if defined(__sparc__) -#ifndef ASI_PL -#define ASI_PL 0x88 -#endif - -static __inline__ void -outb(port, val) -unsigned long port; -char val; -{ - __asm__ __volatile__("stba %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); -} - -static __inline__ void -outw(port, val) -unsigned long port; -char val; -{ - __asm__ __volatile__("stha %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); -} - -static __inline__ void -outl(port, val) -unsigned long port; -char val; -{ - __asm__ __volatile__("sta %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); -} - -static __inline__ unsigned int -inb(port) -unsigned long port; -{ - unsigned char ret; - __asm__ __volatile__("lduba [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL)); - return ret; -} - -static __inline__ unsigned int -inw(port) -unsigned long port; -{ - unsigned char ret; - __asm__ __volatile__("lduha [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL)); - return ret; -} - -static __inline__ unsigned int -inl(port) -unsigned long port; -{ - unsigned char ret; - __asm__ __volatile__("lda [%1] %2, %0" : "=r" (ret) : "r" (port), "i" (ASI_PL)); - return ret; -} -#else -#ifdef __arm32__ -unsigned int IOPortBase; /* Memory mapped I/O port area */ - -static __inline__ void -outb(port, val) - short port; - char val; -{ - if ((unsigned short)port >= 0x400) return; - - *(volatile unsigned char*)(((unsigned short)(port))+IOPortBase) = val; -} - -static __inline__ void -outw(port, val) - short port; - short val; -{ - if ((unsigned short)port >= 0x400) return; - - *(volatile unsigned short*)(((unsigned short)(port))+IOPortBase) = val; -} - -static __inline__ void -outl(port, val) - short port; - int val; -{ - if ((unsigned short)port >= 0x400) return; - - *(volatile unsigned long*)(((unsigned short)(port))+IOPortBase) = val; -} - -static __inline__ unsigned int -inb(port) - short port; -{ - if ((unsigned short)port >= 0x400) return((unsigned int)-1); - - return(*(volatile unsigned char*)(((unsigned short)(port))+IOPortBase)); -} - -static __inline__ unsigned int -inw(port) - short port; -{ - if ((unsigned short)port >= 0x400) return((unsigned int)-1); - - return(*(volatile unsigned short*)(((unsigned short)(port))+IOPortBase)); -} - -static __inline__ unsigned int -inl(port) - short port; -{ - if ((unsigned short)port >= 0x400) return((unsigned int)-1); - - return(*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase)); -} -#else /* __arm32__ */ -#if defined(Lynx) && defined(__powerpc__) -extern unsigned char *ioBase; - -static volatile void -eieio() -{ - __asm__ __volatile__ ("eieio"); -} - -static void -outb(port, value) -short port; -unsigned char value; -{ - *(uchar *)(ioBase + port) = value; eieio(); -} - -static void -outw(port, value) -short port; -unsigned short value; -{ - *(unsigned short *)(ioBase + port) = value; eieio(); -} - -static void -outl(port, value) -short port; -unsigned long value; -{ - *(unsigned long *)(ioBase + port) = value; eieio(); -} - -static unsigned char -inb(port) -short port; -{ - unsigned char val; - - val = *((unsigned char *)(ioBase + port)); eieio(); - return(val); -} - -static unsigned short -inw(port) -short port; -{ - unsigned short val; - - val = *((unsigned short *)(ioBase + port)); eieio(); - return(val); -} - -static unsigned long -inl(port) -short port; -{ - unsigned long val; - - val = *((unsigned long *)(ioBase + port)); eieio(); - return(val); -} - -#else -#if defined(__FreeBSD__) && defined(__alpha__) - -#include - -extern void outb(u_int32_t port, u_int8_t val); -extern void outw(u_int32_t port, u_int16_t val); -extern void outl(u_int32_t port, u_int32_t val); -extern u_int8_t inb(u_int32_t port); -extern u_int16_t inw(u_int32_t port); -extern u_int32_t inl(u_int32_t port); - -#else -#ifdef GCCUSESGAS -static __inline__ void -outb(port, val) -short port; -char val; -{ - __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port)); -} - -static __inline__ void -outw(port, val) -short port; -short val; -{ - __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port)); -} - -static __inline__ void -outl(port, val) -short port; -unsigned int val; -{ - __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); -} - -static __inline__ unsigned int -inb(port) -short port; -{ - unsigned char ret; - __asm__ __volatile__("inb %1,%0" : - "=a" (ret) : - "d" (port)); - return ret; -} - -static __inline__ unsigned int -inw(port) -short port; -{ - unsigned short ret; - __asm__ __volatile__("inw %1,%0" : - "=a" (ret) : - "d" (port)); - return ret; -} - -static __inline__ unsigned int -inl(port) -short port; -{ - unsigned int ret; - __asm__ __volatile__("inl %1,%0" : - "=a" (ret) : - "d" (port)); - return ret; -} - -#else /* GCCUSESGAS */ - -static __inline__ void -outb(port, val) - short port; - char val; -{ - __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port)); -} - -static __inline__ void -outw(port, val) - short port; - short val; -{ - __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port)); -} - -static __inline__ void -outl(port, val) - short port; - unsigned int val; -{ - __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port)); -} - -static __inline__ unsigned int -inb(port) - short port; -{ - unsigned int ret; - __asm__ __volatile__("in%B0 (%1)" : - "=a" (ret) : - "d" (port)); - return ret; -} - -static __inline__ unsigned int -inw(port) - short port; -{ - unsigned int ret; - __asm__ __volatile__("in%W0 (%1)" : - "=a" (ret) : - "d" (port)); - return ret; -} - -static __inline__ unsigned int -inl(port) - short port; -{ - unsigned int ret; - __asm__ __volatile__("in%L0 (%1)" : - "=a" (ret) : - "d" (port)); - return ret; -} - -#endif /* GCCUSESGAS */ -#endif /* Lynx && __powerpc__ */ -#endif /* arm32 */ -#endif /* linux && __sparc__ */ -#endif /* linux && __alpha__ */ -#endif /* __FreeBSD__ && __alpha__ */ - -#if defined(linux) || defined(__arm32__) || (defined(Lynx) && defined(__powerpc__)) - -#define intr_disable() -#define intr_enable() - -#else - -static __inline__ void -intr_disable() -{ - __asm__ __volatile__("cli"); -} - -static __inline__ void -intr_enable() -{ - __asm__ __volatile__("sti"); -} - -#endif /* else !linux && !__arm32__ */ - -#else /* __GNUC__ */ - -#if defined(_MINIX) && defined(_ACK) - -/* inb, outb, inw and outw are defined in the library */ -/* ... but I've no idea if the same is true for inl & outl */ - -u8_t inb(U16_t); -void outb(U16_t, U8_t); -u16_t inw(U16_t); -void outw(U16_t, U16_t); -u32_t inl(U16_t); -void outl(U16_t, U32_t); - -#else /* not _MINIX and _ACK */ - -# if defined(__STDC__) && (__STDC__ == 1) -# ifndef NCR -# define asm __asm -# endif -# endif -# ifdef SVR4 -# include -# ifndef __USLC__ -# define __USLC__ -# endif -# endif -#ifndef SCO325 -# include -#else -# include "../common/scoasm.h" -#endif -#define intr_disable() asm("cli") -#define intr_enable() asm("sti") - -#endif /* _MINIX and _ACK */ -#endif /* __GNUC__ */ diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/README b/board/MAI/bios_emulator/scitech/src/v86bios/README deleted file mode 100644 index cb65674b2d..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/README +++ /dev/null @@ -1,32 +0,0 @@ - -This is a preliminary version of a VGA softbooter for LINUX. - -It makes use of the of the vm86() call and is therefore only -usable on ix86 systems. -There are plans to port this program to use a x86 emulator -like x86emu. Also it may be ported to other operating systems. - -So far it has been tested on a small number of cards. It might -well be that it will fail on your card. - -If you need to make modifications to the programs to be able -to boot your card please let the author know. - -So far there is no command line interface. All options need -to be hardcoded. You can do this by editing debug.h. You can -turn on a bunch of debug output. Other options allow you to -boot the primary card (CONFIG_ACTIVE_DEVICE), save the bios -to a file (SAVE_BIOS), and map the original system bios -(MAP_SYS_BIOS). - -The author wants to thank - Hans Lermen (dosemu) - and - Kendall Bennett (x86emu) -for their support. - -Parts of the code - especially in v86.c and io.c - are based on code -taken from dosemu. Parts of the code in int.c are based on code taken -from x86emu - -Egbert Eich. diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/awk.scr b/board/MAI/bios_emulator/scitech/src/v86bios/awk.scr deleted file mode 100644 index 9d2a80d7d8..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/awk.scr +++ /dev/null @@ -1,15 +0,0 @@ -/.*\(0x3da.*/||/.*\(0x3ba.*/ { - if (v_3da != 1) print "_v_retrace_"; - v_3da = 1; - next; - } -/.*\(0x42.*/||/.*\(0x43.*/ { - if (v_4x != 1) print "_timer_"; - v_4x = 1; - next; -} -{ - print; - v_3da = 0; - v_4x = 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/cbios.c b/board/MAI/bios_emulator/scitech/src/v86bios/cbios.c deleted file mode 100644 index 6b12dff4f9..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/cbios.c +++ /dev/null @@ -1,415 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if defined(__alpha__) || defined (__ia64__) -#include -#elif defined(HAVE_SYS_PERM) -#include -#endif -#include "debug.h" -#include "v86bios.h" -#include "pci.h" -#include "AsmMacros.h" - -#define SIZE 0x100000 -#define VRAM_START 0xA0000 -#define VRAM_SIZE 0x1FFFF -#define V_BIOS_SIZE 0x1FFFF -#define BIOS_START 0x7C00 /* default BIOS entry */ -#define BIOS_MEM 0x600 - -CARD8 code[] = { 0xcd, 0x10, 0xf4 }; -struct config Config; - -static int map(void); -static void unmap(void); -static void runBIOS(int argc, char **argv); -static int map_vram(void); -static void unmap_vram(void); -static int copy_vbios(memType base); -static int copy_sys_bios(void); -static CARD32 setup_int_vect(void); -static void update_bios_vars(void); -static int chksum(CARD8 *start); -static void setup_bios_regs(i86biosRegsPtr regs, int argc, char **argv); -static void print_regs(i86biosRegsPtr regs); -void dprint(unsigned long start, unsigned long size); - -void loadCodeToMem(unsigned char *ptr, CARD8 *code); - -static int vram_mapped = 0; -static char* bios_var; - - -int -main(int argc,char **argv) -{ - CARD32 vbios_base; - - Config.PrintPort = PRINT_PORT; - Config.IoStatistics = IO_STATISTICS; - Config.PrintIrq = PRINT_IRQ; - Config.PrintPci = PRINT_PCI; - Config.ShowAllDev = SHOW_ALL_DEV; - Config.PrintIp = PRINT_IP; - Config.SaveBios = SAVE_BIOS; - Config.Trace = TRACE; - Config.ConfigActiveOnly = CONFIG_ACTIVE_ONLY; - Config.ConfigActiveDevice = CONFIG_ACTIVE_DEVICE; - Config.MapSysBios = MAP_SYS_BIOS; - Config.Resort = RESORT; - Config.FixRom = FIX_ROM; - Config.NoConsole = NO_CONSOLE; - Config.Verbose = VERBOSE; - - if (!map()) - exit(1); - if (!copy_sys_bios()) - exit(1); - if (!(vbios_base = setup_int_vect())) - exit(1); - if (!map_vram()) - exit(1); - if (!copy_vbios(vbios_base)) - exit(1); - - iopl(3); - setup_io(); - runBIOS(argc,argv); - update_bios_vars(); - unmap_vram(); - iopl(0); - unmap(); - printf("done !\n"); - exit (1); -} - -int -map(void) -{ - void* mem; - - mem = mmap(0, (size_t)SIZE, - PROT_EXEC | PROT_READ | PROT_WRITE, - MAP_FIXED | MAP_PRIVATE | MAP_ANON, - -1, 0 ); - if (mem != 0) { - perror("anonymous map"); - return (0); - } - memset(mem,0,SIZE); - - loadCodeToMem((unsigned char *) BIOS_START, code); - return (1); -} - -static int -copy_sys_bios(void) -{ -#define SYS_BIOS 0xF0000 - int mem_fd; - - if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { - perror("opening memory"); - return (0); - } - - if (lseek(mem_fd,(off_t) SYS_BIOS,SEEK_SET) != (off_t) SYS_BIOS) - goto Error; - if (read(mem_fd, (char *)SYS_BIOS, (size_t) 0xFFFF) != (size_t) 0xFFFF) - goto Error; - - close(mem_fd); - return (1); - -Error: - perror("sys_bios"); - close(mem_fd); - return (0); -} - -static int -map_vram(void) -{ - int mem_fd; - -#ifdef __ia64__ - if ((mem_fd = open(MEM_FILE,O_RDWR | O_SYNC))<0) -#else - if ((mem_fd = open(MEM_FILE,O_RDWR))<0) -#endif - { - perror("opening memory"); - return 0; - } - -#ifndef __alpha__ - if (mmap((void *) VRAM_START, (size_t) VRAM_SIZE, - PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, - mem_fd, VRAM_START) == (void *) -1) -#else - if (!_bus_base()) sparse_shift = 7; /* Uh, oh, JENSEN... */ - if (!_bus_base_sparse()) sparse_shift = 0; - if ((vram_map = mmap(0,(size_t) (VRAM_SIZE << sparse_shift), - PROT_READ | PROT_WRITE, - MAP_SHARED, - mem_fd, (VRAM_START << sparse_shift) - | _bus_base_sparse())) == (void *) -1) -#endif - { - perror("mmap error in map_hardware_ram"); - close(mem_fd); - return (0); - } - vram_mapped = 1; - close(mem_fd); - return (1); -} - -static int -copy_vbios(memType v_base) -{ - int mem_fd; - unsigned char *tmp; - int size; - - if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { - perror("opening memory"); - return (0); - } - - if (lseek(mem_fd,(off_t) v_base, SEEK_SET) != (off_t) v_base) { - fprintf(stderr,"Cannot lseek\n"); - goto Error; - } - tmp = (unsigned char *)malloc(3); - if (read(mem_fd, (char *)tmp, (size_t) 3) != (size_t) 3) { - fprintf(stderr,"Cannot read\n"); - goto Error; - } - if (lseek(mem_fd,(off_t) v_base,SEEK_SET) != (off_t) v_base) - goto Error; - - if (*tmp != 0x55 || *(tmp+1) != 0xAA ) { - fprintf(stderr,"No bios found at: 0x%lx\n",v_base); - goto Error; - } -#ifdef DEBUG - dprint((unsigned long)tmp,0x100); -#endif - size = *(tmp+2) * 512; - - if (read(mem_fd, (char *)v_base, (size_t) size) != (size_t) size) { - fprintf(stderr,"Cannot read\n"); - goto Error; - } - free(tmp); - close(mem_fd); - if (!chksum((CARD8*)v_base)) - return (0); - - return (1); - -Error: - perror("v_bios"); - close(mem_fd); - return (0); -} - -static void -unmap(void) -{ - munmap(0,SIZE); -} - -static void -unmap_vram(void) -{ - if (!vram_mapped) return; - - munmap((void*)VRAM_START,VRAM_SIZE); - vram_mapped = 0; -} - -static void -runBIOS(int argc, char ** argv) -{ - i86biosRegs bRegs; -#ifdef V86BIOS_DEBUG - printf("starting BIOS\n"); -#endif - setup_bios_regs(&bRegs, argc, argv); - do_x86(BIOS_START,&bRegs); - print_regs(&bRegs); -#ifdef V86BIOS_DEBUG - printf("done\n"); -#endif -} - -static CARD32 -setup_int_vect(void) -{ - int mem_fd; - CARD32 vbase; - void *map; - - if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { - perror("opening memory"); - return (0); - } - - if ((map = mmap((void *) 0, (size_t) 0x2000, - PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED, - mem_fd, 0)) == (void *)-1) { - perror("mmap error in map_hardware_ram"); - close(mem_fd); - return (0); - } - - close(mem_fd); - memcpy(0,map,BIOS_MEM); - munmap(map,0x2000); - /* - * create a backup copy of the bios variables to write back the - * modified values - */ - bios_var = (char *)malloc(BIOS_MEM); - memcpy(bios_var,0,BIOS_MEM); - - vbase = (*((CARD16*)(0x10 << 2) + 1)) << 4; - fprintf(stderr,"vbase: 0x%x\n",vbase); - return vbase; -} - -static void -update_bios_vars(void) -{ - int mem_fd; - void *map; - memType i; - -#ifdef __ia64__ - if ((mem_fd = open(MEM_FILE,O_RDWR | O_SYNC))<0) -#else - if ((mem_fd = open(MEM_FILE,O_RDWR))<0) -#endif - { - perror("opening memory"); - return; - } - - if ((map = mmap((void *) 0, (size_t) 0x2000, - PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED, - mem_fd, 0)) == (void *)-1) { - perror("mmap error in map_hardware_ram"); - close(mem_fd); - return; - } - - for (i = 0; i < BIOS_MEM; i++) { - if (bios_var[i] != *(CARD8*)i) - *((CARD8*)map + i) = *(CARD8*)i; - } - - munmap(map,0x2000); - close(mem_fd); -} - - -static void -setup_bios_regs(i86biosRegsPtr regs, int argc, char **argv) -{ - int c; - - regs->ax = 0; - regs->bx = 0; - regs->cx = 0; - regs->dx = 0; - regs->es = 0; - regs->di = 0; - opterr = 0; - while ((c = getopt(argc,argv,"a:b:c:d:e:i:")) != EOF) { - switch (c) { - case 'a': - regs->ax = strtol(optarg,NULL,0); - break; - case 'b': - regs->bx = strtol(optarg,NULL,0); - break; - case 'c': - regs->cx = strtol(optarg,NULL,0); - break; - case 'd': - regs->dx = strtol(optarg,NULL,0); - break; - case 'e': - regs->es = strtol(optarg,NULL,0); - break; - case 'i': - regs->di = strtol(optarg,NULL,0); - break; - } - } -} - - -static int -chksum(CARD8 *start) -{ - CARD16 size; - CARD8 val = 0; - int i; - - size = *(start+2) * 512; - for (i = 0; iax, - (CARD16)regs->bx,(CARD16)regs->cx,(CARD16)regs->dx, - (CARD16)regs->es,(CARD16)regs->di); -} - -void -loadCodeToMem(unsigned char *ptr, CARD8 code[]) -{ - int i; - CARD8 val; - - for ( i=0;;i++) { - val = code[i]; - *ptr++ = val; - if (val == 0xf4) break; - } - return; -} - -void -dprint(unsigned long start, unsigned long size) -{ - int i,j; - char *c = (char *)start; - - for (j = 0; j < (size >> 4); j++) { - printf ("\n0x%lx: ",(unsigned long)c); - for (i = 0; i<16; i++) - printf("%x ",(unsigned char) (*(c++))); - } - printf("\n"); -} diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/command.c b/board/MAI/bios_emulator/scitech/src/v86bios/command.c deleted file mode 100644 index e2bce6df1b..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/command.c +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include -#include - -#define PROMPT ">" - - -void -getline(char *buf,int *num,int max_num) -{ - static int line_len = 0; - static char *line = NULL; - static char *line_pointer = NULL; - static int len = 0; - int tmp_len; - char *buff; - - if (len <= 0) { - buff = readline(PROMPT); - add_history(buff); - - if ((tmp_len = strlen(buff)) > line_len) { - free(line); - line = malloc(tmp_len); - line_len = tmp_len; - } - sprintf(line,"%s\n",buff); - free(buff); - line_pointer = line; - len = strlen(line); - } - - *num = max_num > len? len : max_num; - strncpy(buf,line_pointer,*num); - line_pointer = line_pointer + *num; - len = len - *num; -} diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/console.c b/board/MAI/bios_emulator/scitech/src/v86bios/console.c deleted file mode 100644 index 5e9c924b64..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/console.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 1999 Egbert Eich - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the authors not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The authors makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ -#include -#include -#include -#include -#include -#include -#include "debug.h" -#include "v86bios.h" - -console -open_console(void) -{ - int fd; - int VTno; - char VTname[11]; - console Con = {-1,-1}; - struct vt_stat vts; - - if (NO_CONSOLE) - return Con; - - if ((fd = open("/dev/tty0",O_WRONLY,0)) < 0) - return Con; - - if ((ioctl(fd, VT_OPENQRY, &VTno) < 0) || (VTno == -1)) { - fprintf(stderr,"cannot get a vt\n"); - return Con; - } - - close(fd); - sprintf(VTname,"/dev/tty%i",VTno); - - if ((fd = open(VTname, O_RDWR|O_NDELAY, 0)) < 0) { - fprintf(stderr,"cannot open console\n"); - return Con; - } - - if (ioctl(fd, VT_GETSTATE, &vts) == 0) - Con.vt = vts.v_active; - - if (ioctl(fd, VT_ACTIVATE, VTno) != 0) { - fprintf(stderr,"cannot activate console\n"); - close(fd); - return Con; - } - if (ioctl(fd, VT_WAITACTIVE, VTno) != 0) { - fprintf(stderr,"wait for active console failed\n"); - close(fd); - return Con; - } -#if 0 - if (ioctl(fd, KDSETMODE, KD_GRAPHICS) < 0) { - close(fd); - return Con; - } -#endif - Con.fd = fd; - return Con; -} - -void -close_console(console Con) -{ - if (Con.fd == -1) - return; - -#if 0 - ioctl(Con.fd, KDSETMODE, KD_TEXT); -#endif - if (Con.vt >=0) - ioctl(Con.fd, VT_ACTIVATE, Con.vt); - - close(Con.fd); -} diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/debug.h b/board/MAI/bios_emulator/scitech/src/v86bios/debug.h deleted file mode 100644 index c5c906b622..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/debug.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 1999 Egbert Eich - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the authors not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The authors makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ -/*#define V86BIOS_DEBUG */ - -/* - * uncomment the following if needed - * should be command line options - */ - -#define PRINT_PORT 0 -#define IO_STATISTICS 0 -#define PRINT_IRQ 0 -#define PRINT_PCI 1 -#define PRINT_IP 0 /* print IP address with PIO information */ -#define TRACE 0 /* turn on debugger in x86emu */ - /* requires x86emu compiled with -DDEBUG */ - -/* - * these should not be here. - * Should be converted to command line options. - */ -#define CONFIG_ACTIVE_ONLY 0 -#define CONFIG_ACTIVE_DEVICE 1 -#define SAVE_BIOS 0 -#define MAP_SYS_BIOS 1 -#define RESORT 1 -#define FIX_ROM 0 -#define NO_CONSOLE 0 -#define SHOW_ALL_DEV 0 -#define VERBOSE 0 - -/*#define V_BIOS 0xe0000 */ -/*#define V_BIOS 0xe4000 */ - - -#if (PRINT_IO == 1) && (PRINT_PORT == 0) -# define PRINT_IO 0 -#endif -#if (IO_STATISTICS == 1) && (PRINT_PORT == 0) -# define IO_STATISTICS 0 -#endif diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/happy_cards b/board/MAI/bios_emulator/scitech/src/v86bios/happy_cards deleted file mode 100644 index 943d44ede4..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/happy_cards +++ /dev/null @@ -1,76 +0,0 @@ -What I had to do to make cards happy: - -1. Tseng ET4000 W32P -This card wants to call the original system BIOS video routines. -It sets the int 0x42 vector to F000:F065, the entry point to the -system bios video routines. -CAVE: don't catch int 0x42 and use the vbios int 0x10 routines. -At early stage during initialization they call int 0x42. This -causes an infinite loop. - -2. ATi Mach64 Rage IIc AGP -This card does similar things like the Tseng ET4000 W32P. -However it doesn't have the problem with the ininite loop. - -3. Elsa Victory II-A16 AGP Banshee -This card is very clever: It knows it is an AGP card. Therefore -it knows it is behind a PCI-PCI bridge. It also knows that noone -else is behind this bridge. Therefore it start reprogramming the -bridge! For this it assumes the AGP bridge is on bus 1. - -4. Elsa Gloria Synergy 8 ViVo AGP PM2 -This card likes to see a complete interrupt vector table. If -we fill this table with 0 the VBIOS detects this and quits -initialization. - -5. Dimond Viper 330 AGP NVIDIA Riva 128. -This card has a similar problem like the Elsa Gloria. It wants -to read the system BIOS date at 0xffffd. - -6. Matrox Mystique PCI -This card reads the IO port 0x62. If it doesn't like what it sees -it loops forever. To keep the card happy put 0xfc into 0xffffe. -This location holds the system model id. 0xfc means IBM-AT. - One can make an interesting observation: this card likes to know -with whom it has to share the system. Therefore it accesses PCI -config space of all the other cards. It does this bypassing the -PCI BIOS by reading the PCI access ports directly. - -7. Matrox G100 AGP -This card has the same problem as the Mystique. - -Apperantly this works now. However not all combinations of cards are -checked, yet. - -Further notes: -the IO register 0x42-0x43 as well as 0x61-0x63 are of special interest -for many graphic cards. They should be emulated. -The so called "Industry Standard BIOS Entry Points" to int 0x42 (0xFF065) -and to int 0x1a (0xFFE6E) should be filled with useful code. This code -needs to return as if it was called as int. -The subvendor ID PCI registers might cause problems. On some chipsets -they are programmed in a non-obivous non-PCI conformant way. -V_Bioses are seen to modify the following int: -0x10 (default video), 0x1f(font table), 0x42(copy of default video), -0x43 (??), 0x6d (copy of default video - same as 0x10?) - -TODO: -Int 0x6d needs to be done. -All interrupts where there is no default industry standard entry point -should point to an unused location in the 0xF000 segmant (possibly -0xF0000). This way they could be trapped. A trap handler for -a. int 0x42 and int 0x1a needs to be implemented. -The default "industry entry point" for video and PCI (0xFFE6E) should -also be implemented. (any others?) They should either be routed to -int 0x42(0x6d?) (video) and 0x1A (PCI) or some other interrupts to -trap them. Mapping of system bios might not be a good idea. Maybe -the system bios area should just be filled with "hlt" to trap any -access there. -Handling of timer IO registers 0x42, 0x43 and IO registers 0x61, 0x62. - -Find documentation: -- on interrupt vector table -- on industry standard entry points to the system bios -- on IO registers 0x61 and 0x62 - - diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/hexdump b/board/MAI/bios_emulator/scitech/src/v86bios/hexdump deleted file mode 100644 index 4f359e5edd..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/hexdump +++ /dev/null @@ -1,3 +0,0 @@ -"%06.6_ax " 16/1 "%02x " -" " 16/1 "%_p" -"\n" diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/int.c b/board/MAI/bios_emulator/scitech/src/v86bios/int.c deleted file mode 100644 index 3504c6cc3c..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/int.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright 1999 Egbert Eich - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the authors not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The authors makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ -#include "debug.h" -#if defined(__alpha__) || defined (__ia64__) -#include -#endif - -#include "v86bios.h" -#include "AsmMacros.h" -#include "pci.h" - -static int int1A_handler(struct regs86 *regs); -static int int42_handler(int num, struct regs86 *regs); - -int -int_handler(int num, struct regs86 *regs) -{ - switch (num) { - case 0x10: - case 0x42: - return (int42_handler(num,regs)); - case 0x1A: - return (int1A_handler(regs)); - default: - return 0; - } - return 0; -} - -static int -int42_handler(int num,struct regs86 *regs) -{ - unsigned char c; - CARD32 val; - - i_printf("int 0x%x: ax:0x%lx bx:0x%lx cx:0x%lx dx:0x%lx\n",num, - regs->eax,regs->ebx, regs->ecx, regs->edx); - - /* - * video bios has modified these - - * leave it to the video bios to do this - */ - - val = getIntVect(num); - if (val != 0xF000F065) - return 0; - - if ((regs->ebx & 0xff) == 0x32) { - switch (regs->eax & 0xFFFF) { - case 0x1200: - i_printf("enabling video\n"); - c = inb(0x3cc); - c |= 0x02; - outb(0x3c2,c); - return 1; - case 0x1201: - i_printf("disabling video\n"); - c = inb(0x3cc); - c &= ~0x02; - outb(0x3c2,c); - return 1; - default: - } - } - if (num == 0x42) - return 1; - else - return 0; -} - -#define SUCCESSFUL 0x00 -#define DEVICE_NOT_FOUND 0x86 -#define BAD_REGISTER_NUMBER 0x87 - -static int -int1A_handler(struct regs86 *regs) -{ - CARD32 Slot; - PciStructPtr pPci; - - if (! CurrentPci) return 0; /* oops */ - - i_printf("int 0x1a: ax=0x%lx bx=0x%lx cx=0x%lx dx=0x%lx di=0x%lx" - " si=0x%lx\n", regs->eax,regs->ebx,regs->ecx,regs->edx, - regs->edi,regs->esi); - switch (regs->eax & 0xFFFF) { - case 0xb101: - regs->eax &= 0xFF00; /* no config space/special cycle support */ - regs->edx = 0x20494350; /* " ICP" */ - regs->ebx = 0x0210; /* Version 2.10 */ - regs->ecx &= 0xFF00; - regs->ecx |= (pciMaxBus & 0xFF); /* Max bus number in system */ - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - i_printf("ax=0x%lx dx=0x%lx bx=0x%lx cx=0x%lx flags=0x%lx\n", - regs->eax,regs->edx,regs->ebx,regs->ecx,regs->eflags); - return 1; - case 0xb102: - if (((regs->edx & 0xFFFF) == CurrentPci->VendorID) && - ((regs->ecx & 0xFFFF) == CurrentPci->DeviceID) && - (regs->esi == 0)) { - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - regs->ebx = pciSlotBX(CurrentPci); - } - else if (Config.ShowAllDev && - (pPci = findPciDevice(regs->edx,regs->ecx,regs->esi)) != NULL) { - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - regs->ebx = pciSlotBX(pPci); - } else { - regs->eax = (regs->eax & 0x00FF) | (DEVICE_NOT_FOUND << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx bx=0x%lx flags=0x%lx\n", - regs->eax,regs->ebx,regs->eflags); - return 1; - case 0xb103: - if (((regs->ecx & 0xFF) == CurrentPci->Interface) && - (((regs->ecx & 0xFF00) >> 8) == CurrentPci->SubClass) && - (((regs->ecx & 0xFFFF0000) >> 16) == CurrentPci->BaseClass) && - ((regs->esi & 0xff) == 0)) { - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->ebx = pciSlotBX(CurrentPci); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } - else if (Config.ShowAllDev - && (pPci = findPciClass(regs->ecx & 0xFF, (regs->ecx & 0xff00) >> 8, - (regs->ecx & 0xffff0000) >> 16, regs->esi)) != NULL) { - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->ebx = pciSlotBX(pPci); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } else { - regs->eax = (regs->eax & 0x00FF) | (DEVICE_NOT_FOUND << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx flags=0x%lx\n",regs->eax,regs->eflags); - return 1; - case 0xb108: - i_printf("Slot=0x%x\n",CurrentPci->Slot.l); - if ((Slot = findPci(regs->ebx))) { - regs->ecx &= 0xFFFFFF00; - regs->ecx |= PciRead8(regs->edi,Slot); - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } else { - regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx cx=0x%lx flags=0x%lx\n", - regs->eax,regs->ecx,regs->eflags); - return 1; - case 0xb109: - i_printf("Slot=0x%x\n",CurrentPci->Slot.l); - if ((Slot = findPci(regs->ebx))) { - regs->ecx &= 0xFFFF0000; - regs->ecx |= PciRead16(regs->edi,Slot); - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } else { - regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx cx=0x%lx flags=0x%lx\n", - regs->eax,regs->ecx,regs->eflags); - return 1; - case 0xb10a: - i_printf("Slot=0x%x\n",CurrentPci->Slot.l); - if ((Slot = findPci(regs->ebx))) { - regs->ecx &= 0; - regs->ecx |= PciRead32(regs->edi,Slot); - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } else { - regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx cx=0x%lx flags=0x%lx\n", - regs->eax,regs->ecx,regs->eflags); - return 1; - case 0xb10b: - i_printf("Slot=0x%x\n",CurrentPci->Slot.l); - if ((Slot = findPci(regs->ebx))) { - PciWrite8(regs->edi,(CARD8)regs->ecx,Slot); - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } else { - regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx flags=0x%lx\n", regs->eax,regs->eflags); - return 1; - case 0xb10c: - i_printf("Slot=0x%x\n",CurrentPci->Slot.l); - if ((Slot = findPci(regs->ebx))) { - PciWrite16(regs->edi,(CARD16)regs->ecx,Slot); - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } else { - regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx flags=0x%lx\n", regs->eax,regs->eflags); - return 1; - case 0xb10d: - i_printf("Slot=0x%x\n",CurrentPci->Slot.l); - if ((Slot = findPci(regs->ebx))) { - PciWrite32(regs->edi,(CARD32)regs->ecx,Slot); - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } else { - regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx flags=0x%lx\n", regs->eax,regs->eflags); - return 1; - default: - return 0; - } -} diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/io.c b/board/MAI/bios_emulator/scitech/src/v86bios/io.c deleted file mode 100644 index f35b43e9b9..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/io.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright 1999 Egbert Eich - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the authors not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The authors makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ -#include "debug.h" - -#include -#if defined(__alpha__) || defined (__ia64__) -#include -#endif -#include "AsmMacros.h" -#include "v86bios.h" -#include "pci.h" - -int r_inb = 0, r_inw = 0, r_inl = 0, r_outb = 0, r_outw = 0, r_outl = 0; -int in_b = 0, in_w = 0, in_l = 0, out_b = 0, out_w = 0, out_l = 0; - - -int -port_rep_inb(CARD16 port, CARD8 *base, int d_f, CARD32 count) -{ - register int inc = d_f ? -1 : 1; - CARD8 *dst = base; - - p_printf(" rep_insb(%#x) %d bytes at %p %s", - port, count, base, d_f?"up":"down"); - if (Config.PrintIp) - p_printf(" %x\n",getIP()); - else p_printf("\n"); - - r_inb++; - while (count--) { - *dst = inb(port); - dst += inc; - } - return (dst-base); -} - -int -port_rep_inw(CARD16 port, CARD16 *base, int d_f, CARD32 count) -{ - register int inc = d_f ? -1 : 1; - CARD16 *dst = base; - - p_printf(" rep_insw(%#x) %d bytes at %p %s", - port, count, base, d_f?"up":"down"); - if (Config.PrintIp) - p_printf(" %x\n",getIP()); - else p_printf("\n"); - - r_inw++; - while (count--) { - *dst = inw(port); - dst += inc; - } - return (dst-base); -} - -int -port_rep_inl(CARD16 port, CARD32 *base, int d_f, CARD32 count) -{ - register int inc = d_f ? -1 : 1; - CARD32 *dst = base; - - p_printf(" rep_insl(%#x) %d bytes at %p %s", - port, count, base, d_f?"up":"down"); - if (Config.PrintIp) - p_printf(" %x\n",getIP()); - else p_printf("\n"); - - r_inl++; - while (count--) { - *dst = inl(port); - dst += inc; - } - return (dst-base); -} - -int -port_rep_outb(CARD16 port, CARD8 *base, int d_f, CARD32 count) -{ - register int inc = d_f ? -1 : 1; - CARD8 *dst = base; - - p_printf(" rep_outb(%#x) %d bytes at %p %s", - port, count, base, d_f?"up":"down"); - if (Config.PrintIp) - p_printf(" %x\n",getIP()); - else p_printf("\n"); - - r_outb++; - while (count--) { - outb(port,*dst); - dst += inc; - } - return (dst-base); -} - -int -port_rep_outw(CARD16 port, CARD16 *base, int d_f, CARD32 count) -{ - register int inc = d_f ? -1 : 1; - CARD16 *dst = base; - - p_printf(" rep_outw(%#x) %d bytes at %p %s", - port, count, base, d_f?"up":"down"); - if (Config.PrintIp) - p_printf(" %x\n",getIP()); - else p_printf("\n"); - - r_outw++; - while (count--) { - outw(port,*dst); - dst += inc; - } - return (dst-base); -} - -int -port_rep_outl(CARD16 port, CARD32 *base, int d_f, CARD32 count) -{ - register int inc = d_f ? -1 : 1; - CARD32 *dst = base; - - p_printf(" rep_outl(%#x) %d bytes at %p %s", - port, count, base, d_f?"up":"down"); - if (Config.PrintIp) - p_printf(" %x\n",getIP()); - else p_printf("\n"); - - r_outl++; - while (count--) { - outl(port,*dst); - dst += inc; - } - return (dst-base); -} - -CARD8 -p_inb(CARD16 port) -{ - CARD8 val = 0; - in_b++; - val = inb(port); - p_printf(" inb(%#x) = %2.2x",port,val); - if (Config.PrintIp) - p_printf(" %x\n",getIP()); - else p_printf("\n"); - - return val; -} - -CARD16 -p_inw(CARD16 port) -{ - CARD16 val = 0; - in_w++; - val = inw(port); - p_printf(" inw(%#x) = %4.4x",port,val); - if (Config.PrintIp) - p_printf(" %x\n",getIP()); - else p_printf("\n"); - - return val; -} - -CARD32 -p_inl(CARD16 port) -{ - CARD32 val = 0; - in_l++; -#ifdef NEED_PCI_IO - if (cfg1in(port,&val)) - return val; - else -#endif - val = inl(port); - p_printf(" inl(%#x) = %8.8x",port,val); - if (Config.PrintIp) - p_printf(" %x\n",getIP()); - else p_printf("\n"); - - return val; -} - -void -p_outb(CARD16 port, CARD8 val) -{ - out_b++; - p_printf(" outb(%#x, %2.2x)",port,val); - if (Config.PrintIp) - p_printf(" %x\n",getIP()); - else p_printf("\n"); - - outb(port,val); -} - -void -p_outw(CARD16 port, CARD16 val) -{ - out_w++; - p_printf(" outw(%#x, %4.4x)",port,val); - if (Config.PrintIp) - p_printf(" %x\n",getIP()); - else p_printf("\n"); - - outw(port,val); -} - -void -p_outl(CARD16 port, CARD32 val) -{ - out_l++; - p_printf(" outl(%#x, %8.8x)",port,val); - if (Config.PrintIp) - p_printf(" %x\n",getIP()); - else p_printf("\n"); - -#ifdef NEED_PCI_IO - if (cfg1out(port,val)) - return; -#endif - outl(port,val); -} - -void -io_statistics(void) -{ - p_printf("rep: inb: %i, inw: %i, inl: %i, outb: %i, outw: %i, outl: %i\n", - r_inb,r_inw,r_inl,r_outb,r_outw,r_outl); - p_printf("inb: %i, inw: %i, inl: %i, outb: %i, outw: %i, outl: %i\n", - in_b,in_w,in_l,out_b,out_w,out_l); -} - -void -clear_stat(void) -{ - r_inb = r_inw = r_inl = r_outb = r_outw = r_outl = 0; - in_b = in_w = in_l = out_b = out_w = out_l = 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/lex.l b/board/MAI/bios_emulator/scitech/src/v86bios/lex.l deleted file mode 100644 index 3a3391c7b4..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/lex.l +++ /dev/null @@ -1,79 +0,0 @@ -%{ -#include "parser.h" - -#include -#include - - void getline(char *buf,int *num,int max_num); - -#define YY_INPUT(buf,result,max_size) {\ - getline(buf,&result,max_size);\ - } - - void - yyerror (char *s) - { - printf ("%s\n", s); - } - -%} - -DIGIT [0-9a-fA-F] - -%% - -"0x"?{DIGIT}+ { yylval = strtol(yytext,NULL,0); return TOK_NUM; } -"ax" { return TOK_REG_AX; } -"bx" { return TOK_REG_BX; } -"cx" { return TOK_REG_CX; } -"dx" { return TOK_REG_DX; } -"di" { return TOK_REG_SI; } -"si" { return TOK_REG_DI; } -"ds" { return TOK_SEG_DS; } -"es" { return TOK_SEG_ES; } -":" { return TOK_SEP;} -"$"{DIGIT}{1,2} { yylval = strtol(yytext+1,NULL,0); return TOK_VAR; } -"$mem" { return TOK_VAR_MEM; } -[ \t]+ -"#".*[\n] { return TOK_END; } -"boot" { return TOK_COMMAND_BOOT; } -"do" { return TOK_COMMAND_EXEC; } -"\"".*"\"" { yylval = (unsigned long) yytext; return TOK_STRING; } -"byte" { return TOK_BYTE; } -"word" { return TOK_WORD; } -"long" { return TOK_LONG; } -"setmem" { return TOK_COMMAND_MEMSET; } -"dumpmem" { return TOK_COMMAND_MEMDUMP; } -"quit" { return TOK_COMMAND_QUIT; } -"\n" { return TOK_END; } -"select" { return TOK_SELECT; } -"isa" { return TOK_ISA; } -"pci" { return TOK_PCI; } -"pport" { return TOK_PRINT_PORT; } -"iostat" { return TOK_IOSTAT; } -"pirq" { return TOK_PRINT_IRQ; } -"ppci" { return TOK_PPCI; } -"pip" { return TOK_PIP; } -"trace" { return TOK_TRACE; } -"on" { return TOK_ON; } -"off" { return TOK_OFF; } -"verbose" { return TOK_VERBOSE; } -"log" { return TOK_LOG; } -"print" { return TOK_STDOUT; } -"clstat" { return TOK_CLSTAT; } -"hlt" { return TOK_HLT; } -"del" { return TOK_DEL; } -"ioperm" { return TOK_IOPERM; } -"lpci" { return TOK_DUMP_PCI; } -"bootbios" { return TOK_BOOT_BIOS; } -"?" { return '?'; } -. { return TOK_ERROR; } - -%% - - - - - - - diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/main.c b/board/MAI/bios_emulator/scitech/src/v86bios/main.c deleted file mode 100644 index 15f91150f8..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/main.c +++ /dev/null @@ -1,616 +0,0 @@ -/* - * Copyright 1999 Egbert Eich - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the authors not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The authors makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ -#define DELETE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if defined(__alpha__) || defined (__ia64__) -#include -#elif defined(HAVE_SYS_PERM) -#include -#endif -#include "debug.h" -#include "v86bios.h" -#include "pci.h" -#include "AsmMacros.h" - -#define SIZE 0x100000 -#define VRAM_START 0xA0000 -#define VRAM_SIZE 0x1FFFF -#define V_BIOS_SIZE 0x1FFFF -#define BIOS_START 0x7C00 /* default BIOS entry */ - -/*CARD8 code[] = { 0xb8 , 0xf0 , 0xf0, 0xf4 }; */ -#define VB_X(x) (V_BIOS >> x) & 0xFF -CARD8 code[] = { 0x9a, 0x03, 0x00, 0x00, VB_X(12), 0xf4 }; -/*CARD8 code[] = { 0x9a, 0x03, 0x00, 0x00, VB_X(12), 0xb8, 0x03, 0x00, */ -/*0xcd, 0x10, 0xf4 }; */ -/*CARD8 code[] = { 0xb8 , 0xf0 , 0xf0 ,0xf4 }; */ - -static void sig_handler(int); -static int map(void); -static void unmap(void); -static void bootBIOS(CARD16 ax); -static int map_vram(void); -static void unmap_vram(void); -static int copy_vbios(void); -static int copy_sys_bios(void); -static void save_bios_to_file(void); -static int setup_system_bios(void); -static void setup_int_vect(void); -static int chksum(CARD8 *start); -static void setup_bios_regs(i86biosRegsPtr regs, CARD32 ax); - -void loadCodeToMem(unsigned char *ptr, CARD8 *code); -void dprint(unsigned long start, unsigned long size); - -static int vram_mapped = 0; -static CARD8 save_msr; -static CARD8 save_pos102; -static CARD8 save_vse; -static CARD8 save_46e8; -console Console; -struct config Config; - - -int -main(void) -{ - int Active_is_Pci = 0; -#ifdef DELETE - Config.PrintPort = PRINT_PORT; - Config.IoStatistics = IO_STATISTICS; - Config.PrintIrq = PRINT_IRQ; - Config.PrintPci = PRINT_PCI; - Config.ShowAllDev = SHOW_ALL_DEV; - Config.PrintIp = PRINT_IP; - Config.SaveBios = SAVE_BIOS; - Config.Trace = TRACE; - Config.ConfigActiveOnly = CONFIG_ACTIVE_ONLY; - Config.ConfigActiveDevice = CONFIG_ACTIVE_DEVICE; - Config.MapSysBios = MAP_SYS_BIOS; - Config.Resort = RESORT; - Config.FixRom = FIX_ROM; - Config.NoConsole = NO_CONSOLE; - Config.Verbose = VERBOSE; - - if (!map()) - exit(1); - - if (!setup_system_bios()) - exit(1); - - iopl(3); - setup_io(); - - scan_pci(); - if (!CurrentPci && !Config.ConfigActiveDevice && !Config.ConfigActiveOnly) - exit (1); -#endif - Console = open_console(); - - if (Config.ConfigActiveOnly) { - CARD16 ax; - int activePci = 0; - int error = 0; - - while (CurrentPci) { - if (CurrentPci->active) { - activePci = 1; - if (!(mapPciRom(NULL) && chksum((CARD8*)V_BIOS))) - error = 1; - break; - } - CurrentPci = CurrentPci->next; - } - ax = ((CARD16)(CurrentPci->bus) << 8) - | (CurrentPci->dev << 3) | (CurrentPci->func & 0x7); - P_printf("ax: 0x%x\n",ax); - setup_int_vect(); - if (!error && (activePci || copy_vbios())) { - - if (Config.SaveBios) save_bios_to_file(); - if (map_vram()) { - printf("initializing ISA\n"); - bootBIOS(0); - } - } - unmap_vram(); - sleep(1); - } else { - /* disable primary card */ - save_msr = inb(0x3CC); - save_vse = inb(0x3C3); - save_46e8 = inb(0x46e8); - save_pos102 = inb(0x102); - - signal(2,sig_handler); - signal(11,sig_handler); - - outb(0x3C2,~(CARD8)0x03 & save_msr); - outb(0x3C3,~(CARD8)0x01 & save_vse); - outb(0x46e8, ~(CARD8)0x08 & save_46e8); - outb(0x102, ~(CARD8)0x01 & save_pos102); - - pciVideoDisable(); - - while (CurrentPci) { - CARD16 ax; - - if (CurrentPci->active) { - Active_is_Pci = 1; - if (!Config.ConfigActiveDevice) { - CurrentPci = CurrentPci->next; - continue; - } - } - - EnableCurrent(); - - if (CurrentPci->active) { - outb(0x102, save_pos102); - outb(0x46e8, save_46e8); - outb(0x3C3, save_vse); - outb(0x3C2, save_msr); - } - - /* clear interrupt vectors */ - setup_int_vect(); - - ax = ((CARD16)(CurrentPci->bus) << 8) - | (CurrentPci->dev << 3) | (CurrentPci->func & 0x7); - P_printf("ax: 0x%x\n",ax); - - if (!((mapPciRom(NULL) && chksum((CARD8*)V_BIOS)) - || (CurrentPci->active && copy_vbios()))) { - CurrentPci = CurrentPci->next; - continue; - } - if (!map_vram()) { - CurrentPci = CurrentPci->next; - continue; - } - if (Config.SaveBios) save_bios_to_file(); - printf("initializing PCI bus: %i dev: %i func: %i\n",CurrentPci->bus, - CurrentPci->dev,CurrentPci->func); - bootBIOS(ax); - unmap_vram(); - - CurrentPci = CurrentPci->next; - } - - /* We have an ISA device - configure if requested */ - if (!Active_is_Pci && Config.ConfigActiveDevice) { - pciVideoDisable(); - - outb(0x102, save_pos102); - outb(0x46e8, save_46e8); - outb(0x3C3, save_vse); - outb(0x3C2, save_msr); - - setup_int_vect(); - if (copy_vbios()) { - - if (Config.SaveBios) save_bios_to_file(); - if (map_vram()) { - printf("initializing ISA\n"); - bootBIOS(0); - } - } - - unmap_vram(); - sleep(1); - } - - pciVideoRestore(); - - outb(0x102, save_pos102); - outb(0x46e8, save_46e8); - outb(0x3C3, save_vse); - outb(0x3C2, save_msr); - } - - close_console(Console); -#ifdef DELETE - iopl(0); - unmap(); - - printf("done !\n"); -#endif - if (Config.IoStatistics) - io_statistics(); -#ifdef DELETE - exit(0); -#endif -} - -int -map(void) -{ - void* mem; - - mem = mmap(0, (size_t)SIZE, - PROT_EXEC | PROT_READ | PROT_WRITE, - MAP_FIXED | MAP_PRIVATE | MAP_ANON, - -1, 0 ); - if (mem != 0) { - perror("anonymous map"); - return (0); - } - memset(mem,0,SIZE); - - loadCodeToMem((unsigned char *) BIOS_START, code); - return (1); -} - -static void -unmap(void) -{ - munmap(0,SIZE); -} - -static void -bootBIOS(CARD16 ax) -{ - i86biosRegs bRegs; -#ifdef V86BIOS_DEBUG - printf("starting BIOS\n"); -#endif - setup_bios_regs(&bRegs, ax); - do_x86(BIOS_START,&bRegs); -#ifdef V86BIOS_DEBUG - printf("done\n"); -#endif -} - -static int -map_vram(void) -{ - int mem_fd; - -#ifdef __ia64__ - if ((mem_fd = open(MEM_FILE,O_RDWR | O_SYNC))<0) -#else - if ((mem_fd = open(MEM_FILE,O_RDWR))<0) -#endif - { - perror("opening memory"); - return 0; - } - -#ifndef __alpha__ - if (mmap((void *) VRAM_START, (size_t) VRAM_SIZE, - PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, - mem_fd, VRAM_START) == (void *) -1) -#else - if (!_bus_base()) sparse_shift = 7; /* Uh, oh, JENSEN... */ - if (!_bus_base_sparse()) sparse_shift = 0; - if ((vram_map = mmap(0,(size_t) (VRAM_SIZE << sparse_shift), - PROT_READ | PROT_WRITE, - MAP_SHARED, - mem_fd, (VRAM_START << sparse_shift) - | _bus_base_sparse())) == (void *) -1) -#endif - { - perror("mmap error in map_hardware_ram"); - close(mem_fd); - return (0); - } - vram_mapped = 1; - close(mem_fd); - return (1); -} - -static void -unmap_vram(void) -{ - if (!vram_mapped) return; - - munmap((void*)VRAM_START,VRAM_SIZE); - vram_mapped = 0; -} - -static int -copy_vbios(void) -{ - int mem_fd; - unsigned char *tmp; - int size; - - if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { - perror("opening memory"); - return (0); - } - - if (lseek(mem_fd,(off_t) V_BIOS, SEEK_SET) != (off_t) V_BIOS) { - fprintf(stderr,"Cannot lseek\n"); - goto Error; - } - tmp = (unsigned char *)malloc(3); - if (read(mem_fd, (char *)tmp, (size_t) 3) != (size_t) 3) { - fprintf(stderr,"Cannot read\n"); - goto Error; - } - if (lseek(mem_fd,(off_t) V_BIOS,SEEK_SET) != (off_t) V_BIOS) - goto Error; - - if (*tmp != 0x55 || *(tmp+1) != 0xAA ) { -#ifdef DEBUG - dprint((unsigned long)tmp,0x100); -#endif - fprintf(stderr,"No bios found at: 0x%x\n",V_BIOS); - goto Error; - } - size = *(tmp+2) * 512; - - if (read(mem_fd, (char *)V_BIOS, (size_t) size) != (size_t) size) { - fprintf(stderr,"Cannot read\n"); - goto Error; - } - free(tmp); - close(mem_fd); - if (!chksum((CARD8)V_BIOS)) - return (0); - - return (1); - -Error: - perror("v_bios"); - close(mem_fd); - return (0); -} - -static int -copy_sys_bios(void) -{ -#define SYS_BIOS 0xF0000 - int mem_fd; - - if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { - perror("opening memory"); - return (0); - } - - if (lseek(mem_fd,(off_t) SYS_BIOS,SEEK_SET) != (off_t) SYS_BIOS) - goto Error; - if (read(mem_fd, (char *)SYS_BIOS, (size_t) 0xFFFF) != (size_t) 0xFFFF) - goto Error; - - close(mem_fd); - return (1); - -Error: - perror("sys_bios"); - close(mem_fd); - return (0); -} - -void -loadCodeToMem(unsigned char *ptr, CARD8 code[]) -{ - int i; - CARD8 val; - - for ( i=0;;i++) { - val = code[i]; - *ptr++ = val; - if (val == 0xf4) break; - } - return; -} - -void -dprint(unsigned long start, unsigned long size) -{ - int i,j; - char *c = (char *)start; - - for (j = 0; j < (size >> 4); j++) { - char *d = c; - printf("\n0x%lx: ",(unsigned long)c); - for (i = 0; i<16; i++) - printf("%2.2x ",(unsigned char) (*(c++))); - c = d; - for (i = 0; i<16; i++) { - printf("%c",((((CARD8)(*c)) > 32) && (((CARD8)(*c)) < 128)) ? - (unsigned char) (*(c)): '.'); - c++; - } - } - printf("\n"); -} - -static void -save_bios_to_file(void) -{ - static int num = 0; - int size, count; - char file_name[256]; - int fd; - - sprintf(file_name,"bios_%i.fil",num); - if ((fd = open(file_name,O_WRONLY | O_CREAT | O_TRUNC,00644)) == -1) - return; - size = (*(unsigned char*)(V_BIOS + 2)) * 512; -#ifdef V86BIOS_DEBUG - dprint(V_BIOS,20); -#endif - if ((count = write(fd,(void *)(V_BIOS),size)) != size) - fprintf(stderr,"only saved %i of %i bytes\n",size,count); - num++; -} - -static void -sig_handler(int unused) -{ - fflush(stdout); - fflush(stderr); - - /* put system back in a save state */ - unmap_vram(); - pciVideoRestore(); - outb(0x102, save_pos102); - outb(0x46e8, save_46e8); - outb(0x3C3, save_vse); - outb(0x3C2, save_msr); - - close_console(Console); - iopl(0); - unmap(); - - exit(1); -} - -/* - * For initialization we just pass ax to the BIOS. - * PCI BIOSes need this. All other register are set 0. - */ -static void setup_bios_regs(i86biosRegsPtr regs, CARD32 ax) -{ - regs->ax = ax; - regs->bx = 0; - regs->cx = 0; - regs->dx = 0; - regs->es = 0; - regs->di = 0; -} - -/* - * here we are really paranoid about faking a "real" - * BIOS. Most of this information was pulled from - * dosem. - */ -static void -setup_int_vect(void) -{ - const CARD16 cs = 0x0000; - const CARD16 ip = 0x0; - int i; - - /* let the int vects point to the SYS_BIOS seg */ - for (i=0; i<0x80; i++) { - ((CARD16*)0)[i<<1] = ip; - ((CARD16*)0)[(i<<1)+1] = cs; - } - /* video interrupts default location */ - ((CARD16*)0)[(0x42<<1)+1] = 0xf000; - ((CARD16*)0)[0x42<<1] = 0xf065; - ((CARD16*)0)[(0x10<<1)+1] = 0xf000; - ((CARD16*)0)[0x10<<1] = 0xf065; - /* video param table default location (int 1d) */ - ((CARD16*)0)[(0x1d<<1)+1] = 0xf000; - ((CARD16*)0)[0x1d<<1] = 0xf0A4; - /* font tables default location (int 1F) */ - ((CARD16*)0)[(0x1f<<1)+1] = 0xf000; - ((CARD16*)0)[0x1f<<1] = 0xfa6e; - - /* int 11 default location */ - ((CARD16*)0)[(0x11<1)+1] = 0xf000; - ((CARD16*)0)[0x11<<1] = 0xf84d; - /* int 12 default location */ - ((CARD16*)0)[(0x12<<1)+1] = 0xf000; - ((CARD16*)0)[0x12<<1] = 0xf841; - /* int 15 default location */ - ((CARD16*)0)[(0x15<<1)+1] = 0xf000; - ((CARD16*)0)[0x15<<1] = 0xf859; - /* int 1A default location */ - ((CARD16*)0)[(0x1a<<1)+1] = 0xf000; - ((CARD16*)0)[0x1a<<1] = 0xff6e; - /* int 05 default location */ - ((CARD16*)0)[(0x05<<1)+1] = 0xf000; - ((CARD16*)0)[0x05<<1] = 0xff54; - /* int 08 default location */ - ((CARD16*)0)[(0x8<<1)+1] = 0xf000; - ((CARD16*)0)[0x8<<1] = 0xfea5; - /* int 13 default location (fdd) */ - ((CARD16*)0)[(0x13<<1)+1] = 0xf000; - ((CARD16*)0)[0x13<<1] = 0xec59; - /* int 0E default location */ - ((CARD16*)0)[(0xe<<1)+1] = 0xf000; - ((CARD16*)0)[0xe<<1] = 0xef57; - /* int 17 default location */ - ((CARD16*)0)[(0x17<<1)+1] = 0xf000; - ((CARD16*)0)[0x17<<1] = 0xefd2; - /* fdd table default location (int 1e) */ - ((CARD16*)0)[(0x1e<<1)+1] = 0xf000; - ((CARD16*)0)[0x1e<<1] = 0xefc7; -} - -static int -setup_system_bios(void) -{ - char *date = "06/01/99"; - char *eisa_ident = "PCI/ISA"; - -#if MAP_SYS_BIOS - if (!copy_sys_bios()) return 0; - return 1; -#endif -/* memset((void *)0xF0000,0xf4,0xfff7); */ - - /* - * we trap the "industry standard entry points" to the BIOS - * and all other locations by filling them with "hlt" - * TODO: implement hlt-handler for these - */ - memset((void *)0xF0000,0xf4,0x10000); - - /* - * TODO: we should copy the fdd table (0xfec59-0xfec5b) - * the video parameter table (0xf0ac-0xf0fb) - * and the font tables (0xfa6e-0xfe6d) - * from the original bios here - */ - - /* set bios date */ - strcpy((char *)0xFFFF5,date); - /* set up eisa ident string */ - strcpy((char *)0xFFFD9,eisa_ident); - /* write system model id for IBM-AT */ - ((char *)0)[0xFFFFE] = 0xfc; - - return 1; -} - -static int -chksum(CARD8 *start) -{ - CARD16 size; - CARD8 val = 0; - int i; - - size = *(start+2) * 512; - for (i = 0; i= 0xA0000 && addr <= 0xBFFFF) { - addr -= 0xA0000; - shift = (addr & 0x3) * 8; - result = *(vuip) ((unsigned long)vram_map + (addr << sparse_shift)); - result >>= shift; - return 0xffUL & result; - } else -#endif - return rdb(addr); -} - -CARD16 -mem_rw(CARD32 addr) -{ - unsigned long result, shift; -#if 1 - if (addr >= 0xA0000 && addr <= 0xBFFFF) { - addr -= 0xA0000; - shift = (addr & 0x2) * 8; - result = *(vuip)((unsigned long)vram_map+(addr<>= shift; - return 0xffffUL & result; - } else -#endif - return rdw(addr); -} - -CARD32 -mem_rl(CARD32 addr) -{ - unsigned long result; -#if 1 - if (addr >= 0xA0000 && addr <= 0xBFFFF) { - addr -= 0xA0000; - result = *(vuip)((unsigned long)vram_map+(addr<= 0xA0000 && addr <= 0xBFFFF) { - addr -= 0xA0000; - *(vuip) ((unsigned long)vram_map + (addr << sparse_shift)) = b * 0x01010101; - mem_barrier(); - } else -#endif - wrb(addr,val); -} - -void -mem_ww(CARD32 addr, CARD16 val) -{ - unsigned int w = val & 0xffffU; -#if 1 - if (addr >= 0xA0000 && addr <= 0xBFFFF) { - addr -= 0xA0000; - *(vuip)((unsigned long)vram_map+(addr<= 0xA0000 && addr <= 0xBFFFF) { - addr -= 0xA0000; - *(vuip)((unsigned long)vram_map+(addr< -#include -#include "v86bios.h" -#include "pci.h" - -#define YYSTYPE unsigned long - -#define MAX_VAR 0x20 - - CARD32 var[MAX_VAR]; - CARD32 var_mem; - - -i86biosRegs regs = { 00 }; - -enum mem_type { BYTE, WORD, LONG, STRING }; -union mem_val { - CARD32 integer; - char *ptr; -} rec; - -struct mem { - enum mem_type type; - union mem_val val; - struct mem *next; -}; - - -struct device Device = {FALSE,NONE,{0}}; - -extern void yyerror(char *s); -extern int yylex( void ); - -static void boot(void); -static void dump_mem(CARD32 addr, int len); -static void exec_int(int num); -static void *add_to_list(enum mem_type type, union mem_val *rec, void *next); -static void do_list(struct mem *list, memType addr); -static char * normalize_string(char *ptr); -%} - -%token TOK_NUM -%token TOK_REG_AX -%token TOK_REG_BX -%token TOK_REG_CX -%token TOK_REG_DX -%token TOK_REG_DI -%token TOK_REG_SI -%token TOK_SEG_DS -%token TOK_SEG_ES -%token TOK_SEP -%token TOK_VAR -%token TOK_VAR_MEM -%token TOK_COMMAND_BOOT -%token TOK_COMMAND_EXEC -%token TOK_SELECT -%token TOK_STRING -%token TOK_MODIFIER_BYTE -%token TOK_MODIFIER_WORD -%token TOK_MODIFIER_LONG -%token TOK_MODIFIER_MEMSET -%token TOK_COMMAND_MEMSET -%token TOK_COMMAND_MEMDUMP -%token TOK_COMMAND_QUIT -%token TOK_ERROR -%token TOK_END -%token TOK_ISA -%token TOK_PCI -%token TOK_BYTE -%token TOK_WORD -%token TOK_LONG -%token TOK_PRINT_PORT -%token TOK_IOSTAT -%token TOK_PRINT_IRQ -%token TOK_PPCI -%token TOK_PIP -%token TOK_TRACE -%token TOK_ON -%token TOK_OFF -%token TOK_VERBOSE -%token TOK_LOG -%token TOK_LOGOFF -%token TOK_CLSTAT -%token TOK_STDOUT -%token TOK_HLT -%token TOK_DEL -%token TOK_IOPERM -%token TOK_DUMP_PCI -%token TOK_BOOT_BIOS -%% -input: | input line -line: end | com_reg | com_var | com_select - | com_boot | com_memset | com_memdump | com_quit - | com_exec | hlp | config | verbose | logging | print | clstat - | com_hlt | ioperm | list_pci | boot_bios - | error end { printf("unknown command\n"); } -; -end: TOK_END -; -com_reg: reg_off val end { *(CARD16*)$1 = $2 & 0xffff; } - | reg_seg TOK_SEP reg_off val end { - *(CARD16*)$1 = ($4 & 0xf0000) >> 4; - *(CARD16*)$3 = ($4 & 0x0ffff); - } - | reg_off '?' end { printf("0x%x\n",*(CARD16*)$1);} - | reg_seg TOK_SEP reg_off '?' end - { printf("0x%x:0x%x\n",*(CARD16*)$1, - *(CARD16*)$3); } -; -register_read: reg_seg TOK_SEP reg_off { $$ = (((*(CARD16*)$1) << 4) - | ((*(CARD16*)$3) & 0xffff)); - } - | reg_off { $$ = ((*(CARD16*)$1) & 0xffff); } -; -reg_off: TOK_REG_AX { $$ = (unsigned long)&(regs.ax); } - | TOK_REG_BX { $$ = (unsigned long)&(regs.bx); } - | TOK_REG_CX { $$ = (unsigned long)&(regs.cx); } - | TOK_REG_DX { $$ = (unsigned long)&(regs.dx); } - | TOK_REG_DI { $$ = (unsigned long)&(regs.di); } - | TOK_REG_SI { $$ = (unsigned long)&(regs.si); } -; -reg_seg: TOK_SEG_DS { $$ = (unsigned long)&(regs.ds); } - | TOK_SEG_ES { $$ = (unsigned long)&(regs.es); } -; -com_var: TOK_VAR_MEM '?' end { printf("var mem: 0x%x\n",var_mem); } - | TOK_VAR '?' end { if ($1 < MAX_VAR) - printf("var[%i]: 0x%x\n",(int)$1,var[$1]); - else - printf("var index %i out of range\n",(int)$1); } - | TOK_VAR_MEM val end { var_mem = $2; } - | TOK_VAR val end { if ($1 <= MAX_VAR) - var[$1] = $2; - else - printf("var index %i out of range\n",(int)$1); } - | TOK_VAR error end { printf("$i val\n"); } - | TOK_VAR_MEM error end { printf("$i val\n"); } -; -com_boot: TOK_COMMAND_BOOT end { boot(); } - TOK_COMMAND_BOOT error end { boot(); } -; -com_select: TOK_SELECT TOK_ISA end { Device.booted = FALSE; - Device.type = ISA; - CurrentPci = NULL; } - | TOK_SELECT TOK_PCI val TOK_SEP val TOK_SEP val end - { Device.booted = FALSE; - Device.type = PCI; - Device.loc.pci.bus = $3; - Device.loc.pci.dev = $5; - Device.loc.pci.func = $7; } - | TOK_SELECT '?' end - { switch (Device.type) { - case ISA: - printf("isa\n"); - break; - case PCI: - printf("pci: %x:%x:%x\n",Device.loc.pci.bus, - Device.loc.pci.dev, - Device.loc.pci.func); - break; - default: - printf("no device selected\n"); - break; - } - } - | TOK_SELECT error end { printf("select ? | isa " - "| pci:bus:dev:func\n"); } -; -com_quit: TOK_COMMAND_QUIT end { return 0; } - | TOK_COMMAND_QUIT error end { logoff(); return 0; } -; -com_exec: TOK_COMMAND_EXEC end { exec_int(0x10); } - | TOK_COMMAND_EXEC val end { exec_int($2); } - | TOK_COMMAND_EXEC error end { exec_int(0x10); } -; -com_memdump: TOK_COMMAND_MEMDUMP val val end { dump_mem($2,$3); } - | TOK_COMMAND_MEMDUMP error end { printf("memdump start len\n"); } - - -; -com_memset: TOK_COMMAND_MEMSET val list end { do_list((struct mem*)$3,$2);} - | TOK_COMMAND_MEMSET error end { printf("setmem addr [byte val] " - "[word val] [long val] " - "[\"string\"]\n"); } -; -list: { $$ = 0; } - | TOK_BYTE val list { rec.integer = $2; - $$ = (unsigned long)add_to_list(BYTE,&rec,(void*)$3); } - | TOK_WORD val list { rec.integer = $2; - $$ = (unsigned long) add_to_list(WORD,&rec,(void*)$3); } - | TOK_LONG val list { rec.integer = $2; - $$ = (unsigned long) add_to_list(LONG,&rec,(void*)$3); } - | TOK_STRING list { rec.ptr = (void*)$1; - $$ = (unsigned long) add_to_list(STRING,&rec,(void*)$2); } -; -val: TOK_VAR { if ($1 > MAX_VAR) { - printf("variable index out of range\n"); - $$=0; - } else - $$ = var[$1]; } - | TOK_NUM { $$ = $1; } - | register_read -; -bool: TOK_ON { $$ = 1; } - | TOK_OFF { $$ = 0; } -; -config: TOK_PRINT_PORT bool end { Config.PrintPort = $2; } - | TOK_PRINT_PORT '?' end { printf("print port %s\n", - Config.PrintPort?"on":"off"); } - | TOK_PRINT_PORT error end { printf("pport on | off | ?\n") } - | TOK_PRINT_IRQ bool end { Config.PrintIrq = $2; } - | TOK_PRINT_IRQ '?' end { printf("print irq %s\n", - Config.PrintIrq?"on":"off"); } - | TOK_PRINT_IRQ error end { printf("pirq on | off | ?\n") } - | TOK_PPCI bool end { Config.PrintPci = $2; } - | TOK_PPCI '?' end { printf("print PCI %s\n", - Config.PrintPci?"on":"off"); } - | TOK_PPCI error end { printf("ppci on | off | ?\n") } - | TOK_PIP bool end { Config.PrintIp = $2; } - | TOK_PIP '?' end { printf("printip %s\n", - Config.PrintIp?"on":"off"); } - | TOK_PIP error end { printf("pip on | off | ?\n") } - | TOK_IOSTAT bool end { Config.IoStatistics = $2; } - | TOK_IOSTAT '?' end { printf("io statistics %s\n", - Config.IoStatistics?"on":"off"); } - | TOK_IOSTAT error end { printf("iostat on | off | ?\n") } - | TOK_TRACE bool end { Config.Trace = $2; } - | TOK_TRACE '?' end { printf("trace %s\n", - Config.Trace ?"on":"off"); } - | TOK_TRACE error end { printf("trace on | off | ?\n") } -; -verbose: TOK_VERBOSE val end { Config.Verbose = $2; } - | TOK_VERBOSE '?' end { printf("verbose: %i\n", - Config.Verbose); } - | TOK_VERBOSE error end { printf("verbose val | ?\n"); } -; -logging: TOK_LOG TOK_STRING end { logon(normalize_string((char*)$2)); } - | TOK_LOG '?' end { if (logging) printf("logfile: %s\n", - logfile); - else printf("no logging\n?"); } - | TOK_LOG TOK_OFF end { logoff(); } - | TOK_LOG error end { printf("log \"\" | ? |" - " off\n"); } -; -clstat: TOK_CLSTAT end { clear_stat(); } - | TOK_CLSTAT error end { printf("clstat\n"); } -; -print: TOK_STDOUT bool end { nostdout = !$2; } - | TOK_STDOUT '?' end { printf("print %s\n",nostdout ? - "no":"yes"); } - | TOK_STDOUT error end { printf("print on | off\n"); } -; -com_hlt: TOK_HLT val end { add_hlt($2); } - | TOK_HLT TOK_DEL val end { del_hlt($3); } - | TOK_HLT TOK_DEL end { del_hlt(21); } - | TOK_HLT '?' end { list_hlt(); } - | TOK_HLT error end { printf( - "hlt val | del [val] | ?\n"); } -; -ioperm: TOK_IOPERM val val val end { int i,max; - if ($2 >= 0) { - max = $2 + $3 - 1; - if (max > IOPERM_BITS) - max = IOPERM_BITS; - for (i = $2;i <= max; i++) - ioperm_list[i] - = $4>0 ? 1 : 0; - } - } - | TOK_IOPERM '?' end { int i,start; - for (i=0; i <= IOPERM_BITS; i++) { - if (ioperm_list[i]) { - start = i; - for (; i <= IOPERM_BITS; i++) - if (!ioperm_list[i]) { - printf("ioperm on in " - "0x%x+0x%x\n", start,i-start); - break; - } - } - } - } - | TOK_IOPERM error end { printf("ioperm start len val\n"); } -; -list_pci: TOK_DUMP_PCI end { list_pci(); } - | TOK_DUMP_PCI error end { list_pci(); } -; -boot_bios: TOK_BOOT_BIOS '?' end { if (!BootBios) printf("No Boot BIOS\n"); - else printf("BootBIOS from: %i:%i:%i\n", - BootBios->bus, BootBios->dev, - BootBios->func); } - | TOK_BOOT_BIOS error end { printf ("bootbios bus:dev:num\n"); } -; -hlp: '?' { printf("Command list:\n"); - printf(" select isa | pci bus:dev:func\n"); - printf(" boot\n"); - printf(" seg:reg val | reg val \n"); - printf(" $x val | $mem val\n"); - printf(" setmem addr list; addr := val\n"); - printf(" dumpmem addr len; addr,len := val\n"); - printf(" do [val]\n"); - printf(" quit\n"); - printf(" ?\n"); - printf(" seg := ds | es;" - " reg := ax | bx | cx | dx | si \n"); - printf(" val := var | | seg:reg | seg\n"); - printf(" var := $x | $mem; x := 0..20\n"); - printf(" list := byte val | word val | long val " - "| \"string\"\n"); - printf(" pport on | off | ?\n"); - printf(" ppci on | off | ?\n"); - printf(" pirq on | off | ?\n"); - printf(" pip on | off | ?\n"); - printf(" trace on | off | ?\n"); - printf(" iostat on | off | ?\n"); - printf(" verbose val\n"); - printf(" log \"\" | off | ?\n"); - printf(" print on | off\n"); - printf(" hlt val | del [val] | ?\n"); - printf(" clstat\n"); - printf(" lpci\n"); - printf ("bootbios ?\n"); -} -; - -%% - -static void -dump_mem(CARD32 addr, int len) -{ - dprint(addr,len); -} - -static void -exec_int(int num) -{ - if (num == 0x10) { /* video interrupt */ - if (Device.type == NONE) { - CurrentPci = PciList; - while (CurrentPci) { - if (CurrentPci->active) - break; - CurrentPci = CurrentPci->next; - } - if (!CurrentPci) - Device.type = ISA; - else { - Device.type = PCI; - Device.loc.pci.dev = CurrentPci->dev; - Device.loc.pci.bus = CurrentPci->bus; - Device.loc.pci.func = CurrentPci->func; - } - } - if (Device.type != ISA) { - if (!Device.booted) { - if (!CurrentPci || (Device.type == PCI - && (!CurrentPci->active - && (Device.loc.pci.dev != CurrentPci->dev - || Device.loc.pci.bus != CurrentPci->bus - || Device.loc.pci.func != CurrentPci->func)))) { - printf("boot the device fist\n"); - return; - } - } - } else - CurrentPci = NULL; - } else { - Device.booted = FALSE; /* we need this for sanity! */ - } - - runINT(num,®s); -} - -static void -boot(void) -{ - if (Device.type == NONE) { - printf("select a device fist\n"); - return; - } - - call_boot(&Device); -} - -static void * -add_to_list(enum mem_type type, union mem_val *rec, void *next) -{ - struct mem *mem_rec = (struct mem *) malloc(sizeof(mem_rec)); - - mem_rec->type = type; - mem_rec->next = next; - - switch (type) { - case BYTE: - case WORD: - case LONG: - mem_rec->val.integer = rec->integer; - break; - case STRING: - mem_rec->val.ptr = normalize_string(rec->ptr); - break; - } - return mem_rec; -} - -static int -validRange(int addr,int len) -{ - int end = addr + len; - - if (addr < 0x1000 || end > 0xc0000) - return 0; - return 1; -} - -static void -do_list(struct mem *list, memType addr) -{ - struct mem *prev; - int len; - - while (list) { - switch (list->type) { - case BYTE: - if (!validRange(addr,1)) goto error; - *(CARD8*)addr = list->val.integer; - addr =+ 1; - break; - case WORD: - if (!validRange(addr,2)) goto error; - *(CARD16*)addr = list->val.integer; - addr =+ 2; - break; - case LONG: - if (!validRange(addr,4)) goto error; - *(CARD32*)addr = list->val.integer; - addr =+ 4; - break; - case STRING: - len = strlen((char*)list->val.ptr); - if (!validRange(addr,len)) goto error; - memcpy((CARD8*)addr,(void*)list->val.ptr,len); - addr =+ len; - free(list->val.ptr); - break; - } - prev = list; - list = list->next; - free(prev); - continue; - error: - printf("address out of range\n"); - while (list) { - prev = list; - list = list->next; - free(prev); - } - break; - } -} - -static char * -normalize_string(char *ptr) -{ - int i = 0, j = 0, c = 0, esc= 0; - int size; - char *mem_ptr; - - size = strlen(ptr); - mem_ptr = malloc(size); - while (1) { - switch (*(ptr + i)) { - case '\\': - if (esc) { - *(mem_ptr + j++) = *(ptr + i); - esc = 0; - } else - esc = 1; - break; - case '\"': - if (esc) { - *(mem_ptr + j++) = *(ptr + i); - esc = 0; - } else - c++; - break; - default: - *(mem_ptr + j++) = *(ptr + i); - break; - } - if (c > 1) { - *(mem_ptr + j) = '\0'; - break; - } - i++; - } - return mem_ptr; -} diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/pci.c b/board/MAI/bios_emulator/scitech/src/v86bios/pci.c deleted file mode 100644 index b58a57195f..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/pci.c +++ /dev/null @@ -1,902 +0,0 @@ -/* - * Copyright 1999 Egbert Eich - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the authors not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The authors makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ -#include "debug.h" -#include -#include -#include -#include -#include -#include -#include -#include -#if defined (__alpha__) || defined (__ia64__) -#include -#endif -#include "AsmMacros.h" - -#include "pci.h" - -/* - * I'm rather simple mindend - therefore I do a poor man's - * pci scan without all the fancy stuff that is done in - * scanpci. However that's all we need. - */ - -PciStructPtr PciStruct = NULL; -PciBusPtr PciBuses = NULL; -PciStructPtr CurrentPci = NULL; -PciStructPtr PciList = NULL; -PciStructPtr BootBios = NULL; -int pciMaxBus = 0; - -static CARD32 PciCfg1Addr; - -static void readConfigSpaceCfg1(CARD32 bus, CARD32 dev, CARD32 func, - CARD32 *reg); -static int checkSlotCfg1(CARD32 bus, CARD32 dev, CARD32 func); -static int checkSlotCfg2(CARD32 bus, int dev); -static void readConfigSpaceCfg2(CARD32 bus, int dev, CARD32 *reg); -static CARD8 interpretConfigSpace(CARD32 *reg, int busidx, - CARD8 dev, CARD8 func); -static CARD32 findBIOSMap(PciStructPtr pciP, CARD32 *biosSize); -static void restoreMem(PciStructPtr pciP); - - -#ifdef __alpha__ -#define PCI_BUS_FROM_TAG(tag) (((tag) & 0x00ff0000) >> 16) -#define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00) >> 8) - -#include - -CARD32 -axpPciCfgRead(CARD32 tag) -{ - int bus, dfn; - CARD32 val = 0xffffffff; - - bus = PCI_BUS_FROM_TAG(tag); - dfn = PCI_DFN_FROM_TAG(tag); - - syscall(__NR_pciconfig_read, bus, dfn, tag & 0xff, 4, &val); - return(val); -} - -void -axpPciCfgWrite(CARD32 tag, CARD32 val) -{ - int bus, dfn; - - bus = PCI_BUS_FROM_TAG(tag); - dfn = PCI_DFN_FROM_TAG(tag); - - syscall(__NR_pciconfig_write, bus, dfn, tag & 0xff, 4, &val); -} - -static CARD32 (*readPci)(CARD32 reg) = axpPciCfgRead; -static void (*writePci)(CARD32 reg, CARD32 val) = axpPciCfgWrite; -#else -static CARD32 readPciCfg1(CARD32 reg); -static void writePciCfg1(CARD32 reg, CARD32 val); -static CARD32 readPciCfg2(CARD32 reg); -static void writePciCfg2(CARD32 reg, CARD32 val); - -static CARD32 (*readPci)(CARD32 reg) = readPciCfg1; -static void (*writePci)(CARD32 reg, CARD32 val) = writePciCfg1; -#endif - -#if defined(__alpha__) || defined(__sparc__) -#define PCI_EN 0x00000000 -#else -#define PCI_EN 0x80000000 -#endif - - -static int numbus; -static int hostbridges = 1; -static unsigned long pciMinMemReg = ~0; - - -void -scan_pci(void) -{ - unsigned short configtype; - - CARD32 reg[64]; - int busidx; - CARD8 cardnum; - CARD8 func; - int idx; - - int i; - PciStructPtr pci1; - PciBusPtr pci_b1,pci_b2; - -#if defined(__alpha__) || defined(__powerpc__) || defined(__sparc__) || defined(__ia64__) - configtype = 1; -#else - CARD8 tmp1, tmp2; - CARD32 tmp32_1, tmp32_2; - outb(PCI_MODE2_ENABLE_REG, 0x00); - outb(PCI_MODE2_FORWARD_REG, 0x00); - tmp1 = inb(PCI_MODE2_ENABLE_REG); - tmp2 = inb(PCI_MODE2_FORWARD_REG); - if ((tmp1 == 0x00) && (tmp2 == 0x00)) { - configtype = 2; - readPci = readPciCfg2; - writePci = writePciCfg2; - P_printf("PCI says configuration type 2\n"); - } else { - tmp32_1 = inl(PCI_MODE1_ADDRESS_REG); - outl(PCI_MODE1_ADDRESS_REG, PCI_EN); - tmp32_2 = inl(PCI_MODE1_ADDRESS_REG); - outl(PCI_MODE1_ADDRESS_REG, tmp32_1); - if (tmp32_2 == PCI_EN) { - configtype = 1; - P_printf("PCI says configuration type 1\n"); - } else { - P_printf("No PCI !\n"); - return; - } - } -#endif - - if (configtype == 1) { - P_printf("PCI probing configuration type 1\n"); - busidx = 0; - numbus = 1; - idx = 0; - do { - P_printf("\nProbing for devices on PCI bus %d:\n", busidx); - for (cardnum = 0; cardnum < MAX_DEV_PER_VENDOR_CFG1; cardnum++) { - func = 0; - do { - /* loop over the different functions, if present */ - if (!checkSlotCfg1(busidx,cardnum,func)) - break; - readConfigSpaceCfg1(busidx,cardnum,func,reg); - - func = interpretConfigSpace(reg,busidx, - cardnum,func); - - if (idx++ > MAX_PCI_DEVICES) - continue; - } while (func < 8); - } - } while (++busidx < PCI_MAXBUS); -#if defined(__alpha__) || defined(__powerpc__) || defined(__sparc__) || defined(__ia64__) - /* don't use outl() ;-) */ -#else - outl(PCI_MODE1_ADDRESS_REG, 0); -#endif - } else { - int slot; - - P_printf("PCI probing configuration type 2\n"); - busidx = 0; - numbus = 1; - idx = 0; - do { - for (slot=0xc0; slot<0xd0; i++) { - if (!checkSlotCfg2(busidx,slot)) - break; - readConfigSpaceCfg2(busidx,slot,reg); - - interpretConfigSpace(reg,busidx, - slot,0); - if (idx++ > MAX_PCI_DEVICES) - continue; - } - } while (++busidx < PCI_MAXBUS); - } - - - pciMaxBus = numbus - 1; - P_printf("Number of buses in system: %i\n",pciMaxBus + 1); - P_printf("Min PCI mem address: 0x%lx\n",pciMinMemReg); - - /* link buses */ - pci_b1 = PciBuses; - while (pci_b1) { - pci_b2 = PciBuses; - pci_b1->pBus = NULL; - while (pci_b2) { - if (pci_b1->primary == pci_b2->secondary) - pci_b1->pBus = pci_b2; - pci_b2 = pci_b2->next; - } - pci_b1 = pci_b1->next; - } - pci1 = PciStruct; - while (pci1) { - pci_b2 = PciBuses; - pci1->pBus = NULL; - while (pci_b2) { - if (pci1->bus == pci_b2->secondary) - pci1->pBus = pci_b2; - pci_b2 = pci_b2->next; - } - pci1 = pci1->next; - } - if (RESORT) { - PciStructPtr tmp = PciStruct, tmp1; - PciStruct = NULL; - while (tmp) { - tmp1 = tmp->next; - tmp->next = PciStruct; - PciStruct = tmp; - tmp = tmp1; - } - } - PciList = CurrentPci = PciStruct; -} - -#ifndef __alpha__ -static CARD32 -readPciCfg1(CARD32 reg) -{ - CARD32 val; - - outl(PCI_MODE1_ADDRESS_REG, reg); - val = inl(PCI_MODE1_DATA_REG); - outl(PCI_MODE1_ADDRESS_REG, 0); - P_printf("reading: 0x%x from 0x%x\n",val,reg); - return val; -} - -static void -writePciCfg1(CARD32 reg, CARD32 val) -{ - P_printf("writing: 0x%x to 0x%x\n",val,reg); - outl(PCI_MODE1_ADDRESS_REG, reg); - outl(PCI_MODE1_DATA_REG,val); - outl(PCI_MODE1_ADDRESS_REG, 0); -} - -static CARD32 -readPciCfg2(CARD32 reg) -{ - CARD32 val; - CARD8 bus = (reg >> 16) & 0xff; - CARD8 dev = (reg >> 11) & 0x1f; - CARD8 num = reg & 0xff; - - outb(PCI_MODE2_ENABLE_REG, 0xF1); - outb(PCI_MODE2_FORWARD_REG, bus); - val = inl((dev << 8) + num); - outb(PCI_MODE2_ENABLE_REG, 0x00); - P_printf("reading: 0x%x from 0x%x\n",val,reg); - return val; -} - -static void -writePciCfg2(CARD32 reg, CARD32 val) -{ - CARD8 bus = (reg >> 16) & 0xff; - CARD8 dev = (reg >> 11) & 0x1f; - CARD8 num = reg & 0xff; - - P_printf("writing: 0x%x to 0x%x\n",val,reg); - outb(PCI_MODE2_ENABLE_REG, 0xF1); - outb(PCI_MODE2_FORWARD_REG, bus); - outl((dev << 8) + num,val); - outb(PCI_MODE2_ENABLE_REG, 0x00); -} -#endif - -void -pciVideoDisable(void) -{ - /* disable VGA routing on bridges */ - PciBusPtr pbp = PciBuses; - PciStructPtr pcp = PciStruct; - - while (pbp) { - writePci(pbp->Slot.l | 0x3c, pbp->bctl & ~(CARD32)(8<<16)); - pbp = pbp->next; - } - /* disable display devices */ - while (pcp) { - writePci(pcp->Slot.l | 0x04, pcp->cmd_st & ~(CARD32)3); - writePci(pcp->Slot.l | 0x30, pcp->RomBase & ~(CARD32)1); - pcp = pcp->next; - } -} - -void -pciVideoRestore(void) -{ - /* disable VGA routing on bridges */ - PciBusPtr pbp = PciBuses; - PciStructPtr pcp = PciStruct; - - while (pbp) { - writePci(pbp->Slot.l | 0x3c, pbp->bctl); - pbp = pbp->next; - } - /* disable display devices */ - while (pcp) { - writePci(pcp->Slot.l | 0x04, pcp->cmd_st); - writePci(pcp->Slot.l | 0x30, pcp->RomBase); - pcp = pcp->next; - } -} - -void -EnableCurrent() -{ - PciBusPtr pbp; - PciStructPtr pcp = CurrentPci; - - pciVideoDisable(); - - pbp = pcp->pBus; - while (pbp) { /* enable bridges */ - writePci(pbp->Slot.l | 0x3c, pbp->bctl | (CARD32)(8<<16)); - pbp = pbp->pBus; - } - writePci(pcp->Slot.l | 0x04, pcp->cmd_st | (CARD32)3); - writePci(pcp->Slot.l | 0x30, pcp->RomBase | (CARD32)1); -} - -CARD8 -PciRead8(int offset, CARD32 Slot) -{ - int shift = offset & 0x3; - offset = offset & 0xFC; - return ((readPci(Slot | offset) >> (shift << 3)) & 0xff); -} - -CARD16 -PciRead16(int offset, CARD32 Slot) -{ - int shift = offset & 0x2; - offset = offset & 0xFC; - return ((readPci(Slot | offset) >> (shift << 3)) & 0xffff); -} - -CARD32 -PciRead32(int offset, CARD32 Slot) -{ - offset = offset & 0xFC; - return (readPci(Slot | offset)); -} - -void -PciWrite8(int offset, CARD8 byte, CARD32 Slot) -{ - CARD32 val; - int shift = offset & 0x3; - offset = offset & 0xFC; - val = readPci(Slot | offset); - val &= ~(CARD32)(0xff << (shift << 3)); - val |= byte << (shift << 3); - writePci(Slot | offset, val); -} - -void -PciWrite16(int offset, CARD16 word, CARD32 Slot) -{ - CARD32 val; - int shift = offset & 0x2; - offset = offset & 0xFC; - val = readPci(Slot | offset); - val &= ~(CARD32)(0xffff << (shift << 3)); - val |= word << (shift << 3); - writePci(Slot | offset, val); -} - -void -PciWrite32(int offset, CARD32 lg, CARD32 Slot) -{ - offset = offset & 0xFC; - writePci(Slot | offset, lg); -} - -int -mapPciRom(PciStructPtr pciP) -{ - unsigned long RomBase = 0; - int mem_fd; - unsigned char *mem, *ptr; - unsigned char *scratch = NULL; - int length = 0; - CARD32 biosSize = 0x1000000; - CARD32 enablePci; - - if (!pciP) - pciP = CurrentPci; - - if (FIX_ROM) { - RomBase = findBIOSMap(pciP, &biosSize); - if (!RomBase) { - fprintf(stderr,"Cannot remap BIOS of %i:%i:%i " - "- trying preset address\n",pciP->bus,pciP->dev, - pciP->func); - RomBase = pciP->RomBase & ~(CARD32)0xFF; - } - } else { - RomBase = pciP->RomBase & ~(CARD32)0xFF; - if (~RomBase + 1 < biosSize || !RomBase) - RomBase = findBIOSMap(pciP, &biosSize); - } - - P_printf("RomBase: 0x%lx\n",RomBase); - - if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { - perror("opening memory"); - restoreMem(pciP); - return (0); - } - - PciWrite32(0x30,RomBase | 1,pciP->Slot.l); - -#ifdef __alpha__ - mem = ptr = (unsigned char *)mmap(0, biosSize, PROT_READ, - MAP_SHARED, mem_fd, RomBase | _bus_base()); -#else - mem = ptr = (unsigned char *)mmap(0, biosSize, PROT_READ, - MAP_SHARED, mem_fd, RomBase); -#endif - if (pciP != CurrentPci) { - enablePci = PciRead32(0x4,pciP->Slot.l); - PciWrite32(0x4,enablePci | 0x2,pciP->Slot.l); - } - -#ifdef PRINT_PCI - dprint((unsigned long)ptr,0x30); -#endif - while ( *ptr == 0x55 && *(ptr+1) == 0xAA) { - unsigned short data_off = *(ptr+0x18) | (*(ptr+0x19)<< 8); - unsigned char *data = ptr + data_off; - unsigned char type; - int i; - - if (*data!='P' || *(data+1)!='C' || *(data+2)!='I' || *(data+3)!='R') { - break; - } - type = *(data + 0x14); - P_printf("data segment in BIOS: 0x%x, type: 0x%x ",data_off,type); - - if (type != 0) { /* not PC-AT image: find next one */ - unsigned int image_length; - unsigned char indicator = *(data + 0x15); - if (indicator & 0x80) /* last image */ - break; - image_length = (*(data + 0x10) - | (*(data + 0x11) << 8)) << 9; - P_printf("data image length: 0x%x, ind: 0x%x\n", - image_length,indicator); - ptr = ptr + image_length; - continue; - } - /* OK, we have a PC Image */ - length = (*(ptr + 2) << 9); - P_printf("BIOS length: 0x%x\n",length); - scratch = (unsigned char *)malloc(length); - /* don't use memcpy() here: Reading from bus! */ - for (i=0;iSlot.l); - - /* unmap/close/disable PCI bios mem */ - munmap(mem, biosSize); - close(mem_fd); - /* disable and restore mapping */ - writePci(pciP->Slot.l | 0x30, pciP->RomBase & ~(CARD32)1); - - if (scratch && length) { - memcpy((unsigned char *)V_BIOS, scratch, length); - free(scratch); - } - - restoreMem(pciP); - return length; -} - -CARD32 -findPci(CARD16 slotBX) -{ - CARD32 slot = slotBX << 8; - - if (slot == (CurrentPci->Slot.l & ~PCI_EN)) - return (CurrentPci->Slot.l | PCI_EN); - else { -#if !SHOW_ALL_DEV - PciBusPtr pBus = CurrentPci->pBus; - while (pBus) { - /* fprintf(stderr,"slot: 0x%x bridge: 0x%x\n",slot, pBus->Slot.l); */ - if (slot == (pBus->Slot.l & ~PCI_EN)) - return pBus->Slot.l | PCI_EN; - pBus = pBus->next; - } -#else - PciStructPtr pPci = PciStruct; - while (pPci) { - /*fprintf(stderr,"slot: 0x%x bridge: 0x%x\n",slot, pPci->Slot.l); */ - if (slot == (pPci->Slot.l & ~PCI_EN)) - return pPci->Slot.l | PCI_EN; - pPci = pPci->next; - } -#endif - } - return 0; -} - -CARD16 -pciSlotBX(PciStructPtr pPci) -{ - return (CARD16)((pPci->Slot.l >> 8) & 0xFFFF); -} - -PciStructPtr -findPciDevice(CARD16 vendorID, CARD16 deviceID, char n) -{ - PciStructPtr pPci = CurrentPci; - n++; - - while (pPci) { - if ((pPci->VendorID == vendorID) && (pPci->DeviceID == deviceID)) { - if (!(--n)) break; - } - pPci = pPci->next; - } - return pPci; -} - -PciStructPtr -findPciClass(CARD8 intf, CARD8 subClass, CARD16 class, char n) -{ - PciStructPtr pPci = CurrentPci; - n++; - - while (pPci) { - if ((pPci->Interface == intf) && (pPci->SubClass == subClass) - && (pPci->BaseClass == class)) { - if (!(--n)) break; - } - pPci = pPci->next; - } - return pPci; -} - -static void -readConfigSpaceCfg1(CARD32 bus, CARD32 dev, CARD32 func, CARD32 *reg) -{ - CARD32 config_cmd = PCI_EN | (bus<<16) | - (dev<<11) | (func<<8); - int i; - - for (i = 0; i<64;i+=4) { -#ifdef __alpha__ - reg[i] = axpPciCfgRead(config_cmd | i); -#else - outl(PCI_MODE1_ADDRESS_REG, config_cmd | i); - reg[i] = inl(PCI_MODE1_DATA_REG); -#endif - -#ifdef V86BIOS_DEBUG - P_printf("0x%lx\n",reg[i]); -#endif - } -} - -static int -checkSlotCfg1(CARD32 bus, CARD32 dev, CARD32 func) -{ - CARD32 config_cmd = PCI_EN | (bus<<16) | - (dev<<11) | (func<<8); - CARD32 reg; -#ifdef __alpha__ - reg = axpPciCfgRead(config_cmd); -#else - outl(PCI_MODE1_ADDRESS_REG, config_cmd); - reg = inl(PCI_MODE1_DATA_REG); -#endif - if (reg != 0xFFFFFFFF) - return 1; - else - return 0; -} - -static int -checkSlotCfg2(CARD32 bus, int dev) -{ - CARD32 val; - - outb(PCI_MODE2_ENABLE_REG, 0xF1); - outb(PCI_MODE2_FORWARD_REG, bus); - val = inl(dev << 8); - outb(PCI_MODE2_FORWARD_REG, 0x00); - outb(PCI_MODE2_ENABLE_REG, 0x00); - if (val == 0xFFFFFFFF) - return 0; - if (val == 0xF0F0F0F0) - return 0; - return 1; -} - -static void -readConfigSpaceCfg2(CARD32 bus, int dev, CARD32 *reg) -{ - int i; - - outb(PCI_MODE2_ENABLE_REG, 0xF1); - outb(PCI_MODE2_FORWARD_REG, bus); - for (i = 0; i<64;i+=4) { - reg[i] = inl((dev << 8) + i); -#ifdef V86BIOS_DEBUG - P_printf("0x%lx\n",reg[i]); -#endif - } - outb(PCI_MODE2_ENABLE_REG, 0x00); -} - -static CARD8 -interpretConfigSpace(CARD32 *reg, int busidx, CARD8 dev, CARD8 func) -{ - CARD32 config_cmd; - CARD16 vendor, device; - CARD8 baseclass, subclass; - CARD8 primary, secondary; - CARD8 header, interface; - int i; - - config_cmd = PCI_EN | busidx<<16 | - (dev<<11) | (func<<8); - - for (i = 0x10; i < 0x28; i+=4) { - if (IS_MEM32(reg[i])) - if ((reg[i] & 0xFFFFFFF0) < pciMinMemReg) - pciMinMemReg = (reg[i] & 0xFFFFFFF0); -#ifdef __alpha__ - if (IS_MEM64(reg[i])) { - unsigned long addr = reg[i] | - (unsigned long)(reg[i+4]) << 32; - if ((addr & ~0xfL) < pciMinMemReg) - pciMinMemReg = (addr & ~0xfL); - i+=4; - } -#endif - } - vendor = reg[0] & 0xFFFF; - device = reg[0] >> 16; - P_printf("bus: %i card: %i func %i reg0: 0x%x ", busidx,dev,func,reg[0]); - baseclass = reg[8] >> 24; - subclass = (reg[8] >> 16) & 0xFF; - interface = (reg[8] >> 8) & 0xFF; - - header = (reg[0x0c] >> 16) & 0xff; - P_printf("bc 0x%x, sub 0x%x, if 0x%x, hdr 0x%x\n", - baseclass,subclass,interface,header); - if (BRIDGE_CLASS(baseclass)) { - if (BRIDGE_PCI_CLASS(subclass)) { - PciBusPtr pbp = malloc(sizeof(PciBusRec)); - P_printf("Pci-Pci Bridge found; "); - primary = reg[0x18] & 0xFF; - secondary = (reg[0x18] >> 8) & 0xFF; - P_printf("primary: 0x%x secondary: 0x%x\n", - primary,secondary); - pbp->bctl = reg[0x3c]; - pbp->primary = primary; - pbp->secondary = secondary; - pbp->Slot.l = config_cmd; - pbp->next = PciBuses; - PciBuses = pbp; - numbus++; - } else if (BRIDGE_HOST_CLASS(subclass) - && (hostbridges++ > 1)) { - numbus++; - } - } else if (VIDEO_CLASS(baseclass,subclass)) { - PciStructPtr pcp = malloc(sizeof(PciStructRec)); - P_printf("Display adapter found\n"); - pcp->RomBase = reg[0x30]; - pcp->cmd_st = reg[4]; - pcp->active = (reg[4] & 0x03) == 3 ? 1 : 0; - pcp->VendorID = vendor; - pcp->DeviceID = device; - pcp->Interface = interface; - pcp->BaseClass = baseclass; - pcp->SubClass = subclass; - pcp->Slot.l = config_cmd; - pcp->bus = busidx; - pcp->dev = dev; - pcp->func = func; - pcp->next = PciStruct; - PciStruct = pcp; - } - if ((func == 0) - && ((header & PCI_MULTIFUNC_DEV) == 0)) - func = 8; - else - func++; - return func; -} - -static CARD32 remapMEM_val; -static int remapMEM_num; - -static int /* map it on some other video device */ -remapMem(PciStructPtr pciP, int num, CARD32 size) -{ - PciStructPtr pciPtr = PciStruct; - int i; - CARD32 org; - CARD32 val; - CARD32 size_n; - - org = PciRead32(num + 0x10,pciP->Slot.l); - - while (pciPtr) { - for (i = 0; i < 20; i=i+4) { - - val = PciRead32(i + 0x10,pciPtr->Slot.l); - /* don't map it on itself */ - if ((org & 0xfffffff0) == (val & 0xfffffff0)) - continue; - if (val && !(val & 1)) - PciWrite32(i + 0x10,0xffffffff,pciPtr->Slot.l); - else - continue; - size_n = PciRead32(i + 0x10,pciPtr->Slot.l); - PciWrite32(i + 0x10,val,pciPtr->Slot.l); - size_n = ~(CARD32)(size_n & 0xfffffff0) + 1; - - if (size_n >= size) { - PciWrite32(num + 0x10,val,pciP->Slot.l); - return 1; - } - } - pciPtr = pciPtr->next; - } - /* last resort: try to go below lowest PCI mem address */ - val = ((pciMinMemReg & ~(CARD32)(size - 1)) - size); - if (val > 0x7fffffff) { - PciWrite32(num + 0x10,val, pciP->Slot.l); - return 1; - } - - return 0; -} - -static void -restoreMem(PciStructPtr pciP) -{ - if (remapMEM_val == 0) return; - PciWrite32(remapMEM_num + 0x10,remapMEM_val,pciP->Slot.l); - return; -} - -static CARD32 -findBIOSMap(PciStructPtr pciP, CARD32 *biosSize) -{ - PciStructPtr pciPtr = PciStruct; - int i; - CARD32 val; - CARD32 size; - - PciWrite32(0x30,0xffffffff,pciP->Slot.l); - *biosSize = PciRead32(0x30,pciP->Slot.l); - P_printf("bios size: 0x%x\n",*biosSize); - PciWrite32(0x30,pciP->RomBase,pciP->Slot.l); - *biosSize = ~(*biosSize & 0xFFFFFF00) + 1; - P_printf("bios size masked: 0x%x\n",*biosSize); - if (*biosSize > (1024 * 1024 * 16)) { - *biosSize = 1024 * 1024 * 16; - P_printf("fixing broken BIOS size: 0x%x\n",*biosSize); - } - while (pciPtr) { - if (pciPtr->bus != pciP->bus) { - pciPtr = pciPtr->next; - continue; - } - for (i = 0; i < 20; i=i+4) { - - val = PciRead32(i + 0x10,pciPtr->Slot.l); - if (!(val & 1)) - - PciWrite32(i + 0x10,0xffffffff,pciPtr->Slot.l); - else - continue; - size = PciRead32(i + 0x10,pciPtr->Slot.l); - PciWrite32(i + 0x10,val,pciPtr->Slot.l); - size = ~(CARD32)(size & 0xFFFFFFF0) + 1; -#ifdef V86_BIOS_DEBUG - P_printf("size: 0x%x\n",size); -#endif - if (size >= *biosSize) { - if (pciP == pciPtr) { /* if same device remap ram*/ - if (!(remapMem(pciP,i,size))) - continue; - remapMEM_val = val; - remapMEM_num = i; - } else { - remapMEM_val = 0; - } - return val & 0xFFFFFF00; - } - } - pciPtr = pciPtr->next; - } - remapMEM_val = 0; - /* very last resort */ - if (pciP->bus == 0 && (pciMinMemReg > *biosSize)) - return (pciMinMemReg - size) & ~(size - 1); - - return 0; -} - -int -cfg1out(CARD16 addr, CARD32 val) -{ - if (addr == 0xCF8) { - PciCfg1Addr = val; - return 1; - } else if (addr == 0xCFC) { - writePci(PciCfg1Addr, val); - return 1; - } - return 0; -} - -int -cfg1in(CARD16 addr, CARD32 *val) -{ - if (addr == 0xCF8) { - *val = PciCfg1Addr; - return 1; - } else if (addr == 0xCFC) { - *val = readPci(PciCfg1Addr); - return 1; - } - return 0; -} - -void -list_pci(void) -{ - PciStructPtr pci = PciList; - - while (pci) { - printf("[0x%x:0x%x:0x%x] vendor: 0x%4.4x dev: 0x%4.4x class: 0x%4.4x" - " subclass: 0x%4.4x\n",pci->bus,pci->dev,pci->func, - pci->VendorID,pci->DeviceID,pci->BaseClass,pci->SubClass); - pci = pci->next; - } -} - -PciStructPtr -findPciByIDs(int bus, int dev, int func) -{ - PciStructPtr pciP = PciList; - - while (pciP) { - if (pciP->bus == bus && pciP->dev == dev && pciP->func == func) - return pciP; - pciP = pciP->next; - } - return NULL; -} diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/pci.h b/board/MAI/bios_emulator/scitech/src/v86bios/pci.h deleted file mode 100644 index 58ad52202e..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/pci.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 1999 Egbert Eich - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the authors not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The authors makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ -#include "v86bios.h" - -#ifndef V86_PCI_H -#define V86_PCI_H - -typedef union { - struct { - unsigned int zero:2; - unsigned int reg:6; - unsigned int func:3; - unsigned int dev:5; - unsigned int bus:8; - unsigned int reserved:7; - unsigned int enable:1; - } pci; - CARD32 l; -} PciSlot; - -typedef struct pciBusRec { - CARD8 primary; - CARD8 secondary; - CARD32 bctl; - PciSlot Slot; - struct pciBusRec *next; - struct pciBusRec *pBus; -} PciBusRec, *PciBusPtr; - -typedef struct pciStructRec { - CARD16 VendorID; - CARD16 DeviceID; - CARD8 Interface; - CARD8 BaseClass; - CARD8 SubClass; - CARD32 RomBase; - CARD32 bus; - CARD8 dev; - CARD8 func; - CARD32 cmd_st; - int active; - PciSlot Slot; - struct pciStructRec *next; - PciBusPtr pBus; -} PciStructRec , *PciStructPtr; - - -extern PciStructPtr CurrentPci; -extern PciStructPtr PciList; -extern PciStructPtr BootBios; -extern int pciMaxBus; - -extern CARD32 findPci(CARD16 slotBX); -extern CARD16 pciSlotBX(PciStructPtr); -PciStructPtr findPciDevice(CARD16 vendorID, CARD16 deviceID, char n); -PciStructPtr findPciClass(CARD8 intf, CARD8 subClass, CARD16 class, char n); - -extern CARD8 PciRead8(int offset, CARD32 slot); -extern CARD16 PciRead16(int offset, CARD32 slot); -extern CARD32 PciRead32(int offset, CARD32 slot); - -extern void PciWrite8(int offset,CARD8 byte, CARD32 slot); -extern void PciWrite16(int offset,CARD16 word, CARD32 slot); -extern void PciWrite32(int offset,CARD32 lg, CARD32 slot); - -extern void scan_pci(void); -extern void pciVideoDisable(void); -extern void pciVideoRestore(void); -extern void EnableCurrent(void); -extern int mapPciRom(PciStructPtr pciP); -extern int cfg1out(CARD16 addr, CARD32 val); -extern int cfg1in(CARD16 addr, CARD32 *val); -extern void list_pci(void); -extern PciStructPtr findPciByIDs(int bus, int dev, int func); - -#define PCI_MODE2_ENABLE_REG 0xCF8 -#define PCI_MODE2_FORWARD_REG 0xCFA -#define PCI_MODE1_ADDRESS_REG 0xCF8 -#define PCI_MODE1_DATA_REG 0xCFC -#if defined(__alpha__) || defined(__sparc__) -#define PCI_EN 0x00000000 -#else -#define PCI_EN 0x80000000 -#endif -#define MAX_DEV_PER_VENDOR_CFG1 32 -#define BRIDGE_CLASS(x) (x == 0x06) -#define BRIDGE_PCI_CLASS(x) (x == 0x04) -#define BRIDGE_HOST_CLASS(x) (x == 0x00) -#define PCI_CLASS_PREHISTORIC 0x00 -#define PCI_SUBCLASS_PREHISTORIC_VGA 0x01 -#define PCI_CLASS_DISPLAY 0x03 -#define PCI_SUBCLASS_DISPLAY_VGA 0x00 -#define PCI_SUBCLASS_DISPLAY_XGA 0x01 -#define PCI_SUBCLASS_DISPLAY_MISC 0x80 -#define VIDEO_CLASS(b,s) \ - (((b) == PCI_CLASS_PREHISTORIC && (s) == PCI_SUBCLASS_PREHISTORIC_VGA) || \ - ((b) == PCI_CLASS_DISPLAY && (s) == PCI_SUBCLASS_DISPLAY_VGA) ||\ - ((b) == PCI_CLASS_DISPLAY && (s) == PCI_SUBCLASS_DISPLAY_XGA) ||\ - ((b) == PCI_CLASS_DISPLAY && (s) == PCI_SUBCLASS_DISPLAY_MISC)) -#define PCI_MULTIFUNC_DEV 0x80 -#define MAX_PCI_DEVICES 64 -#define PCI_MAXBUS 16 -#define PCI_IS_MEM 0x00000001 -#define MAX_PCI_ROM_SIZE (1024 * 1024 * 16) - -#define IS_MEM32(x) ((x & 0x7) == 0 && x != 0) -#define IS_MEM64(x) ((x & 0x7) == 0x4) -#endif diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/v86.c b/board/MAI/bios_emulator/scitech/src/v86bios/v86.c deleted file mode 100644 index 4deed044cb..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/v86.c +++ /dev/null @@ -1,562 +0,0 @@ -/* - * Copyright 1999 Egbert Eich - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the authors not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The authors makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include "debug.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "v86bios.h" -#include "AsmMacros.h" - -struct vm86_struct vm86s; - -static int vm86_GP_fault(void); -static int vm86_do_int(int num); -static void dump_code(void); -static void dump_registers(void); -static void stack_trace(void); -static int vm86_rep(struct vm86_struct *ptr); - -#define CPU_REG(x) (vm86s.regs.##x) -#define CPU_REG_LW(reg) (*((CARD16 *)&CPU_REG(reg))) -#define CPU_REG_HW(reg) (*((CARD16 *)&CPU_REG(reg) + 1)) -#define CPU_REG_LB(reg) (*(CARD8 *)&CPU_REG(e##reg)) -#define SEG_ADR(type, seg, reg) type((CPU_REG_LW(seg) << 4) \ - + CPU_REG_LW(e##reg)) -#define DF (1 << 10) - -struct pio P; - - -void -setup_io(void) -{ - if (!Config.PrintPort && !Config.IoStatistics) { - P.inb = (CARD8(*)(CARD16))inb; - P.inw = (CARD16(*)(CARD16))inw; - P.inl = (CARD32(*)(CARD16))inl; - P.outb = (void(*)(CARD16,CARD8))outb; - P.outw = (void(*)(CARD16,CARD16))outw; - P.outl = (void(*)(CARD16,CARD32))outl; - } else { - P.inb = p_inb; - P.inw = p_inw; - P.inl = p_inl; - P.outb = p_outb; - P.outw = p_outw; - P.outl = p_outl; - } -} - - -static void -setup_vm86(unsigned long bios_start, i86biosRegsPtr regs) -{ - CARD32 eip; - CARD16 cs; - - vm86s.flags = VM86_SCREEN_BITMAP; - vm86s.flags = 0; - vm86s.screen_bitmap = 0; - vm86s.cpu_type = CPU_586; - memset(&vm86s.int_revectored, 0xff,sizeof(vm86s.int_revectored)) ; - memset(&vm86s.int21_revectored, 0xff,sizeof(vm86s.int21_revectored)) ; - - eip = bios_start & 0xFFFF; - cs = (bios_start & 0xFF0000) >> 4; - - CPU_REG(eax) = regs->ax; - CPU_REG(ebx) = regs->bx; - CPU_REG(ecx) = regs->cx; - CPU_REG(edx) = regs->dx; - CPU_REG(esi) = 0; - CPU_REG(edi) = regs->di; - CPU_REG(ebp) = 0; - CPU_REG(eip) = eip; - CPU_REG(cs) = cs; - CPU_REG(esp) = 0x100; - CPU_REG(ss) = 0x30; /* This is the standard pc bios stack */ - CPU_REG(es) = regs->es; - CPU_REG(ds) = 0x40; /* standard pc ds */ - CPU_REG(fs) = 0; - CPU_REG(gs) = 0; - CPU_REG(eflags) |= (VIF_MASK | VIP_MASK); -} - -void -collect_bios_regs(i86biosRegsPtr regs) -{ - regs->ax = CPU_REG(eax); - regs->bx = CPU_REG(ebx); - regs->cx = CPU_REG(ecx); - regs->dx = CPU_REG(edx); - regs->es = CPU_REG(es); - regs->ds = CPU_REG(ds); - regs->di = CPU_REG(edi); - regs->si = CPU_REG(esi); -} - -static int -do_vm86(void) -{ - int retval; - -#ifdef V86BIOS_DEBUG - dump_registers(); -#endif -/* retval = SYS_vm86old(&vm86s); */ -/* retval = syscall(SYS_vm86old,&vm86s); */ - - retval = vm86_rep(&vm86s); - - switch (VM86_TYPE(retval)) { - case VM86_UNKNOWN: - if (!vm86_GP_fault()) return 0; - break; - case VM86_STI: - fprintf(stderr,"vm86_sti :-((\n"); - stack_trace(); - dump_code(); - return 0; - case VM86_INTx: - if (!vm86_do_int(VM86_ARG(retval))) { - fprintf(stderr,"\nUnknown vm86_int: %X\n\n",VM86_ARG(retval)); - dump_registers(); - return 0; - } - /* I'm not sure yet what to do if we can handle ints */ - break; - case VM86_SIGNAL: - fprintf(stderr,"received signal\n"); - return 0; - default: - fprintf(stderr,"unknown type(0x%x)=0x%x\n", - VM86_ARG(retval),VM86_TYPE(retval)); - dump_registers(); - dump_code(); - stack_trace(); - return 0; - } - - return 1; -} - -static jmp_buf x86_esc; -static void -vmexit(int unused) -{ - longjmp(x86_esc,1); -} - -void -do_x86(unsigned long bios_start, i86biosRegsPtr regs) -{ - static void (*org_handler)(int); - - setup_vm86(bios_start, regs); - if (setjmp(x86_esc) == 0) { - org_handler = signal(2,vmexit); - while(do_vm86()) {}; - signal(2,org_handler); - collect_bios_regs(regs); - } else { - signal(2,org_handler); - printf("interrupted at 0x%x\n",((CARD16)CPU_REG(cs)) << 4 - | (CARD16)CPU_REG(eip)); - } -} - -/* get the linear address */ -#define LIN_PREF_SI ((pref_seg << 4) + CPU_REG_LW(esi)) - -#define LWECX (prefix66 ^ prefix67 ? CPU_REG(ecx) : CPU_REG_LW(ecx)) - -static int -vm86_GP_fault(void) -{ - unsigned char *csp, *lina; - CARD32 org_eip; - int pref_seg; - int done,is_rep,prefix66,prefix67; - - - csp = lina = SEG_ADR((unsigned char *), cs, ip); -#ifdef V86BIOS_DEBUG - printf("exception: \n"); - dump_code(); -#endif - - is_rep = 0; - prefix66 = prefix67 = 0; - pref_seg = -1; - - /* eat up prefixes */ - done = 0; - do { - switch (*(csp++)) { - case 0x66: /* operand prefix */ prefix66=1; break; - case 0x67: /* address prefix */ prefix67=1; break; - case 0x2e: /* CS */ pref_seg=CPU_REG(cs); break; - case 0x3e: /* DS */ pref_seg=CPU_REG(ds); break; - case 0x26: /* ES */ pref_seg=CPU_REG(es); break; - case 0x36: /* SS */ pref_seg=CPU_REG(ss); break; - case 0x65: /* GS */ pref_seg=CPU_REG(gs); break; - case 0x64: /* FS */ pref_seg=CPU_REG(fs); break; - case 0xf2: /* repnz */ - case 0xf3: /* rep */ is_rep=1; break; - default: done=1; - } - } while (!done); - csp--; /* oops one too many */ - org_eip = CPU_REG(eip); - CPU_REG_LW(eip) += (csp - lina); - - switch (*csp) { - - case 0x6c: /* insb */ - /* NOTE: ES can't be overwritten; prefixes 66,67 should use esi,edi,ecx - * but is anyone using extended regs in real mode? */ - /* WARNING: no test for DI wrapping! */ - CPU_REG_LW(edi) += port_rep_inb(CPU_REG_LW(edx), - SEG_ADR((CARD8 *),es,di), - CPU_REG_LW(eflags)&DF, - (is_rep? LWECX:1)); - if (is_rep) LWECX = 0; - CPU_REG_LW(eip)++; - break; - - case 0x6d: /* (rep) insw / insd */ - /* NOTE: ES can't be overwritten */ - /* WARNING: no test for _DI wrapping! */ - if (prefix66) { - CPU_REG_LW(edi) += port_rep_inl(CPU_REG_LW(edx), - SEG_ADR((CARD32 *),es,di), - CPU_REG_LW(eflags)&DF, - (is_rep? LWECX:1)); - } - else { - CPU_REG_LW(edi) += port_rep_inw(CPU_REG_LW(edx), - SEG_ADR((CARD16 *),es,di), - CPU_REG_LW(eflags)&DF, - (is_rep? LWECX:1)); - } - if (is_rep) LWECX = 0; - CPU_REG_LW(eip)++; - break; - - case 0x6e: /* (rep) outsb */ - if (pref_seg < 0) pref_seg = CPU_REG_LW(ds); - /* WARNING: no test for _SI wrapping! */ - CPU_REG_LW(esi) += port_rep_outb(CPU_REG_LW(edx),(CARD8*)LIN_PREF_SI, - CPU_REG_LW(eflags)&DF, - (is_rep? LWECX:1)); - if (is_rep) LWECX = 0; - CPU_REG_LW(eip)++; - break; - - case 0x6f: /* (rep) outsw / outsd */ - if (pref_seg < 0) pref_seg = CPU_REG_LW(ds); - /* WARNING: no test for _SI wrapping! */ - if (prefix66) { - CPU_REG_LW(esi) += port_rep_outl(CPU_REG_LW(edx), - (CARD32 *)LIN_PREF_SI, - CPU_REG_LW(eflags)&DF, - (is_rep? LWECX:1)); - } - else { - CPU_REG_LW(esi) += port_rep_outw(CPU_REG_LW(edx), - (CARD16 *)LIN_PREF_SI, - CPU_REG_LW(eflags)&DF, - (is_rep? LWECX:1)); - } - if (is_rep) LWECX = 0; - CPU_REG_LW(eip)++; - break; - - case 0xe5: /* inw xx, inl xx */ - if (prefix66) CPU_REG(eax) = P.inl((int) csp[1]); - else CPU_REG_LW(eax) = P.inw((int) csp[1]); - CPU_REG_LW(eip) += 2; - break; - case 0xe4: /* inb xx */ - CPU_REG_LW(eax) &= ~(CARD32)0xff; - CPU_REG_LB(ax) |= P.inb((int) csp[1]); - CPU_REG_LW(eip) += 2; - break; - case 0xed: /* inw dx, inl dx */ - if (prefix66) CPU_REG(eax) = P.inl(CPU_REG_LW(edx)); - else CPU_REG_LW(eax) = P.inw(CPU_REG_LW(edx)); - CPU_REG_LW(eip) += 1; - break; - case 0xec: /* inb dx */ - CPU_REG_LW(eax) &= ~(CARD32)0xff; - CPU_REG_LB(ax) |= P.inb(CPU_REG_LW(edx)); - CPU_REG_LW(eip) += 1; - break; - - case 0xe7: /* outw xx */ - if (prefix66) P.outl((int)csp[1], CPU_REG(eax)); - else P.outw((int)csp[1], CPU_REG_LW(eax)); - CPU_REG_LW(eip) += 2; - break; - case 0xe6: /* outb xx */ - P.outb((int) csp[1], CPU_REG_LB(ax)); - CPU_REG_LW(eip) += 2; - break; - case 0xef: /* outw dx */ - if (prefix66) P.outl(CPU_REG_LW(edx), CPU_REG(eax)); - else P.outw(CPU_REG_LW(edx), CPU_REG_LW(eax)); - CPU_REG_LW(eip) += 1; - break; - case 0xee: /* outb dx */ - P.outb(CPU_REG_LW(edx), CPU_REG_LB(ax)); - CPU_REG_LW(eip) += 1; - break; - - case 0xf4: -#ifdef V86BIOS_DEBUG - printf("hlt at %p\n", lina); -#endif - return 0; - - case 0x0f: - fprintf(stderr,"CPU 0x0f Trap at eip=0x%lx\n",CPU_REG(eip)); - goto op0ferr; - break; - - case 0xf0: /* lock */ - default: - fprintf(stderr,"unknown reason for exception\n"); - dump_registers(); - stack_trace(); - op0ferr: - dump_code(); - fprintf(stderr,"cannot continue\n"); - return 0; - } /* end of switch() */ - return 1; -} - -static int -vm86_do_int(int num) -{ - int val; - struct regs86 regs; - - i_printf("int 0x%x received: ax:0x%lx",num,CPU_REG(eax)); - if (Config.PrintIp) - i_printf(" at: 0x%x\n",getIP()); - else - i_printf("\n"); - - /* try to run bios interrupt */ - - /* if not installed fall back */ -#define COPY(x) regs.##x = CPU_REG(x) -#define COPY_R(x) CPU_REG(x) = regs.##x - - COPY(eax); - COPY(ebx); - COPY(ecx); - COPY(edx); - COPY(esi); - COPY(edi); - COPY(ebp); - COPY(eip); - COPY(esp); - COPY(cs); - COPY(ss); - COPY(ds); - COPY(es); - COPY(fs); - COPY(gs); - COPY(eflags); - - if (!(val = int_handler(num,®s))) - if (!(val = run_bios_int(num,®s))) - return val; - - COPY_R(eax); - COPY_R(ebx); - COPY_R(ecx); - COPY_R(edx); - COPY_R(esi); - COPY_R(edi); - COPY_R(ebp); - COPY_R(eip); - COPY_R(esp); - COPY_R(cs); - COPY_R(ss); - COPY_R(ds); - COPY_R(es); - COPY_R(fs); - COPY_R(gs); - COPY_R(eflags); - - return val; -#undef COPY -#undef COPY_R -} - -static void -dump_code(void) -{ - int i; - unsigned char *lina = SEG_ADR((unsigned char *), cs, ip); - - fprintf(stderr,"code at 0x%8.8x: ",(CARD32)lina); - for (i=0; i<0x10; i++) - fprintf(stderr,"%2.2x ",*(lina + i)); - fprintf(stderr,"\n "); - for (; i<0x20; i++) - fprintf(stderr,"%2.2x ",*(lina + i)); - fprintf(stderr,"\n"); -} - -#define PRINT(x) fprintf(stderr,#x":%4.4x ",CPU_REG_LW(x)) -#define PRINT_FLAGS(x) fprintf(stderr,#x":%8.8x ",CPU_REG_LW(x)) -static void -dump_registers(void) -{ - PRINT(eip); - PRINT(eax); - PRINT(ebx); - PRINT(ecx); - PRINT(edx); - PRINT(esi); - PRINT(edi); - PRINT(ebp); - fprintf(stderr,"\n"); - PRINT(esp); - PRINT(cs); - PRINT(ss); - PRINT(es); - PRINT(ds); - PRINT(fs); - PRINT(gs); - PRINT_FLAGS(eflags); - fprintf(stderr,"\n"); -} - -static void -stack_trace(void) -{ - int i; - unsigned char *stack = SEG_ADR((unsigned char *), ss, sp); - - fprintf(stderr,"stack at 0x%8.8lx:\n",(unsigned long)stack); - for (i=0; i < 0x10; i++) - fprintf(stderr,"%2.2x ",*(stack + i)); - fprintf(stderr,"\n"); - -} - -static int -vm86_rep(struct vm86_struct *ptr) -{ - - int __res; - - __asm__ __volatile__("int $0x80\n" - :"=a" (__res):"a" ((int)113), - "b" ((struct vm86_struct *)ptr)); - - if ((__res) < 0) { - errno = -__res; - __res=-1; - } - else errno = 0; - return __res; -} - -#define pushw(base, ptr, val) \ -__asm__ __volatile__( \ - "decw %w0\n\t" \ - "movb %h2,(%1,%0)\n\t" \ - "decw %w0\n\t" \ - "movb %b2,(%1,%0)" \ - : "=r" (ptr) \ - : "r" (base), "q" (val), "0" (ptr)) - -int -run_bios_int(int num, struct regs86 *regs) -{ - CARD16 *ssp; - CARD32 sp; - CARD32 eflags; - -#ifdef V86BIOS_DEBUG - static int firsttime = 1; -#endif - /* check if bios vector is initialized */ - if (((CARD16*)0)[(num<<1)+1] == 0x0000) { /* SYS_BIOS_SEG ?*/ -#ifdef V86BIOS_DEBUG - i_printf("card BIOS not loaded\n"); -#endif - return 0; - } - -#ifdef V86BIOS_DEBUG - if (firsttime) { - dprint(0,0x3D0); - firsttime = 0; - } -#endif - - i_printf("calling card BIOS at: "); - ssp = (CARD16*)(CPU_REG(ss)<<4); - sp = (CARD32) CPU_REG_LW(esp); - - eflags = regs->eflags; - eflags = ((eflags & VIF_MASK) != 0) - ? (eflags | IF_MASK) : (eflags & ~(CARD32) IF_MASK); - pushw(ssp, sp, eflags); - pushw(ssp, sp, regs->cs); - pushw(ssp, sp, (CARD16)regs->eip); - regs->esp -= 6; - regs->cs = ((CARD16 *) 0)[(num << 1) + 1]; - regs->eip = (regs->eip & 0xFFFF0000) | ((CARD16 *) 0)[num << 1]; - i_printf("0x%x:%lx\n",regs->cs,regs->eip); -#ifdef V86BIOS_DEBUG - dump_code(); -#endif - regs->eflags = regs->eflags - & ~(VIF_MASK | TF_MASK | IF_MASK | NT_MASK); - return 1; -} - -CARD32 -getIntVect(int num) -{ - return ((CARD32*)0)[num]; -} - -CARD32 -getIP(void) -{ - return (CPU_REG(cs) << 4) + CPU_REG(eip); -} diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.c b/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.c deleted file mode 100644 index 101c1f26e6..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.c +++ /dev/null @@ -1,933 +0,0 @@ -/* - * Copyright 1999 Egbert Eich - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the authors not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The authors makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ -#define DELETE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if defined(__alpha__) || defined (__ia64__) -#include -#elif defined(HAVE_SYS_PERM) -#include -#endif -#include "debug.h" -#include "v86bios.h" -#include "pci.h" -#include "AsmMacros.h" - -#define SIZE 0x100000 -#define VRAM_START 0xA0000 -#define VRAM_SIZE 0x1FFFF -#define V_BIOS_SIZE 0x1FFFF -#define BIOS_START 0x7C00 /* default BIOS entry */ -#define BIOS_MEM 0x600 - -/*CARD8 code[] = { 0xb8 , 0xf0 , 0xf0, 0xf4 }; */ -#define VB_X(x) (V_BIOS >> x) & 0xFF -CARD8 code[] = { 6, 0x9a, 0x03, 0x00, 0x00, VB_X(12), 0xf4 }; -/*CARD8 code[] = { 0x9a, 0x03, 0x00, 0x00, VB_X(12), 0xb8, 0x03, 0x00, */ -/*0xcd, 0x10, 0xf4 }; */ -/*CARD8 code[] = { 0xb8 , 0xf0 , 0xf0 ,0xf4 }; */ - -int ioperm_list[IOPERM_BITS] = {0,}; - -static void sig_handler(int); -static int map(void); -static void unmap(void); -static void bootBIOS(CARD16 ax); -static int map_vram(void); -static void unmap_vram(void); -static int copy_vbios(memType v_base); -static int copy_sys_bios(void); -static void save_bios_to_file(void); -static int setup_system_bios(void); -static CARD32 setup_int_vect(void); -#ifdef __ia32__ -static CARD32 setup_primary_int_vect(void); -#endif -static int chksum(CARD8 *start); -static void setup_bios_regs(i86biosRegsPtr regs, CARD32 ax); -static void print_regs(i86biosRegsPtr regs); -static void print_usage(void); -static void set_hlt(Bool set); -static void set_ioperm(void); - -extern void yyparse(); - -void loadCodeToMem(unsigned char *ptr, CARD8 *code); -void dprint(unsigned long start, unsigned long size); - -static int vram_mapped = 0; -static char* bios_var = NULL; -static CARD8 save_msr; -static CARD8 save_pos102; -static CARD8 save_vse; -static CARD8 save_46e8; -static haltpoints hltp[20] = { {0, 0}, }; - -console Console = {-1,-1}; -struct config Config; - -int main(int argc,char **argv) -{ - int c; - - Config.PrintPort = PRINT_PORT; - Config.IoStatistics = IO_STATISTICS; - Config.PrintIrq = PRINT_IRQ; - Config.PrintPci = PRINT_PCI; - Config.ShowAllDev = SHOW_ALL_DEV; - Config.PrintIp = PRINT_IP; - Config.SaveBios = SAVE_BIOS; - Config.Trace = TRACE; - Config.ConfigActiveOnly = CONFIG_ACTIVE_ONLY; /* boot */ - Config.ConfigActiveDevice = CONFIG_ACTIVE_DEVICE; /* boot */ - Config.MapSysBios = MAP_SYS_BIOS; - Config.Resort = RESORT; /* boot */ - Config.FixRom = FIX_ROM; - Config.NoConsole = NO_CONSOLE; - Config.BootOnly = FALSE; - Config.Verbose = VERBOSE; - - opterr = 0; - while ((c = getopt(argc,argv,"psicaPStAdbrfnv:?")) != EOF) { - switch(c) { - case 'p': - Config.PrintPort = TRUE; - break; - case 's': - Config.IoStatistics = TRUE; - break; - case 'i': - Config.PrintIrq = TRUE; - break; - case 'c': - Config.PrintPci = TRUE; - break; - case 'a': - Config.ShowAllDev = TRUE; - break; - case 'P': - Config.PrintIp = TRUE; - break; - case 'S': - Config.SaveBios = TRUE; - break; - case 't': - Config.Trace = TRUE; - break; - case 'A': - Config.ConfigActiveOnly = TRUE; - break; - case 'd': - Config.ConfigActiveDevice = TRUE; - break; - case 'b': - Config.MapSysBios = TRUE; - break; - case 'r': - Config.Resort = TRUE; - break; - case 'f': - Config.FixRom = TRUE; - break; - case 'n': - Config.NoConsole = TRUE; - break; - case 'v': - Config.Verbose = strtol(optarg,NULL,0); - break; - case '?': - print_usage(); - break; - default: - break; - } - } - - - if (!map()) - exit(1); - - if (!setup_system_bios()) - exit(1); - - iopl(3); - - scan_pci(); - - save_msr = inb(0x3CC); - save_vse = inb(0x3C3); - save_46e8 = inb(0x46e8); - save_pos102 = inb(0x102); - - if (Config.BootOnly) { - - if (!CurrentPci && !Config.ConfigActiveDevice - && !Config.ConfigActiveOnly) { - iopl(0); - unmap(); - exit (1); - } - call_boot(NULL); - } else { - using_history(); - yyparse(); - } - - unmap(); - - pciVideoRestore(); - - outb(0x102, save_pos102); - outb(0x46e8, save_46e8); - outb(0x3C3, save_vse); - outb(0x3C2, save_msr); - - iopl(0); - - close_console(Console); - - exit(0); -} - - -void -call_boot(struct device *dev) -{ - int Active_is_Pci = 0; - CARD32 vbios_base; - - CurrentPci = PciList; - Console = open_console(); - - set_ioperm(); - - - signal(2,sig_handler); - signal(11,sig_handler); - - /* disable primary card */ - pciVideoRestore(); /* reset PCI state to see primary card */ - outb(0x3C2,~(CARD8)0x03 & save_msr); - outb(0x3C3,~(CARD8)0x01 & save_vse); - outb(0x46e8, ~(CARD8)0x08 & save_46e8); - outb(0x102, ~(CARD8)0x01 & save_pos102); - - pciVideoDisable(); - - while (CurrentPci) { - CARD16 ax; - - if (CurrentPci->active) { - Active_is_Pci = 1; - if (!Config.ConfigActiveDevice && !dev) { - CurrentPci = CurrentPci->next; - continue; - } - } else if (Config.ConfigActiveOnly && !dev) { - CurrentPci = CurrentPci->next; - continue; - } - if (dev && ((dev->type != PCI) - || (dev->type == PCI - && (dev->loc.pci.dev != CurrentPci->dev - || dev->loc.pci.bus != CurrentPci->bus - || dev->loc.pci.func != CurrentPci->func)))) { - CurrentPci = CurrentPci->next; - continue; - } - - EnableCurrent(); - - if (CurrentPci->active) { - outb(0x102, save_pos102); - outb(0x46e8, save_46e8); - outb(0x3C3, save_vse); - outb(0x3C2, save_msr); - } - - /* clear interrupt vectors */ -#ifdef __ia32__ - vbios_base = CurrentPci->active ? setup_primary_int_vect() - : setup_int_vect(); -#else - vbios_base = setup_int_vect(); -#endif - ax = ((CARD16)(CurrentPci->bus) << 8) - | (CurrentPci->dev << 3) | (CurrentPci->func & 0x7); - if (Config.Verbose > 1) P_printf("ax: 0x%x\n",ax); - - BootBios = findPciByIDs(CurrentPci->bus,CurrentPci->dev, - CurrentPci->func); - if (!((mapPciRom(BootBios) && chksum((CARD8*)V_BIOS)) - || (CurrentPci->active && copy_vbios(vbios_base)))) { - CurrentPci = CurrentPci->next; - continue; - } - if (!map_vram()) { - CurrentPci = CurrentPci->next; - continue; - } - if (Config.SaveBios) save_bios_to_file(); - printf("initializing PCI bus: %i dev: %i func: %i\n",CurrentPci->bus, - CurrentPci->dev,CurrentPci->func); - bootBIOS(ax); - unmap_vram(); - - if (CurrentPci->active) - close_console(Console); - - if (dev) return; - - CurrentPci = CurrentPci->next; - } - - /* We have an ISA device - configure if requested */ - if (!Active_is_Pci /* no isa card in system! */ - && ((!dev && (Config.ConfigActiveDevice || Config.ConfigActiveOnly)) - || (dev && dev->type == ISA))) { - - pciVideoDisable(); - - if (!dev || dev->type == ISA) { - outb(0x102, save_pos102); - outb(0x46e8, save_46e8); - outb(0x3C3, save_vse); - outb(0x3C2, save_msr); - -#ifdef __ia32__ - vbios_base = setup_primary_int_vect(); -#else - vbios_base = setup_int_vect(); -#endif - if (copy_vbios(vbios_base)) { - - if (Config.SaveBios) save_bios_to_file(); - if (map_vram()) { - printf("initializing ISA bus\n"); - bootBIOS(0); - } - } - - unmap_vram(); - sleep(1); - close_console(Console); - } - } - - -} - -int -map(void) -{ - void* mem; - mem = mmap(0, (size_t)SIZE, - PROT_EXEC | PROT_READ | PROT_WRITE, - MAP_FIXED | MAP_PRIVATE | MAP_ANON, - -1, 0 ); - if (mem != 0) { - perror("anonymous map"); - return (0); - } - memset(mem,0,SIZE); - - return (1); -} - -static void -unmap(void) -{ - munmap(0,SIZE); -} - -static void -bootBIOS(CARD16 ax) -{ - i86biosRegs bRegs; -#ifdef V86BIOS_DEBUG - printf("starting BIOS\n"); -#endif - setup_io(); - setup_bios_regs(&bRegs, ax); - loadCodeToMem((unsigned char *) BIOS_START, code); - do_x86(BIOS_START,&bRegs); -#ifdef V86BIOS_DEBUG - printf("done\n"); -#endif -} - -static int -map_vram(void) -{ - int mem_fd; - -#ifdef __ia64__ - if ((mem_fd = open(MEM_FILE,O_RDWR | O_SYNC))<0) -#else - if ((mem_fd = open(MEM_FILE,O_RDWR))<0) -#endif - { - perror("opening memory"); - return 0; - } - -#ifdef __alpha__ - if (!_bus_base()) sparse_shift = 7; /* Uh, oh, JENSEN... */ - if (!_bus_base_sparse()) sparse_shift = 0; - if ((vram_map = mmap(0,(size_t) (VRAM_SIZE << sparse_shift), - PROT_READ | PROT_WRITE, - MAP_SHARED, - mem_fd, (VRAM_START << sparse_shift) - | _bus_base_sparse())) == (void *) -1) -#else - if (mmap((void *) VRAM_START, (size_t) VRAM_SIZE, - PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, - mem_fd, VRAM_START) == (void *) -1) -#endif - { - perror("mmap error in map_hardware_ram (1)"); - close(mem_fd); - return (0); - } - vram_mapped = 1; - close(mem_fd); - return (1); -} - -static void -unmap_vram(void) -{ - if (!vram_mapped) return; - - munmap((void*)VRAM_START,VRAM_SIZE); - vram_mapped = 0; -} - -static int -copy_vbios(memType v_base) -{ - int mem_fd; - unsigned char *tmp; - int size; - - if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { - perror("opening memory"); - return (0); - } - - if (lseek(mem_fd,(off_t) v_base, SEEK_SET) != (off_t) v_base) { - fprintf(stderr,"Cannot lseek\n"); - goto Error; - } - tmp = (unsigned char *)malloc(3); - if (read(mem_fd, (char *)tmp, (size_t) 3) != (size_t) 3) { - fprintf(stderr,"Cannot read\n"); - goto Error; - } - if (lseek(mem_fd,(off_t) v_base,SEEK_SET) != (off_t) v_base) - goto Error; - - if (*tmp != 0x55 || *(tmp+1) != 0xAA ) { - fprintf(stderr,"No bios found at: 0x%lx\n",v_base); - goto Error; - } -#ifdef DEBUG - dprint((unsigned long)tmp,0x100); -#endif - size = *(tmp+2) * 512; - - if (read(mem_fd, (char *)v_base, (size_t) size) != (size_t) size) { - fprintf(stderr,"Cannot read\n"); - goto Error; - } - free(tmp); - close(mem_fd); - if (!chksum((CARD8*)v_base)) - return (0); - - return (1); - -Error: - perror("v_bios"); - close(mem_fd); - return (0); -} - -static int -copy_sys_bios(void) -{ -#define SYS_BIOS 0xF0000 - int mem_fd; - - if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { - perror("opening memory"); - return (0); - } - - if (lseek(mem_fd,(off_t) SYS_BIOS,SEEK_SET) != (off_t) SYS_BIOS) - goto Error; - if (read(mem_fd, (char *)SYS_BIOS, (size_t) 0xFFFF) != (size_t) 0xFFFF) - goto Error; - - close(mem_fd); - return (1); - -Error: - perror("sys_bios"); - close(mem_fd); - return (0); -} - -void -loadCodeToMem(unsigned char *ptr, CARD8 code[]) -{ - int i; - CARD8 val; - int size = code[0]; - - for ( i=1;i<=size;i++) { - val = code[i]; - *ptr++ = val; - } - return; -} - -void -dprint(unsigned long start, unsigned long size) -{ - int i,j; - char *c = (char *)start; - - for (j = 0; j < (size >> 4); j++) { - char *d = c; - printf("\n0x%lx: ",(unsigned long)c); - for (i = 0; i<16; i++) - printf("%2.2x ",(unsigned char) (*(c++))); - c = d; - for (i = 0; i<16; i++) { - printf("%c",((((CARD8)(*c)) > 32) && (((CARD8)(*c)) < 128)) ? - (unsigned char) (*(c)): '.'); - c++; - } - } - printf("\n"); -} - -static void -save_bios_to_file(void) -{ - static int num = 0; - int size, count; - char file_name[256]; - int fd; - - sprintf(file_name,"bios_%i.fil",num); - if ((fd = open(file_name,O_WRONLY | O_CREAT | O_TRUNC,00644)) == -1) - return; - size = (*(unsigned char*)(V_BIOS + 2)) * 512; -#ifdef V86BIOS_DEBUG - dprint(V_BIOS,20); -#endif - if ((count = write(fd,(void *)(V_BIOS),size)) != size) - fprintf(stderr,"only saved %i of %i bytes\n",size,count); - num++; -} - -static void -sig_handler(int unused) -{ - fflush(stdout); - fflush(stderr); - - /* put system back in a save state */ - unmap_vram(); - pciVideoRestore(); - outb(0x102, save_pos102); - outb(0x46e8, save_46e8); - outb(0x3C3, save_vse); - outb(0x3C2, save_msr); - - close_console(Console); - iopl(0); - unmap(); - - exit(1); -} - -/* - * For initialization we just pass ax to the BIOS. - * PCI BIOSes need this. All other register are set 0. - */ -static void setup_bios_regs(i86biosRegsPtr regs, CARD32 ax) -{ - regs->ax = ax; - regs->bx = 0; - regs->cx = 0; - regs->dx = 0; - regs->es = 0; - regs->ds = 0x40; /* standard pc ds */ - regs->si = 0; - regs->di = 0; -} - -/* - * here we are really paranoid about faking a "real" - * BIOS. Most of this information was pulled from - * dosem. - */ - -#ifdef __ia32__ -static CARD32 -setup_primary_int_vect(void) -{ - int mem_fd; - CARD32 vbase; - void *map; - - if ((mem_fd = open(MEM_FILE,O_RDWR))<0) - { - perror("opening memory"); - return (0); - } - - if ((map = mmap((void *) 0, (size_t) 0x2000, - PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED, - mem_fd, 0)) == (void *)-1) { - perror("mmap error in map_hardware_ram (2)"); - close(mem_fd); - return (0); - } - - close(mem_fd); - memcpy(0,map,BIOS_MEM); - munmap(map,0x2000); - /* - * create a backup copy of the bios variables to write back the - * modified values - */ - if (!bios_var) - bios_var = (char *)malloc(BIOS_MEM); - memcpy(bios_var,0,BIOS_MEM); - - vbase = (*((CARD16*)(0x10 << 2) + 1)) << 4; - if (Config.Verbose > 0) printf("vbase: 0x%x\n",vbase); - return vbase; -} -#endif - -static CARD32 -setup_int_vect(void) -{ - const CARD16 cs = 0x0; - const CARD16 ip = 0x0; - int i; - - /* let the int vects point to the SYS_BIOS seg */ - for (i=0; i<0x80; i++) { - ((CARD16*)0)[i<<1] = ip; - ((CARD16*)0)[(i<<1)+1] = cs; - } - /* video interrupts default location */ - ((CARD16*)0)[(0x42<<1)+1] = 0xf000; - ((CARD16*)0)[0x42<<1] = 0xf065; - ((CARD16*)0)[(0x10<<1)+1] = 0xf000; - ((CARD16*)0)[0x10<<1] = 0xf065; - /* video param table default location (int 1d) */ - ((CARD16*)0)[(0x1d<<1)+1] = 0xf000; - ((CARD16*)0)[0x1d<<1] = 0xf0A4; - /* font tables default location (int 1F) */ - ((CARD16*)0)[(0x1f<<1)+1] = 0xf000; - ((CARD16*)0)[0x1f<<1] = 0xfa6e; - - /* int 11 default location */ - ((CARD16*)0)[(0x11<<1)+1] = 0xf000; - ((CARD16*)0)[0x11<<1] = 0xf84d; - /* int 12 default location */ - ((CARD16*)0)[(0x12<<1)+1] = 0xf000; - ((CARD16*)0)[0x12<<1] = 0xf841; - /* int 15 default location */ - ((CARD16*)0)[(0x15<<1)+1] = 0xf000; - ((CARD16*)0)[0x15<<1] = 0xf859; - /* int 1A default location */ - ((CARD16*)0)[(0x1a<<1)+1] = 0xf000; - ((CARD16*)0)[0x1a<<1] = 0xff6e; - /* int 05 default location */ - ((CARD16*)0)[(0x05<<1)+1] = 0xf000; - ((CARD16*)0)[0x05<<1] = 0xff54; - /* int 08 default location */ - ((CARD16*)0)[(0x8<<1)+1] = 0xf000; - ((CARD16*)0)[0x8<<1] = 0xfea5; - /* int 13 default location (fdd) */ - ((CARD16*)0)[(0x13<<1)+1] = 0xf000; - ((CARD16*)0)[0x13<<1] = 0xec59; - /* int 0E default location */ - ((CARD16*)0)[(0xe<<1)+1] = 0xf000; - ((CARD16*)0)[0xe<<1] = 0xef57; - /* int 17 default location */ - ((CARD16*)0)[(0x17<<1)+1] = 0xf000; - ((CARD16*)0)[0x17<<1] = 0xefd2; - /* fdd table default location (int 1e) */ - ((CARD16*)0)[(0x1e<<1)+1] = 0xf000; - ((CARD16*)0)[0x1e<<1] = 0xefc7; - return V_BIOS; -} - -static int -setup_system_bios(void) -{ - char *date = "06/01/99"; - char *eisa_ident = "PCI/ISA"; - - if (Config.MapSysBios) { - - if (!copy_sys_bios()) return 0; - return 1; - - } else { - -/* memset((void *)0xF0000,0xf4,0xfff7); */ - - /* - * we trap the "industry standard entry points" to the BIOS - * and all other locations by filling them with "hlt" - * TODO: implement hlt-handler for these - */ - memset((void *)0xF0000,0xf4,0x10000); - - /* - * TODO: we should copy the fdd table (0xfec59-0xfec5b) - * the video parameter table (0xf0ac-0xf0fb) - * and the font tables (0xfa6e-0xfe6d) - * from the original bios here - */ - - /* set bios date */ - strcpy((char *)0xFFFF5,date); - /* set up eisa ident string */ - strcpy((char *)0xFFFD9,eisa_ident); - /* write system model id for IBM-AT */ - ((char *)0)[0xFFFFE] = 0xfc; - - return 1; - } - -} - -static void -update_bios_vars(void) -{ - int mem_fd; - void *map; - memType i; - -#ifdef __ia64__ - if ((mem_fd = open(MEM_FILE,O_RDWR | O_SYNC))<0) -#else - if ((mem_fd = open(MEM_FILE,O_RDWR))<0) -#endif - { - perror("opening memory"); - return; - } - - if ((map = mmap((void *) 0, (size_t) 0x2000, - PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED, - mem_fd, 0)) == (void *)-1) { - perror("mmap error in map_hardware_ram (3)"); - close(mem_fd); - return; - } - - for (i = 0; i < BIOS_MEM; i++) { - if (bios_var[i] != *(CARD8*)i) - *((CARD8*)map + i) = *(CARD8*)i; - } - - munmap(map,0x2000); - close(mem_fd); -} - -static int -chksum(CARD8 *start) -{ - CARD16 size; - CARD8 val = 0; - int i; - - size = *(start+2) * 512; - for (i = 0; iactive)) || !isVideo) { - CARD32 vbios_base; - -#ifdef __ia32__ - if (!(vbios_base = setup_primary_int_vect())) -#else - if (!(vbios_base = setup_int_vect())) -#endif - return; - if (!copy_vbios(vbios_base)) - return; - } - - if (!map_vram()) - return; - -#ifdef V86BIOS_DEBUG - printf("starting BIOS\n"); -#endif - loadCodeToMem((unsigned char *) BIOS_START, code_int); - setup_io(); - print_regs(Regs); - set_ioperm(); - set_hlt(TRUE); - do_x86(BIOS_START,Regs); - set_hlt(FALSE); - print_regs(Regs); - -#ifdef V86BIOS_DEBUG - printf("done\n"); -#endif - - if ((isVideo && (!CurrentPci || CurrentPci->active)) || !isVideo) - update_bios_vars(); -} - -static void -print_regs(i86biosRegsPtr regs) -{ - printf("ax=%x bx=%x cx=%x dx=%x ds=%x es=%x di=%x si=%x\n", - (CARD16)regs->ax,(CARD16)regs->bx,(CARD16)regs->cx,(CARD16)regs->dx, - (CARD16)regs->ds,(CARD16)regs->es,(CARD16)regs->di, - (CARD16)regs->si); -} - -static void -print_usage(void) -{ -} - -void -add_hlt(unsigned long val) -{ - int i; - - if (val < BIOS_MEM || (val > VRAM_START && val < (VRAM_START + VRAM_SIZE)) - || val >= SIZE) { - printf("address out of range\n"); - return; - } - - for (i=0; i<20; i++) { - if (hltp[i].address == 0) { - hltp[i].address = (void*)val; - break; - } - } - if (i == 20) printf("no more hltpoints available\n"); -} - -void -del_hlt(int val) -{ - if (val == 21) { /* delete all */ - int i; - printf("clearing all hltpoints\n"); - for (i=0; i <20; i++) - hltp[i].address = NULL; - } else if (val >= 0 && val <20) - hltp[val].address = NULL; - else printf("hltpoint %i out of range: valid range 0-19\n",val); -} - -void -list_hlt() -{ - int i; - for (i=0; i<20; i++) - if (hltp[i].address) - printf("hltpoint[%i]: 0x%lx\n",i,(unsigned long)hltp[i].address); -} - -static void -set_hlt(Bool set) -{ - int i; - for (i=0; i<20; i++) - if (hltp[i].address) { - if (set) { - hltp[i].orgval = *(CARD8*)hltp[i].address; - *(CARD8*)hltp[i].address = 0xf4; - } else - *(CARD8*)hltp[i].address = hltp[i].orgval; - } -} - -static void -set_ioperm(void) -{ - int i, start; - - ioperm(0,IOPERM_BITS,0); - - for (i = 0; i < IOPERM_BITS;i++) - if (ioperm_list[i]) { - start = i; - for (;i < IOPERM_BITS; i++) { - if (!ioperm_list[i]) { - ioperm(start,i - start, 1); - break; - } - } - } -} diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.h b/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.h deleted file mode 100644 index a8f3f8e649..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright 1999 Egbert Eich - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the authors not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The authors makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ -#ifndef V86_BIOS_H -#define V86_BIOS_H - -#if defined (__i386__) || defined (__i486__) || defined (__i586__) || defined (__i686__) || defined (__k6__) -# ifndef __ia32__ -# define __ia32__ -# endif -#endif - -#include - -#define p_printf(f,a...) do {if (Config.PrintPort) lprintf(f,##a);} \ - while(0) -#define i_printf(f,a...) do {if (Config.PrintIrq) lprintf(f,##a);} \ - while(0) -#define P_printf(f,a...) do {if (Config.PrintPci) lprintf(f,##a);} \ - while(0) - -typedef unsigned char CARD8; -typedef unsigned short CARD16; -typedef unsigned int CARD32; -#if defined (__alpha__) || defined (__ia64__) -typedef unsigned long memType; -#else -typedef unsigned int memType; -#endif - -typedef int Bool; - -#define FALSE 0 -#define TRUE 1 - -struct config { - Bool PrintPort; - Bool IoStatistics; - Bool PrintIrq; - Bool PrintPci; - Bool ShowAllDev; - Bool PrintIp; - Bool SaveBios; - Bool Trace; - Bool ConfigActiveOnly; - Bool ConfigActiveDevice; - Bool MapSysBios; - Bool Resort; - Bool FixRom; - Bool NoConsole; - Bool BootOnly; - int Verbose; -}; - -struct pio { - CARD8 (*inb)(CARD16); - CARD16 (*inw)(CARD16); - CARD32 (*inl)(CARD16); - void (*outb)(CARD16,CARD8); - void (*outw)(CARD16,CARD16); - void (*outl)(CARD16,CARD32); -}; - -struct regs86 { - long ebx; - long ecx; - long edx; - long esi; - long edi; - long ebp; - long eax; - long eip; - long esp; - unsigned short cs; - unsigned short ss; - unsigned short es; - unsigned short ds; - unsigned short fs; - unsigned short gs; - long eflags; -}; - -typedef struct { - CARD32 ax; - CARD32 bx; - CARD32 cx; - CARD32 dx; - CARD32 cs; - CARD32 es; - CARD32 ds; - CARD32 si; - CARD32 di; -} i86biosRegs, *i86biosRegsPtr; - -typedef struct { - int fd; - int vt; -} console; - -typedef struct { - void* address; - CARD8 orgval; -} haltpoints; - -enum dev_type { NONE, ISA, PCI }; -struct device { - Bool booted; - enum dev_type type; - union { - int none; - struct pci { - int bus; - int dev; - int func; - } pci; - } loc; -}; - -extern struct device Device; - -#ifdef __alpha__ -unsigned long _bus_base(void); -extern void* vram_map; -extern int sparse_shift; -#endif - -extern struct pio P; -extern struct config Config; -#define IOPERM_BITS 1024 -extern int ioperm_list[IOPERM_BITS]; - -extern void setup_io(void); -extern void do_x86(unsigned long bios_start,i86biosRegsPtr regs); -extern int run_bios_int(int num, struct regs86 *regs); -extern CARD32 getIntVect(int num); -CARD32 getIP(void); - -extern void call_boot(struct device *dev); -extern void runINT(int num,i86biosRegsPtr Regs); -extern void add_hlt(unsigned long addr); -extern void del_hlt(int addr); -extern void list_hlt(); - -extern int port_rep_inb(CARD16 port, CARD8 *base, int d_f, CARD32 count); -extern int port_rep_inw(CARD16 port, CARD16 *base, int d_f, CARD32 count); -extern int port_rep_inl(CARD16 port, CARD32 *base, int d_f, CARD32 count); -extern int port_rep_outb(CARD16 port, CARD8 *base, int d_f, CARD32 count); -extern int port_rep_outw(CARD16 port, CARD16 *base, int d_f, CARD32 count); -extern int port_rep_outl(CARD16 port, CARD32 *base, int d_f, CARD32 count); -extern CARD8 p_inb(CARD16 port); -extern CARD16 p_inw(CARD16 port); -extern CARD32 p_inl(CARD16 port); -extern void p_outb(CARD16 port, CARD8 val); -extern void p_outw(CARD16 port, CARD16 val); -extern void p_outl(CARD16 port, CARD32 val); -#ifdef __alpha__ -extern CARD8 a_inb(CARD16 port); -extern CARD16 a_inw(CARD16 port); -extern void a_outb(CARD16 port, CARD8 val); -extern void a_outw(CARD16 port, CARD16 val); -#endif -#ifdef __alpha__ -CARD8 mem_rb(CARD32 addr); -CARD16 mem_rw(CARD32 addr); -CARD32 mem_rl(CARD32 addr); -void mem_wb(CARD32 addr, CARD8 val); -void mem_ww(CARD32 addr, CARD16 val); -void mem_wl(CARD32 addr, CARD32 val); -#endif -extern void io_statistics(void); -extern void clear_stat(void); -extern int int_handler(int num, struct regs86 *regs); - -extern console open_console(void); -extern void close_console(console); - -extern void dprint(unsigned long start, unsigned long size); - -extern Bool logging; -extern Bool nostdout; -extern char* logfile; -extern void logon(void* ptr); -extern void logoff(); -extern void lprintf(const char *f, ...); - -#define MEM_FILE "/dev/mem" -#define DEFAULT_V_BIOS 0xc0000 -#ifndef V_BIOS -#define V_BIOS DEFAULT_V_BIOS -#endif - -#ifdef __alpha__ -#define NEED_PCI_IO -#endif - -#endif diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/working_cards b/board/MAI/bios_emulator/scitech/src/v86bios/working_cards deleted file mode 100644 index 7753f2495d..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/working_cards +++ /dev/null @@ -1,7 +0,0 @@ -David Monro: Trident TGUI 9440 - Virge/VX (Diamond Stealth 3D 3400) - Riva TNT (Diamond Viper V550) no vbios? -Jarno Paananen : Guillemot Maxigamer Xentor 32 - (NVIDIA TNT2 Ultra) - Creative Graphics Blaster Exxtreme - (Permedia 2) diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/x86emu.c b/board/MAI/bios_emulator/scitech/src/v86bios/x86emu.c deleted file mode 100644 index b5c99d7a7f..0000000000 --- a/board/MAI/bios_emulator/scitech/src/v86bios/x86emu.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * Copyright 1999 Egbert Eich - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the authors not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The authors makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ -#include "debug.h" - -#define IF_MASK 0x00000200 -#define VIF_MASK 0x00080000 /* virtual interrupt flag */ -#define VIP_MASK 0x00100000 /* virtual interrupt pending */ - -#include -#include -#include -/*#include */ -#include -#include -#include -#include -#ifdef __alpha__ -#include -#endif -#include -#include -#include "AsmMacros.h" -#include "v86bios.h" -# define DEBUG -#include "x86emu.h" -#undef DEBUG - -#define M _X86EMU_env -#define CPU_REG(reg) M.x86.R_##reg - -struct pio P; - -void -setup_io(void) -{ - if (!Config.PrintPort && !Config.IoStatistics) { - -#if defined (__i386__) - P.inb = (u8(*)(u16))inb; - P.inw = (u16(*)(u16))inw; - P.outb = (void(*)(u16,u8))outb; - P.outw = (void(*)(u16,u16))outw; -#else - P.inb = p_inb; - P.inw = p_inw; - P.outb = p_outb; - P.outw = p_outw; -#endif -#if defined (__i386__) && ! defined(NEED_PCI_IO) - P.inl = (u32(*)(u16))inl; - P.outl = (void(*)(u16,u32))outl; -#else - P.inl = p_inl; - P.outl = p_outl; -#endif - } else { - P.inb = p_inb; - P.inw = p_inw; - P.inl = p_inl; - P.outb = p_outb; - P.outw = p_outw; - P.outl = p_outl; - } -} - -void -x86emu_do_int(int num) -{ - struct regs86 regs; - - i_printf("int 0x%x received: ax:0x%x",num,CPU_REG(AX)); - if (Config.PrintIp) - i_printf(" at: 0x%x\n",getIP()); - else - i_printf("\n"); - - /* try to run bios interrupt */ - - /* if not installed fall back */ -#define COPY(x,y) regs.y = M.x86.x -#define COPY_R(x,y) M.x86.x = regs.y - - COPY(R_EAX,eax); - COPY(R_EBX,ebx); - COPY(R_ECX,ecx); - COPY(R_EDX,edx); - COPY(R_ESI,esi); - COPY(R_EDI,edi); - COPY(R_EBP,ebp); - COPY(R_EIP,eip); - COPY(R_ESP,esp); - COPY(R_CS,cs); - COPY(R_SS,ss); - COPY(R_DS,ds); - COPY(R_ES,es); - COPY(R_FS,fs); - COPY(R_GS,gs); - COPY(R_EFLG,eflags); - - if (!(int_handler(num,®s))) { - if (!run_bios_int(num,®s)) - goto unknown_int; - else - return; - } - - COPY_R(R_EAX,eax); - COPY_R(R_EBX,ebx); - COPY_R(R_ECX,ecx); - COPY_R(R_EDX,edx); - COPY_R(R_ESI,esi); - COPY_R(R_EDI,edi); - COPY_R(R_EBP,ebp); - COPY_R(R_EIP,eip); - COPY_R(R_ESP,esp); - COPY_R(R_CS,cs); - COPY_R(R_SS,ss); - COPY_R(R_DS,ds); - COPY_R(R_ES,es); - COPY_R(R_FS,fs); - COPY_R(R_GS,gs); - COPY_R(R_EFLG,eflags); - return; - - unknown_int: - fprintf(stderr,"\nUnknown vm86_int: %X\n\n",num); - X86EMU_halt_sys(); - return; - -#undef COPY -#undef COPY_R -} - -void -setup_x86emu(unsigned long bios_start, i86biosRegsPtr regs) -{ - int i; - CARD32 eip; - CARD16 cs; - X86EMU_intrFuncs intFuncs[256]; - - X86EMU_pioFuncs pioFuncs = { - (u8(*)(u16))P.inb, - (u16(*)(u16))P.inw, - (u32(*)(u16))P.inl, - (void(*)(u16,u8))P.outb, - (void(*)(u16,u16))P.outw, - (void(*)(u16,u32))P.outl - }; -#ifdef __alpha__ - X86EMU_memFuncs memFuncs = { - (u8(*)(u32))mem_rb, - (u16(*)(u32))mem_rw, - (u32(*)(u32))mem_rl, - (void(*)(u32,u8))mem_wb, - (void(*)(u32,u16))mem_ww, - (void(*)(u32,u32))mem_wl - }; -#endif - M.mem_base = 0; - M.mem_size = 1024*1024 + 1024; - /* M.x86.debug = DEBUG_DISASSEMBLE_F | DEBUG_TRACE_F | DEBUG_DECODE_F; */ - /* M.x86.debug |= DEBUG_DECODE_F | DEBUG_TRACE_F; */ -/* - * For single step tracing compile x86emu with option -DDEBUG - */ - M.x86.debug = 0; - if (Config.PrintIp) - M.x86.debug = DEBUG_SAVE_CS_IP; - - if (Config.Trace) - X86EMU_trace_on(); - - X86EMU_setupPioFuncs(&pioFuncs); -#ifdef __alpha__ - X86EMU_setupMemFuncs(&memFuncs); -#endif - for (i=0;i<256;i++) - intFuncs[i] = x86emu_do_int; - X86EMU_setupIntrFuncs(intFuncs); - - eip = bios_start & 0xFFFF; - cs = (bios_start & 0xFF0000) >> 4; - - CPU_REG(EAX) = regs->ax; - CPU_REG(EBX) = regs->bx; - CPU_REG(ECX) = regs->cx; - CPU_REG(EDX) = regs->dx; - CPU_REG(ESI) = regs->si; - CPU_REG(EDI) = regs->di; - CPU_REG(EBP) = 0; - CPU_REG(EIP) = eip; - CPU_REG(CS) = cs; - CPU_REG(SP) = 0x100; - CPU_REG(SS) = 0x30; /* This is the standard pc bios stack */ - CPU_REG(ES) = regs->es; - CPU_REG(DS) = regs->ds; - CPU_REG(FS) = 0; - CPU_REG(GS) = 0; - CPU_REG(EFLG) |= (VIF_MASK | VIP_MASK | IF_MASK | 0x2); -} - -void -collect_bios_regs(i86biosRegsPtr regs) -{ - regs->ax = CPU_REG(EAX); - regs->bx = CPU_REG(EBX); - regs->cx = CPU_REG(ECX); - regs->dx = CPU_REG(EDX); - regs->es = CPU_REG(ES); - regs->ds = CPU_REG(DS); - regs->di = CPU_REG(EDI); - regs->si = CPU_REG(ESI); -} - -static void -do_x86emu(void) -{ - X86EMU_exec(); -} - -static jmp_buf x86_esc; -static void -vmexit(int unused) -{ - longjmp(x86_esc,1); -} - -void -do_x86(unsigned long bios_start, i86biosRegsPtr regs) -{ - static void (*org_handler)(int); - - setup_x86emu(bios_start,regs); - if (setjmp(x86_esc) == 0) { - org_handler = signal(2,vmexit); - do_x86emu(); - signal(2,org_handler); - collect_bios_regs(regs); - } else { - signal(2,org_handler); - printf("interrupted at 0x%x\n",((CARD16)CPU_REG(CS)) << 4 - | (CARD16)CPU_REG(EIP)); - } -} - -int -run_bios_int(int num, struct regs86 *regs) -{ -#ifdef V86BIOS_DEBUG - static int firsttime = 1; -#endif - /* check if bios vector is initialized */ - if (((CARD16*)0)[(num<<1)+1] == 0x0000) { /* SYS_BIOS_SEG ?*/ -#ifdef V86BIOS_DEBUG - i_printf("card BIOS not loaded\n"); -#endif - return 0; - } - -#ifdef V86BIOS_DEBUG - if (firsttime) { - dprint(0,0x3D0); - firsttime = 0; - } -#endif - - i_printf("calling card BIOS at: "); - i_printf("0x%x:%x\n",((CARD16 *) 0)[(num << 1) + 1], - (CARD32)((CARD16 *) 0)[num << 1]); - X86EMU_prepareForInt(num); - - return 1; -} - -CARD32 -getIntVect(int num) -{ - return ((CARD32*)0)[num]; -} -#if 0 -void -printk(const char *fmt, ...) -{ - va_list argptr; - va_start(argptr, fmt); - vfprintf(stdout, fmt, argptr); - fflush(stdout); - va_end(argptr); -} -#endif - -CARD32 -getIP(void) -{ - return (M.x86.saved_cs << 4) + M.x86.saved_ip; -} diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/LICENSE b/board/MAI/bios_emulator/scitech/src/x86emu/LICENSE deleted file mode 100644 index a3ede4a87d..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/LICENSE +++ /dev/null @@ -1,17 +0,0 @@ - License information - ------------------- - -The x86emu library is under a BSD style license, comaptible -with the XFree86 and X licenses used by XFree86. The -original x86emu libraries were under the GNU General Public -License. Due to license incompatibilities between the GPL -and the XFree86 license, the original authors of the code -decided to allow a license change. If you have submitted -code to the original x86emu project, and you don't agree -with the license change, please contact us and let you -know. Your code will be removed to comply with your wishes. - -If you have any questions about this, please send email to -x86emu@linuxlabs.com or KendallB@scitechsoft.com for -clarification. - diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/debug.c b/board/MAI/bios_emulator/scitech/src/x86emu/debug.c deleted file mode 100644 index 235e6ac146..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/debug.c +++ /dev/null @@ -1,443 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: This file contains the code to handle debugging of the -* emulator. -* -****************************************************************************/ - -#include "x86emu/x86emui.h" -#include -#include - -/*----------------------------- Implementation ----------------------------*/ - -#ifdef DEBUG - -static void print_encoded_bytes (u16 s, u16 o); -static void print_decoded_instruction (void); -static int parse_line (char *s, int *ps, int *n); - -/* should look something like debug's output. */ -void X86EMU_trace_regs (void) -{ - if (DEBUG_TRACE()) { - x86emu_dump_regs(); - } - if (DEBUG_DECODE() && ! DEBUG_DECODE_NOPRINT()) { - printk("%04x:%04x ",M.x86.saved_cs, M.x86.saved_ip); - print_encoded_bytes( M.x86.saved_cs, M.x86.saved_ip); - print_decoded_instruction(); - } -} - -void X86EMU_trace_xregs (void) -{ - if (DEBUG_TRACE()) { - x86emu_dump_xregs(); - } -} - -void x86emu_just_disassemble (void) -{ - /* - * This routine called if the flag DEBUG_DISASSEMBLE is set kind - * of a hack! - */ - printk("%04x:%04x ",M.x86.saved_cs, M.x86.saved_ip); - print_encoded_bytes( M.x86.saved_cs, M.x86.saved_ip); - print_decoded_instruction(); -} - -static void disassemble_forward (u16 seg, u16 off, int n) -{ - X86EMU_sysEnv tregs; - int i; - u8 op1; - /* - * hack, hack, hack. What we do is use the exact machinery set up - * for execution, except that now there is an additional state - * flag associated with the "execution", and we are using a copy - * of the register struct. All the major opcodes, once fully - * decoded, have the following two steps: TRACE_REGS(r,m); - * SINGLE_STEP(r,m); which disappear if DEBUG is not defined to - * the preprocessor. The TRACE_REGS macro expands to: - * - * if (debug&DEBUG_DISASSEMBLE) - * {just_disassemble(); goto EndOfInstruction;} - * if (debug&DEBUG_TRACE) trace_regs(r,m); - * - * ...... and at the last line of the routine. - * - * EndOfInstruction: end_instr(); - * - * Up to the point where TRACE_REG is expanded, NO modifications - * are done to any register EXCEPT the IP register, for fetch and - * decoding purposes. - * - * This was done for an entirely different reason, but makes a - * nice way to get the system to help debug codes. - */ - tregs = M; - tregs.x86.R_IP = off; - tregs.x86.R_CS = seg; - - /* reset the decoding buffers */ - tregs.x86.enc_str_pos = 0; - tregs.x86.enc_pos = 0; - - /* turn on the "disassemble only, no execute" flag */ - tregs.x86.debug |= DEBUG_DISASSEMBLE_F; - - /* DUMP NEXT n instructions to screen in straight_line fashion */ - /* - * This looks like the regular instruction fetch stream, except - * that when this occurs, each fetched opcode, upon seeing the - * DEBUG_DISASSEMBLE flag set, exits immediately after decoding - * the instruction. XXX --- CHECK THAT MEM IS NOT AFFECTED!!! - * Note the use of a copy of the register structure... - */ - for (i=0; i 256) return; - seg = fetch_data_word_abs(0,iv*4); - off = fetch_data_word_abs(0,iv*4+2); - printk("%04x:%04x ", seg, off); -} - -void X86EMU_dump_memory (u16 seg, u16 off, u32 amt) -{ - u32 start = off & 0xfffffff0; - u32 end = (off+16) & 0xfffffff0; - u32 i; - u32 current; - - current = start; - while (end <= off + amt) { - printk("%04x:%04x ", seg, start); - for (i=start; i< off; i++) - printk(" "); - for ( ; i< end; i++) - printk("%02x ", fetch_data_byte_abs(seg,i)); - printk("\n"); - start = end; - end = start + 16; - } -} - -void x86emu_single_step (void) -{ - char s[1024]; - int ps[10]; - int ntok; - int cmd; - int done; - int segment; - int offset; - static int breakpoint; - static int noDecode = 1; - - char *p; - - if (DEBUG_BREAK()) { - if (M.x86.saved_ip != breakpoint) { - return; - } else { - M.x86.debug &= ~DEBUG_DECODE_NOPRINT_F; - M.x86.debug |= DEBUG_TRACE_F; - M.x86.debug &= ~DEBUG_BREAK_F; - print_decoded_instruction (); - X86EMU_trace_regs(); - } - } - - done=0; - offset = M.x86.saved_ip; - while (!done) { - printk("-"); - /*p = fgets(s, 1023, stdin); */ - cons_gets(s); - cmd = parse_line(s, ps, &ntok); - switch(cmd) { - case 'u': - disassemble_forward(M.x86.saved_cs,(u16)offset,10); - break; - case 'd': - if (ntok == 2) { - segment = M.x86.saved_cs; - offset = ps[1]; - X86EMU_dump_memory(segment,(u16)offset,16); - offset += 16; - } else if (ntok == 3) { - segment = ps[1]; - offset = ps[2]; - X86EMU_dump_memory(segment,(u16)offset,16); - offset += 16; - } else { - segment = M.x86.saved_cs; - X86EMU_dump_memory(segment,(u16)offset,16); - offset += 16; - } - break; - case 'c': - M.x86.debug ^= DEBUG_TRACECALL_F; - break; - case 's': - M.x86.debug ^= DEBUG_SVC_F | DEBUG_SYS_F | DEBUG_SYSINT_F; - break; - case 'r': - X86EMU_trace_regs(); - break; - case 'x': - X86EMU_trace_xregs(); - break; - case 'g': - if (ntok == 2) { - breakpoint = ps[1]; - printk("breakpoint set to 0x%X\n", breakpoint); - if (noDecode) { - M.x86.debug |= DEBUG_DECODE_NOPRINT_F; - } else { - M.x86.debug &= ~DEBUG_DECODE_NOPRINT_F; - } - M.x86.debug &= ~DEBUG_TRACE_F; - M.x86.debug |= DEBUG_BREAK_F; - done = 1; - } - break; - case 'q': - M.x86.debug |= DEBUG_EXIT; - return; - case 'P': - noDecode = (noDecode)?0:1; - printk("Toggled decoding to %s\n",(noDecode)?"FALSE":"TRUE"); - break; - case 't': - case 0: - done = 1; - break; - } - } -} - -int X86EMU_trace_on(void) -{ - return M.x86.debug |= DEBUG_STEP_F | DEBUG_DECODE_F | DEBUG_TRACE_F; -} - -int X86EMU_trace_off(void) -{ - return M.x86.debug &= ~(DEBUG_STEP_F | DEBUG_DECODE_F | DEBUG_TRACE_F); -} - -static int parse_line (char *s, int *ps, int *n) -{ - int cmd; - - *n = 0; - while(*s == ' ' || *s == '\t') s++; - ps[*n] = *s; - switch (*s) { - case '\n': - *n += 1; - return 0; - default: - cmd = *s; - *n += 1; - } - - while (1) { - while (*s != ' ' && *s != '\t' && *s != '\n') s++; - - if (*s == '\n') - return cmd; - - while(*s == ' ' || *s == '\t') s++; - - ps[*n]=atoi(s); - /*sscanf(s,"%x",&ps[*n]); */ - *n += 1; - } -} - -#endif /* DEBUG */ - -void x86emu_dump_stack(void) -{ - int i; - printk("Stack: "); - for (i = 0; i<16; i++) - { - u8 x = fetch_data_byte_abs(M.x86.R_SS, M.x86.R_SP + i); - printk("%02x ", (int)x); - } - printk("\n"); -} - -void x86emu_dump_regs (void) -{ - printk("\tAX=%04x ", M.x86.R_AX ); - printk("BX=%04x ", M.x86.R_BX ); - printk("CX=%04x ", M.x86.R_CX ); - printk("DX=%04x ", M.x86.R_DX ); - printk("SP=%04x ", M.x86.R_SP ); - printk("BP=%04x ", M.x86.R_BP ); - printk("SI=%04x ", M.x86.R_SI ); - printk("DI=%04x\n", M.x86.R_DI ); - printk("\tDS=%04x ", M.x86.R_DS ); - printk("ES=%04x ", M.x86.R_ES ); - printk("SS=%04x ", M.x86.R_SS ); - printk("CS=%04x ", M.x86.R_CS ); - printk("IP=%04x ", M.x86.R_IP ); - if (ACCESS_FLAG(F_OF)) printk("OV "); /* CHECKED... */ - else printk("NV "); - if (ACCESS_FLAG(F_DF)) printk("DN "); - else printk("UP "); - if (ACCESS_FLAG(F_IF)) printk("EI "); - else printk("DI "); - if (ACCESS_FLAG(F_SF)) printk("NG "); - else printk("PL "); - if (ACCESS_FLAG(F_ZF)) printk("ZR "); - else printk("NZ "); - if (ACCESS_FLAG(F_AF)) printk("AC "); - else printk("NA "); - if (ACCESS_FLAG(F_PF)) printk("PE "); - else printk("PO "); - if (ACCESS_FLAG(F_CF)) printk("CY "); - else printk("NC "); - printk("\n"); - /*x86emu_dump_stack(); */ -} - -void x86emu_dump_xregs (void) -{ - printk("\tEAX=%08x ", M.x86.R_EAX ); - printk("EBX=%08x ", M.x86.R_EBX ); - printk("ECX=%08x ", M.x86.R_ECX ); - printk("EDX=%08x \n", M.x86.R_EDX ); - printk("\tESP=%08x ", M.x86.R_ESP ); - printk("EBP=%08x ", M.x86.R_EBP ); - printk("ESI=%08x ", M.x86.R_ESI ); - printk("EDI=%08x\n", M.x86.R_EDI ); - printk("\tDS=%04x ", M.x86.R_DS ); - printk("ES=%04x ", M.x86.R_ES ); - printk("SS=%04x ", M.x86.R_SS ); - printk("CS=%04x ", M.x86.R_CS ); - printk("EIP=%08x\n\t", M.x86.R_EIP ); - if (ACCESS_FLAG(F_OF)) printk("OV "); /* CHECKED... */ - else printk("NV "); - if (ACCESS_FLAG(F_DF)) printk("DN "); - else printk("UP "); - if (ACCESS_FLAG(F_IF)) printk("EI "); - else printk("DI "); - if (ACCESS_FLAG(F_SF)) printk("NG "); - else printk("PL "); - if (ACCESS_FLAG(F_ZF)) printk("ZR "); - else printk("NZ "); - if (ACCESS_FLAG(F_AF)) printk("AC "); - else printk("NA "); - if (ACCESS_FLAG(F_PF)) printk("PE "); - else printk("PO "); - if (ACCESS_FLAG(F_CF)) printk("CY "); - else printk("NC "); - printk("\n"); -} diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/decode.c b/board/MAI/bios_emulator/scitech/src/x86emu/decode.c deleted file mode 100644 index 832b1f5f2e..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/decode.c +++ /dev/null @@ -1,970 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: This file includes subroutines which are related to -* instruction decoding and accessess of immediate data via IP. etc. -* -****************************************************************************/ - -#include "x86emu/x86emui.h" - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -REMARKS: -Handles any pending asychronous interrupts. -****************************************************************************/ -static void x86emu_intr_handle(void) -{ - u8 intno; - - if (M.x86.intr & INTR_SYNCH) { - intno = M.x86.intno; - if (_X86EMU_intrTab[intno]) { - (*_X86EMU_intrTab[intno])(intno); - } else { - push_word((u16)M.x86.R_FLG); - CLEAR_FLAG(F_IF); - CLEAR_FLAG(F_TF); - push_word(M.x86.R_CS); - M.x86.R_CS = mem_access_word(intno * 4 + 2); - push_word(M.x86.R_IP); - M.x86.R_IP = mem_access_word(intno * 4); - M.x86.intr = 0; - } - } -} - -/**************************************************************************** -PARAMETERS: -intrnum - Interrupt number to raise - -REMARKS: -Raise the specified interrupt to be handled before the execution of the -next instruction. -****************************************************************************/ -void x86emu_intr_raise( - u8 intrnum) -{ - M.x86.intno = intrnum; - M.x86.intr |= INTR_SYNCH; -} - -/**************************************************************************** -REMARKS: -Main execution loop for the emulator. We return from here when the system -halts, which is normally caused by a stack fault when we return from the -original real mode call. -****************************************************************************/ -void X86EMU_exec(void) -{ - u8 op1; - - M.x86.intr = 0; - DB(x86emu_end_instr();) - - for (;;) { - DB(if (CHECK_IP_FETCH()) x86emu_check_ip_access();) - /* If debugging, save the IP and CS values. */ - SAVE_IP_CS(M.x86.R_CS, M.x86.R_IP); - INC_DECODED_INST_LEN(1); - if (M.x86.intr) { - if (M.x86.intr & INTR_HALTED) { - DB( printk("halted\n"); X86EMU_trace_regs();) - return; - } - if (((M.x86.intr & INTR_SYNCH) && (M.x86.intno == 0 || M.x86.intno == 2)) || - !ACCESS_FLAG(F_IF)) { - x86emu_intr_handle(); - } - } - op1 = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++)); - (*x86emu_optab[op1])(op1); - if (M.x86.debug & DEBUG_EXIT) { - M.x86.debug &= ~DEBUG_EXIT; - return; - } - } -} - -/**************************************************************************** -REMARKS: -Halts the system by setting the halted system flag. -****************************************************************************/ -void X86EMU_halt_sys(void) -{ - M.x86.intr |= INTR_HALTED; -} - -/**************************************************************************** -PARAMETERS: -mod - Mod value from decoded byte -regh - Reg h value from decoded byte -regl - Reg l value from decoded byte - -REMARKS: -Raise the specified interrupt to be handled before the execution of the -next instruction. - -NOTE: Do not inline this function, as (*sys_rdb) is already inline! -****************************************************************************/ -void fetch_decode_modrm( - int *mod, - int *regh, - int *regl) -{ - int fetched; - -DB( if (CHECK_IP_FETCH()) - x86emu_check_ip_access();) - fetched = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++)); - INC_DECODED_INST_LEN(1); - *mod = (fetched >> 6) & 0x03; - *regh = (fetched >> 3) & 0x07; - *regl = (fetched >> 0) & 0x07; -} - -/**************************************************************************** -RETURNS: -Immediate byte value read from instruction queue - -REMARKS: -This function returns the immediate byte from the instruction queue, and -moves the instruction pointer to the next value. - -NOTE: Do not inline this function, as (*sys_rdb) is already inline! -****************************************************************************/ -u8 fetch_byte_imm(void) -{ - u8 fetched; - -DB( if (CHECK_IP_FETCH()) - x86emu_check_ip_access();) - fetched = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++)); - INC_DECODED_INST_LEN(1); - return fetched; -} - -/**************************************************************************** -RETURNS: -Immediate word value read from instruction queue - -REMARKS: -This function returns the immediate byte from the instruction queue, and -moves the instruction pointer to the next value. - -NOTE: Do not inline this function, as (*sys_rdw) is already inline! -****************************************************************************/ -u16 fetch_word_imm(void) -{ - u16 fetched; - -DB( if (CHECK_IP_FETCH()) - x86emu_check_ip_access();) - fetched = (*sys_rdw)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP)); - M.x86.R_IP += 2; - INC_DECODED_INST_LEN(2); - return fetched; -} - -/**************************************************************************** -RETURNS: -Immediate lone value read from instruction queue - -REMARKS: -This function returns the immediate byte from the instruction queue, and -moves the instruction pointer to the next value. - -NOTE: Do not inline this function, as (*sys_rdw) is already inline! -****************************************************************************/ -u32 fetch_long_imm(void) -{ - u32 fetched; - -DB( if (CHECK_IP_FETCH()) - x86emu_check_ip_access();) - fetched = (*sys_rdl)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP)); - M.x86.R_IP += 4; - INC_DECODED_INST_LEN(4); - return fetched; -} - -/**************************************************************************** -RETURNS: -Value of the default data segment - -REMARKS: -Inline function that returns the default data segment for the current -instruction. - -On the x86 processor, the default segment is not always DS if there is -no segment override. Address modes such as -3[BP] or 10[BP+SI] all refer to -addresses relative to SS (ie: on the stack). So, at the minimum, all -decodings of addressing modes would have to set/clear a bit describing -whether the access is relative to DS or SS. That is the function of the -cpu-state-varible M.x86.mode. There are several potential states: - - repe prefix seen (handled elsewhere) - repne prefix seen (ditto) - - cs segment override - ds segment override - es segment override - fs segment override - gs segment override - ss segment override - - ds/ss select (in absense of override) - -Each of the above 7 items are handled with a bit in the mode field. -****************************************************************************/ -_INLINE u32 get_data_segment(void) -{ -#define GET_SEGMENT(segment) - switch (M.x86.mode & SYSMODE_SEGMASK) { - case 0: /* default case: use ds register */ - case SYSMODE_SEGOVR_DS: - case SYSMODE_SEGOVR_DS | SYSMODE_SEG_DS_SS: - return M.x86.R_DS; - case SYSMODE_SEG_DS_SS: /* non-overridden, use ss register */ - return M.x86.R_SS; - case SYSMODE_SEGOVR_CS: - case SYSMODE_SEGOVR_CS | SYSMODE_SEG_DS_SS: - return M.x86.R_CS; - case SYSMODE_SEGOVR_ES: - case SYSMODE_SEGOVR_ES | SYSMODE_SEG_DS_SS: - return M.x86.R_ES; - case SYSMODE_SEGOVR_FS: - case SYSMODE_SEGOVR_FS | SYSMODE_SEG_DS_SS: - return M.x86.R_FS; - case SYSMODE_SEGOVR_GS: - case SYSMODE_SEGOVR_GS | SYSMODE_SEG_DS_SS: - return M.x86.R_GS; - case SYSMODE_SEGOVR_SS: - case SYSMODE_SEGOVR_SS | SYSMODE_SEG_DS_SS: - return M.x86.R_SS; - default: -#ifdef DEBUG - printk("error: should not happen: multiple overrides.\n"); -#endif - HALT_SYS(); - return 0; - } -} - -/**************************************************************************** -PARAMETERS: -offset - Offset to load data from - -RETURNS: -Byte value read from the absolute memory location. - -NOTE: Do not inline this function as (*sys_rdX) is already inline! -****************************************************************************/ -u8 fetch_data_byte( - uint offset) -{ -#ifdef DEBUG - if (CHECK_DATA_ACCESS()) - x86emu_check_data_access((u16)get_data_segment(), offset); -#endif - return (*sys_rdb)((get_data_segment() << 4) + offset); -} - -/**************************************************************************** -PARAMETERS: -offset - Offset to load data from - -RETURNS: -Word value read from the absolute memory location. - -NOTE: Do not inline this function as (*sys_rdX) is already inline! -****************************************************************************/ -u16 fetch_data_word( - uint offset) -{ -#ifdef DEBUG - if (CHECK_DATA_ACCESS()) - x86emu_check_data_access((u16)get_data_segment(), offset); -#endif - return (*sys_rdw)((get_data_segment() << 4) + offset); -} - -/**************************************************************************** -PARAMETERS: -offset - Offset to load data from - -RETURNS: -Long value read from the absolute memory location. - -NOTE: Do not inline this function as (*sys_rdX) is already inline! -****************************************************************************/ -u32 fetch_data_long( - uint offset) -{ -#ifdef DEBUG - if (CHECK_DATA_ACCESS()) - x86emu_check_data_access((u16)get_data_segment(), offset); -#endif - return (*sys_rdl)((get_data_segment() << 4) + offset); -} - -/**************************************************************************** -PARAMETERS: -segment - Segment to load data from -offset - Offset to load data from - -RETURNS: -Byte value read from the absolute memory location. - -NOTE: Do not inline this function as (*sys_rdX) is already inline! -****************************************************************************/ -u8 fetch_data_byte_abs( - uint segment, - uint offset) -{ -#ifdef DEBUG - if (CHECK_DATA_ACCESS()) - x86emu_check_data_access(segment, offset); -#endif - return (*sys_rdb)(((u32)segment << 4) + offset); -} - -/**************************************************************************** -PARAMETERS: -segment - Segment to load data from -offset - Offset to load data from - -RETURNS: -Word value read from the absolute memory location. - -NOTE: Do not inline this function as (*sys_rdX) is already inline! -****************************************************************************/ -u16 fetch_data_word_abs( - uint segment, - uint offset) -{ -#ifdef DEBUG - if (CHECK_DATA_ACCESS()) - x86emu_check_data_access(segment, offset); -#endif - return (*sys_rdw)(((u32)segment << 4) + offset); -} - -/**************************************************************************** -PARAMETERS: -segment - Segment to load data from -offset - Offset to load data from - -RETURNS: -Long value read from the absolute memory location. - -NOTE: Do not inline this function as (*sys_rdX) is already inline! -****************************************************************************/ -u32 fetch_data_long_abs( - uint segment, - uint offset) -{ -#ifdef DEBUG - if (CHECK_DATA_ACCESS()) - x86emu_check_data_access(segment, offset); -#endif - return (*sys_rdl)(((u32)segment << 4) + offset); -} - -/**************************************************************************** -PARAMETERS: -offset - Offset to store data at -val - Value to store - -REMARKS: -Writes a word value to an segmented memory location. The segment used is -the current 'default' segment, which may have been overridden. - -NOTE: Do not inline this function as (*sys_wrX) is already inline! -****************************************************************************/ -void store_data_byte( - uint offset, - u8 val) -{ -#ifdef DEBUG - if (CHECK_DATA_ACCESS()) - x86emu_check_data_access((u16)get_data_segment(), offset); -#endif - (*sys_wrb)((get_data_segment() << 4) + offset, val); -} - -/**************************************************************************** -PARAMETERS: -offset - Offset to store data at -val - Value to store - -REMARKS: -Writes a word value to an segmented memory location. The segment used is -the current 'default' segment, which may have been overridden. - -NOTE: Do not inline this function as (*sys_wrX) is already inline! -****************************************************************************/ -void store_data_word( - uint offset, - u16 val) -{ -#ifdef DEBUG - if (CHECK_DATA_ACCESS()) - x86emu_check_data_access((u16)get_data_segment(), offset); -#endif - (*sys_wrw)((get_data_segment() << 4) + offset, val); -} - -/**************************************************************************** -PARAMETERS: -offset - Offset to store data at -val - Value to store - -REMARKS: -Writes a long value to an segmented memory location. The segment used is -the current 'default' segment, which may have been overridden. - -NOTE: Do not inline this function as (*sys_wrX) is already inline! -****************************************************************************/ -void store_data_long( - uint offset, - u32 val) -{ -#ifdef DEBUG - if (CHECK_DATA_ACCESS()) - x86emu_check_data_access((u16)get_data_segment(), offset); -#endif - (*sys_wrl)((get_data_segment() << 4) + offset, val); -} - -/**************************************************************************** -PARAMETERS: -segment - Segment to store data at -offset - Offset to store data at -val - Value to store - -REMARKS: -Writes a byte value to an absolute memory location. - -NOTE: Do not inline this function as (*sys_wrX) is already inline! -****************************************************************************/ -void store_data_byte_abs( - uint segment, - uint offset, - u8 val) -{ -#ifdef DEBUG - if (CHECK_DATA_ACCESS()) - x86emu_check_data_access(segment, offset); -#endif - (*sys_wrb)(((u32)segment << 4) + offset, val); -} - -/**************************************************************************** -PARAMETERS: -segment - Segment to store data at -offset - Offset to store data at -val - Value to store - -REMARKS: -Writes a word value to an absolute memory location. - -NOTE: Do not inline this function as (*sys_wrX) is already inline! -****************************************************************************/ -void store_data_word_abs( - uint segment, - uint offset, - u16 val) -{ -#ifdef DEBUG - if (CHECK_DATA_ACCESS()) - x86emu_check_data_access(segment, offset); -#endif - (*sys_wrw)(((u32)segment << 4) + offset, val); -} - -/**************************************************************************** -PARAMETERS: -segment - Segment to store data at -offset - Offset to store data at -val - Value to store - -REMARKS: -Writes a long value to an absolute memory location. - -NOTE: Do not inline this function as (*sys_wrX) is already inline! -****************************************************************************/ -void store_data_long_abs( - uint segment, - uint offset, - u32 val) -{ -#ifdef DEBUG - if (CHECK_DATA_ACCESS()) - x86emu_check_data_access(segment, offset); -#endif - (*sys_wrl)(((u32)segment << 4) + offset, val); -} - -/**************************************************************************** -PARAMETERS: -reg - Register to decode - -RETURNS: -Pointer to the appropriate register - -REMARKS: -Return a pointer to the register given by the R/RM field of the -modrm byte, for byte operands. Also enables the decoding of instructions. -****************************************************************************/ -u8* decode_rm_byte_register( - int reg) -{ - switch (reg) { - case 0: - DECODE_PRINTF("AL"); - return &M.x86.R_AL; - case 1: - DECODE_PRINTF("CL"); - return &M.x86.R_CL; - case 2: - DECODE_PRINTF("DL"); - return &M.x86.R_DL; - case 3: - DECODE_PRINTF("BL"); - return &M.x86.R_BL; - case 4: - DECODE_PRINTF("AH"); - return &M.x86.R_AH; - case 5: - DECODE_PRINTF("CH"); - return &M.x86.R_CH; - case 6: - DECODE_PRINTF("DH"); - return &M.x86.R_DH; - case 7: - DECODE_PRINTF("BH"); - return &M.x86.R_BH; - } - HALT_SYS(); - return NULL; /* NOT REACHED OR REACHED ON ERROR */ -} - -/**************************************************************************** -PARAMETERS: -reg - Register to decode - -RETURNS: -Pointer to the appropriate register - -REMARKS: -Return a pointer to the register given by the R/RM field of the -modrm byte, for word operands. Also enables the decoding of instructions. -****************************************************************************/ -u16* decode_rm_word_register( - int reg) -{ - switch (reg) { - case 0: - DECODE_PRINTF("AX"); - return &M.x86.R_AX; - case 1: - DECODE_PRINTF("CX"); - return &M.x86.R_CX; - case 2: - DECODE_PRINTF("DX"); - return &M.x86.R_DX; - case 3: - DECODE_PRINTF("BX"); - return &M.x86.R_BX; - case 4: - DECODE_PRINTF("SP"); - return &M.x86.R_SP; - case 5: - DECODE_PRINTF("BP"); - return &M.x86.R_BP; - case 6: - DECODE_PRINTF("SI"); - return &M.x86.R_SI; - case 7: - DECODE_PRINTF("DI"); - return &M.x86.R_DI; - } - HALT_SYS(); - return NULL; /* NOTREACHED OR REACHED ON ERROR */ -} - -/**************************************************************************** -PARAMETERS: -reg - Register to decode - -RETURNS: -Pointer to the appropriate register - -REMARKS: -Return a pointer to the register given by the R/RM field of the -modrm byte, for dword operands. Also enables the decoding of instructions. -****************************************************************************/ -u32* decode_rm_long_register( - int reg) -{ - switch (reg) { - case 0: - DECODE_PRINTF("EAX"); - return &M.x86.R_EAX; - case 1: - DECODE_PRINTF("ECX"); - return &M.x86.R_ECX; - case 2: - DECODE_PRINTF("EDX"); - return &M.x86.R_EDX; - case 3: - DECODE_PRINTF("EBX"); - return &M.x86.R_EBX; - case 4: - DECODE_PRINTF("ESP"); - return &M.x86.R_ESP; - case 5: - DECODE_PRINTF("EBP"); - return &M.x86.R_EBP; - case 6: - DECODE_PRINTF("ESI"); - return &M.x86.R_ESI; - case 7: - DECODE_PRINTF("EDI"); - return &M.x86.R_EDI; - } - HALT_SYS(); - return NULL; /* NOTREACHED OR REACHED ON ERROR */ -} - -/**************************************************************************** -PARAMETERS: -reg - Register to decode - -RETURNS: -Pointer to the appropriate register - -REMARKS: -Return a pointer to the register given by the R/RM field of the -modrm byte, for word operands, modified from above for the weirdo -special case of segreg operands. Also enables the decoding of instructions. -****************************************************************************/ -u16* decode_rm_seg_register( - int reg) -{ - switch (reg) { - case 0: - DECODE_PRINTF("ES"); - return &M.x86.R_ES; - case 1: - DECODE_PRINTF("CS"); - return &M.x86.R_CS; - case 2: - DECODE_PRINTF("SS"); - return &M.x86.R_SS; - case 3: - DECODE_PRINTF("DS"); - return &M.x86.R_DS; - case 4: - case 5: - case 6: - case 7: - DECODE_PRINTF("ILLEGAL SEGREG"); - break; - } - HALT_SYS(); - return NULL; /* NOT REACHED OR REACHED ON ERROR */ -} - -/**************************************************************************** -PARAMETERS: -rm - RM value to decode - -RETURNS: -Offset in memory for the address decoding - -REMARKS: -Return the offset given by mod=00 addressing. Also enables the -decoding of instructions. - -NOTE: The code which specifies the corresponding segment (ds vs ss) - below in the case of [BP+..]. The assumption here is that at the - point that this subroutine is called, the bit corresponding to - SYSMODE_SEG_DS_SS will be zero. After every instruction - except the segment override instructions, this bit (as well - as any bits indicating segment overrides) will be clear. So - if a SS access is needed, set this bit. Otherwise, DS access - occurs (unless any of the segment override bits are set). -****************************************************************************/ -unsigned decode_rm00_address( - int rm) -{ - unsigned offset; - - if (M.x86.mode & SYSMODE_PREFIX_ADDR) - { - switch (rm) { - case 0: - DECODE_PRINTF("[EAX]"); - return M.x86.R_EAX; - case 1: - DECODE_PRINTF("[ECX]"); - return M.x86.R_ECX; - case 2: - DECODE_PRINTF("[EDX]"); -/* M.x86.mode |= SYSMODE_SEG_DS_SS; */ - return M.x86.R_EDX; - case 3: - DECODE_PRINTF("[EBX]"); -/* M.x86.mode |= SYSMODE_SEG_DS_SS; */ - return M.x86.R_EBX; - case 4: - printk("Unsupported SIB encoding\n"); - HALT_SYS(); - return 0; - case 5: - offset = fetch_long_imm(); - DECODE_PRINTF2("[%08x]", offset); - return offset; - case 6: - DECODE_PRINTF("[ESI]"); - return M.x86.R_ESI; - case 7: - DECODE_PRINTF("[EDI]"); - return M.x86.R_EDI; - } - } - else - { - switch (rm) { - case 0: - DECODE_PRINTF("[BX+SI]"); - return M.x86.R_BX + M.x86.R_SI; - case 1: - DECODE_PRINTF("[BX+DI]"); - return M.x86.R_BX + M.x86.R_DI; - case 2: - DECODE_PRINTF("[BP+SI]"); - M.x86.mode |= SYSMODE_SEG_DS_SS; - return M.x86.R_BP + M.x86.R_SI; - case 3: - DECODE_PRINTF("[BP+DI]"); - M.x86.mode |= SYSMODE_SEG_DS_SS; - return M.x86.R_BP + M.x86.R_DI; - case 4: - DECODE_PRINTF("[SI]"); - return M.x86.R_SI; - case 5: - DECODE_PRINTF("[DI]"); - return M.x86.R_DI; - case 6: - offset = fetch_word_imm(); - DECODE_PRINTF2("[%04x]", offset); - return offset; - case 7: - DECODE_PRINTF("[BX]"); - return M.x86.R_BX; - } - } - HALT_SYS(); - return 0; -} - -/**************************************************************************** -PARAMETERS: -rm - RM value to decode - -RETURNS: -Offset in memory for the address decoding - -REMARKS: -Return the offset given by mod=01 addressing. Also enables the -decoding of instructions. -****************************************************************************/ -unsigned decode_rm01_address( - int rm) -{ - int displacement = (s8)fetch_byte_imm(); - if (M.x86.mode & SYSMODE_PREFIX_ADDR) - { - switch (rm) - { - case 0: - DECODE_PRINTF2("%d[EAX}", displacement); - return M.x86.R_EAX + displacement; - case 1: - DECODE_PRINTF2("%d[ECX]", displacement); - return M.x86.R_ECX + displacement; - case 2: - DECODE_PRINTF2("%d[EDX]", displacement); - return M.x86.R_EDX + displacement; - case 3: - DECODE_PRINTF2("%d[EBX]", displacement); - return M.x86.R_EBX + displacement; - case 4: - printk("Unsupported SIB addressing mode\n"); - HALT_SYS(); - return 0; - case 5: - DECODE_PRINTF2("%d[EBP]", displacement); - return M.x86.R_EBP + displacement; - case 6: - DECODE_PRINTF2("%d[ESI]", displacement); - return M.x86.R_ESI + displacement; - case 7: - DECODE_PRINTF2("%d[EDI]", displacement); - return M.x86.R_EDI + displacement; - } - } - else - { - switch (rm) { - case 0: - DECODE_PRINTF2("%d[BX+SI]", displacement); - return M.x86.R_BX + M.x86.R_SI + displacement; - case 1: - DECODE_PRINTF2("%d[BX+DI]", displacement); - return M.x86.R_BX + M.x86.R_DI + displacement; - case 2: - DECODE_PRINTF2("%d[BP+SI]", displacement); - M.x86.mode |= SYSMODE_SEG_DS_SS; - return M.x86.R_BP + M.x86.R_SI + displacement; - case 3: - DECODE_PRINTF2("%d[BP+DI]", displacement); - M.x86.mode |= SYSMODE_SEG_DS_SS; - return M.x86.R_BP + M.x86.R_DI + displacement; - case 4: - DECODE_PRINTF2("%d[SI]", displacement); - return M.x86.R_SI + displacement; - case 5: - DECODE_PRINTF2("%d[DI]", displacement); - return M.x86.R_DI + displacement; - case 6: - DECODE_PRINTF2("%d[BP]", displacement); - M.x86.mode |= SYSMODE_SEG_DS_SS; - return M.x86.R_BP + displacement; - case 7: - DECODE_PRINTF2("%d[BX]", displacement); - return M.x86.R_BX + displacement; - } - HALT_SYS(); - } - return 0; /* SHOULD NOT HAPPEN */ -} - -/**************************************************************************** -PARAMETERS: -rm - RM value to decode - -RETURNS: -Offset in memory for the address decoding - -REMARKS: -Return the offset given by mod=10 addressing. Also enables the -decoding of instructions. -****************************************************************************/ -unsigned decode_rm10_address( - int rm) -{ - if (M.x86.mode & SYSMODE_PREFIX_ADDR) - { - int displacement = (s32)fetch_long_imm(); - switch (rm) - { - case 0: - DECODE_PRINTF2("%d[EAX}", displacement); - return M.x86.R_EAX + displacement; - case 1: - DECODE_PRINTF2("%d[ECX]", displacement); - return M.x86.R_ECX + displacement; - case 2: - DECODE_PRINTF2("%d[EDX]", displacement); - return M.x86.R_EDX + displacement; - case 3: - DECODE_PRINTF2("%d[EBX]", displacement); - return M.x86.R_EBX + displacement; - case 4: - printk("Unsupported SIB addressing mode\n"); - HALT_SYS(); - return 0; - case 5: - DECODE_PRINTF2("%d[EBP]", displacement); - return M.x86.R_EBP + displacement; - case 6: - DECODE_PRINTF2("%d[ESI]", displacement); - return M.x86.R_ESI + displacement; - case 7: - DECODE_PRINTF2("%d[EDI]", displacement); - return M.x86.R_EDI + displacement; - } - } - else - { - int displacement = (s16)fetch_word_imm(); - switch (rm) { - case 0: - DECODE_PRINTF2("%d[BX+SI]", displacement); - return (M.x86.R_BX + M.x86.R_SI + displacement) & 0xffff; - case 1: - DECODE_PRINTF2("%d[BX+DI]", displacement); - return (M.x86.R_BX + M.x86.R_DI + displacement) & 0xffff; - case 2: - DECODE_PRINTF2("%d[BP+SI]", displacement); - M.x86.mode |= SYSMODE_SEG_DS_SS; - return (M.x86.R_BP + M.x86.R_SI + displacement) & 0xffff; - case 3: - DECODE_PRINTF2("%d[BP+DI]", displacement); - M.x86.mode |= SYSMODE_SEG_DS_SS; - return (M.x86.R_BP + M.x86.R_DI + displacement) & 0xffff; - case 4: - DECODE_PRINTF2("%d[SI]", displacement); - return (M.x86.R_SI + displacement) & 0xffff; - case 5: - DECODE_PRINTF2("%d[DI]", displacement); - return (M.x86.R_DI + displacement) & 0xffff; - case 6: - DECODE_PRINTF2("%d[BP]", displacement); - M.x86.mode |= SYSMODE_SEG_DS_SS; - return (M.x86.R_BP + displacement) & 0xffff; - case 7: - DECODE_PRINTF2("%d[BX]", displacement); - return (M.x86.R_BX + displacement) & 0xffff; - } - } - HALT_SYS(); - return 0; - /*NOTREACHED */ -} diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/fpu.c b/board/MAI/bios_emulator/scitech/src/x86emu/fpu.c deleted file mode 100644 index 7f7c345b34..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/fpu.c +++ /dev/null @@ -1,945 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: This file contains the code to implement the decoding and -* emulation of the FPU instructions. -* -****************************************************************************/ - -#include "x86emu/x86emui.h" - -/*----------------------------- Implementation ----------------------------*/ - -/* opcode=0xd8 */ -void x86emuOp_esc_coprocess_d8(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("ESC D8\n"); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR_NO_TRACE(); -} - -#ifdef DEBUG - -static char *x86emu_fpu_op_d9_tab[] = { - "FLD\tDWORD PTR ", "ESC_D9\t", "FST\tDWORD PTR ", "FSTP\tDWORD PTR ", - "FLDENV\t", "FLDCW\t", "FSTENV\t", "FSTCW\t", - - "FLD\tDWORD PTR ", "ESC_D9\t", "FST\tDWORD PTR ", "FSTP\tDWORD PTR ", - "FLDENV\t", "FLDCW\t", "FSTENV\t", "FSTCW\t", - - "FLD\tDWORD PTR ", "ESC_D9\t", "FST\tDWORD PTR ", "FSTP\tDWORD PTR ", - "FLDENV\t", "FLDCW\t", "FSTENV\t", "FSTCW\t", -}; - -static char *x86emu_fpu_op_d9_tab1[] = { - "FLD\t", "FLD\t", "FLD\t", "FLD\t", - "FLD\t", "FLD\t", "FLD\t", "FLD\t", - - "FXCH\t", "FXCH\t", "FXCH\t", "FXCH\t", - "FXCH\t", "FXCH\t", "FXCH\t", "FXCH\t", - - "FNOP", "ESC_D9", "ESC_D9", "ESC_D9", - "ESC_D9", "ESC_D9", "ESC_D9", "ESC_D9", - - "FSTP\t", "FSTP\t", "FSTP\t", "FSTP\t", - "FSTP\t", "FSTP\t", "FSTP\t", "FSTP\t", - - "FCHS", "FABS", "ESC_D9", "ESC_D9", - "FTST", "FXAM", "ESC_D9", "ESC_D9", - - "FLD1", "FLDL2T", "FLDL2E", "FLDPI", - "FLDLG2", "FLDLN2", "FLDZ", "ESC_D9", - - "F2XM1", "FYL2X", "FPTAN", "FPATAN", - "FXTRACT", "ESC_D9", "FDECSTP", "FINCSTP", - - "FPREM", "FYL2XP1", "FSQRT", "ESC_D9", - "FRNDINT", "FSCALE", "ESC_D9", "ESC_D9", -}; - -#endif /* DEBUG */ - -/* opcode=0xd9 */ -void x86emuOp_esc_coprocess_d9(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - u8 stkelem; - - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); -#ifdef DEBUG - if (mod != 3) { - DECODE_PRINTINSTR32(x86emu_fpu_op_d9_tab, mod, rh, rl); - } else { - DECODE_PRINTF(x86emu_fpu_op_d9_tab1[(rh << 3) + rl]); - } -#endif - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - break; - case 3: /* register to register */ - stkelem = (u8)rl; - if (rh < 4) { - DECODE_PRINTF2("ST(%d)\n", stkelem); - } else { - DECODE_PRINTF("\n"); - } - break; - } -#ifdef X86EMU_FPU_PRESENT - /* execute */ - switch (mod) { - case 3: - switch (rh) { - case 0: - x86emu_fpu_R_fld(X86EMU_FPU_STKTOP, stkelem); - break; - case 1: - x86emu_fpu_R_fxch(X86EMU_FPU_STKTOP, stkelem); - break; - case 2: - switch (rl) { - case 0: - x86emu_fpu_R_nop(); - break; - default: - x86emu_fpu_illegal(); - break; - } - case 3: - x86emu_fpu_R_fstp(X86EMU_FPU_STKTOP, stkelem); - break; - case 4: - switch (rl) { - case 0: - x86emu_fpu_R_fchs(X86EMU_FPU_STKTOP); - break; - case 1: - x86emu_fpu_R_fabs(X86EMU_FPU_STKTOP); - break; - case 4: - x86emu_fpu_R_ftst(X86EMU_FPU_STKTOP); - break; - case 5: - x86emu_fpu_R_fxam(X86EMU_FPU_STKTOP); - break; - default: - /* 2,3,6,7 */ - x86emu_fpu_illegal(); - break; - } - break; - - case 5: - switch (rl) { - case 0: - x86emu_fpu_R_fld1(X86EMU_FPU_STKTOP); - break; - case 1: - x86emu_fpu_R_fldl2t(X86EMU_FPU_STKTOP); - break; - case 2: - x86emu_fpu_R_fldl2e(X86EMU_FPU_STKTOP); - break; - case 3: - x86emu_fpu_R_fldpi(X86EMU_FPU_STKTOP); - break; - case 4: - x86emu_fpu_R_fldlg2(X86EMU_FPU_STKTOP); - break; - case 5: - x86emu_fpu_R_fldln2(X86EMU_FPU_STKTOP); - break; - case 6: - x86emu_fpu_R_fldz(X86EMU_FPU_STKTOP); - break; - default: - /* 7 */ - x86emu_fpu_illegal(); - break; - } - break; - - case 6: - switch (rl) { - case 0: - x86emu_fpu_R_f2xm1(X86EMU_FPU_STKTOP); - break; - case 1: - x86emu_fpu_R_fyl2x(X86EMU_FPU_STKTOP); - break; - case 2: - x86emu_fpu_R_fptan(X86EMU_FPU_STKTOP); - break; - case 3: - x86emu_fpu_R_fpatan(X86EMU_FPU_STKTOP); - break; - case 4: - x86emu_fpu_R_fxtract(X86EMU_FPU_STKTOP); - break; - case 5: - x86emu_fpu_illegal(); - break; - case 6: - x86emu_fpu_R_decstp(); - break; - case 7: - x86emu_fpu_R_incstp(); - break; - } - break; - - case 7: - switch (rl) { - case 0: - x86emu_fpu_R_fprem(X86EMU_FPU_STKTOP); - break; - case 1: - x86emu_fpu_R_fyl2xp1(X86EMU_FPU_STKTOP); - break; - case 2: - x86emu_fpu_R_fsqrt(X86EMU_FPU_STKTOP); - break; - case 3: - x86emu_fpu_illegal(); - break; - case 4: - x86emu_fpu_R_frndint(X86EMU_FPU_STKTOP); - break; - case 5: - x86emu_fpu_R_fscale(X86EMU_FPU_STKTOP); - break; - case 6: - case 7: - default: - x86emu_fpu_illegal(); - break; - } - break; - - default: - switch (rh) { - case 0: - x86emu_fpu_M_fld(X86EMU_FPU_FLOAT, destoffset); - break; - case 1: - x86emu_fpu_illegal(); - break; - case 2: - x86emu_fpu_M_fst(X86EMU_FPU_FLOAT, destoffset); - break; - case 3: - x86emu_fpu_M_fstp(X86EMU_FPU_FLOAT, destoffset); - break; - case 4: - x86emu_fpu_M_fldenv(X86EMU_FPU_WORD, destoffset); - break; - case 5: - x86emu_fpu_M_fldcw(X86EMU_FPU_WORD, destoffset); - break; - case 6: - x86emu_fpu_M_fstenv(X86EMU_FPU_WORD, destoffset); - break; - case 7: - x86emu_fpu_M_fstcw(X86EMU_FPU_WORD, destoffset); - break; - } - } - } -#endif /* X86EMU_FPU_PRESENT */ - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR_NO_TRACE(); -} - -#ifdef DEBUG - -char *x86emu_fpu_op_da_tab[] = { - "FIADD\tDWORD PTR ", "FIMUL\tDWORD PTR ", "FICOM\tDWORD PTR ", - "FICOMP\tDWORD PTR ", - "FISUB\tDWORD PTR ", "FISUBR\tDWORD PTR ", "FIDIV\tDWORD PTR ", - "FIDIVR\tDWORD PTR ", - - "FIADD\tDWORD PTR ", "FIMUL\tDWORD PTR ", "FICOM\tDWORD PTR ", - "FICOMP\tDWORD PTR ", - "FISUB\tDWORD PTR ", "FISUBR\tDWORD PTR ", "FIDIV\tDWORD PTR ", - "FIDIVR\tDWORD PTR ", - - "FIADD\tDWORD PTR ", "FIMUL\tDWORD PTR ", "FICOM\tDWORD PTR ", - "FICOMP\tDWORD PTR ", - "FISUB\tDWORD PTR ", "FISUBR\tDWORD PTR ", "FIDIV\tDWORD PTR ", - "FIDIVR\tDWORD PTR ", - - "ESC_DA ", "ESC_DA ", "ESC_DA ", "ESC_DA ", - "ESC_DA ", "ESC_DA ", "ESC_DA ", "ESC_DA ", -}; - -#endif /* DEBUG */ - -/* opcode=0xda */ -void x86emuOp_esc_coprocess_da(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - u8 stkelem; - - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); - DECODE_PRINTINSTR32(x86emu_fpu_op_da_tab, mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - break; - case 3: /* register to register */ - stkelem = (u8)rl; - DECODE_PRINTF2("\tST(%d),ST\n", stkelem); - break; - } -#ifdef X86EMU_FPU_PRESENT - switch (mod) { - case 3: - x86emu_fpu_illegal(); - break; - default: - switch (rh) { - case 0: - x86emu_fpu_M_iadd(X86EMU_FPU_SHORT, destoffset); - break; - case 1: - x86emu_fpu_M_imul(X86EMU_FPU_SHORT, destoffset); - break; - case 2: - x86emu_fpu_M_icom(X86EMU_FPU_SHORT, destoffset); - break; - case 3: - x86emu_fpu_M_icomp(X86EMU_FPU_SHORT, destoffset); - break; - case 4: - x86emu_fpu_M_isub(X86EMU_FPU_SHORT, destoffset); - break; - case 5: - x86emu_fpu_M_isubr(X86EMU_FPU_SHORT, destoffset); - break; - case 6: - x86emu_fpu_M_idiv(X86EMU_FPU_SHORT, destoffset); - break; - case 7: - x86emu_fpu_M_idivr(X86EMU_FPU_SHORT, destoffset); - break; - } - } -#endif - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR_NO_TRACE(); -} - -#ifdef DEBUG - -char *x86emu_fpu_op_db_tab[] = { - "FILD\tDWORD PTR ", "ESC_DB\t19", "FIST\tDWORD PTR ", "FISTP\tDWORD PTR ", - "ESC_DB\t1C", "FLD\tTBYTE PTR ", "ESC_DB\t1E", "FSTP\tTBYTE PTR ", - - "FILD\tDWORD PTR ", "ESC_DB\t19", "FIST\tDWORD PTR ", "FISTP\tDWORD PTR ", - "ESC_DB\t1C", "FLD\tTBYTE PTR ", "ESC_DB\t1E", "FSTP\tTBYTE PTR ", - - "FILD\tDWORD PTR ", "ESC_DB\t19", "FIST\tDWORD PTR ", "FISTP\tDWORD PTR ", - "ESC_DB\t1C", "FLD\tTBYTE PTR ", "ESC_DB\t1E", "FSTP\tTBYTE PTR ", -}; - -#endif /* DEBUG */ - -/* opcode=0xdb */ -void x86emuOp_esc_coprocess_db(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); -#ifdef DEBUG - if (mod != 3) { - DECODE_PRINTINSTR32(x86emu_fpu_op_db_tab, mod, rh, rl); - } else if (rh == 4) { /* === 11 10 0 nnn */ - switch (rl) { - case 0: - DECODE_PRINTF("FENI\n"); - break; - case 1: - DECODE_PRINTF("FDISI\n"); - break; - case 2: - DECODE_PRINTF("FCLEX\n"); - break; - case 3: - DECODE_PRINTF("FINIT\n"); - break; - } - } else { - DECODE_PRINTF2("ESC_DB %0x\n", (mod << 6) + (rh << 3) + (rl)); - } -#endif /* DEBUG */ - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - break; - case 1: - destoffset = decode_rm01_address(rl); - break; - case 2: - destoffset = decode_rm10_address(rl); - break; - case 3: /* register to register */ - break; - } -#ifdef X86EMU_FPU_PRESENT - /* execute */ - switch (mod) { - case 3: - switch (rh) { - case 4: - switch (rl) { - case 0: - x86emu_fpu_R_feni(); - break; - case 1: - x86emu_fpu_R_fdisi(); - break; - case 2: - x86emu_fpu_R_fclex(); - break; - case 3: - x86emu_fpu_R_finit(); - break; - default: - x86emu_fpu_illegal(); - break; - } - break; - default: - x86emu_fpu_illegal(); - break; - } - break; - default: - switch (rh) { - case 0: - x86emu_fpu_M_fild(X86EMU_FPU_SHORT, destoffset); - break; - case 1: - x86emu_fpu_illegal(); - break; - case 2: - x86emu_fpu_M_fist(X86EMU_FPU_SHORT, destoffset); - break; - case 3: - x86emu_fpu_M_fistp(X86EMU_FPU_SHORT, destoffset); - break; - case 4: - x86emu_fpu_illegal(); - break; - case 5: - x86emu_fpu_M_fld(X86EMU_FPU_LDBL, destoffset); - break; - case 6: - x86emu_fpu_illegal(); - break; - case 7: - x86emu_fpu_M_fstp(X86EMU_FPU_LDBL, destoffset); - break; - } - } -#endif - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR_NO_TRACE(); -} - -#ifdef DEBUG -char *x86emu_fpu_op_dc_tab[] = { - "FADD\tQWORD PTR ", "FMUL\tQWORD PTR ", "FCOM\tQWORD PTR ", - "FCOMP\tQWORD PTR ", - "FSUB\tQWORD PTR ", "FSUBR\tQWORD PTR ", "FDIV\tQWORD PTR ", - "FDIVR\tQWORD PTR ", - - "FADD\tQWORD PTR ", "FMUL\tQWORD PTR ", "FCOM\tQWORD PTR ", - "FCOMP\tQWORD PTR ", - "FSUB\tQWORD PTR ", "FSUBR\tQWORD PTR ", "FDIV\tQWORD PTR ", - "FDIVR\tQWORD PTR ", - - "FADD\tQWORD PTR ", "FMUL\tQWORD PTR ", "FCOM\tQWORD PTR ", - "FCOMP\tQWORD PTR ", - "FSUB\tQWORD PTR ", "FSUBR\tQWORD PTR ", "FDIV\tQWORD PTR ", - "FDIVR\tQWORD PTR ", - - "FADD\t", "FMUL\t", "FCOM\t", "FCOMP\t", - "FSUBR\t", "FSUB\t", "FDIVR\t", "FDIV\t", -}; -#endif /* DEBUG */ - -/* opcode=0xdc */ -void x86emuOp_esc_coprocess_dc(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - u8 stkelem; - - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); - DECODE_PRINTINSTR32(x86emu_fpu_op_dc_tab, mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - break; - case 3: /* register to register */ - stkelem = (u8)rl; - DECODE_PRINTF2("\tST(%d),ST\n", stkelem); - break; - } -#ifdef X86EMU_FPU_PRESENT - /* execute */ - switch (mod) { - case 3: - switch (rh) { - case 0: - x86emu_fpu_R_fadd(stkelem, X86EMU_FPU_STKTOP); - break; - case 1: - x86emu_fpu_R_fmul(stkelem, X86EMU_FPU_STKTOP); - break; - case 2: - x86emu_fpu_R_fcom(stkelem, X86EMU_FPU_STKTOP); - break; - case 3: - x86emu_fpu_R_fcomp(stkelem, X86EMU_FPU_STKTOP); - break; - case 4: - x86emu_fpu_R_fsubr(stkelem, X86EMU_FPU_STKTOP); - break; - case 5: - x86emu_fpu_R_fsub(stkelem, X86EMU_FPU_STKTOP); - break; - case 6: - x86emu_fpu_R_fdivr(stkelem, X86EMU_FPU_STKTOP); - break; - case 7: - x86emu_fpu_R_fdiv(stkelem, X86EMU_FPU_STKTOP); - break; - } - break; - default: - switch (rh) { - case 0: - x86emu_fpu_M_fadd(X86EMU_FPU_DOUBLE, destoffset); - break; - case 1: - x86emu_fpu_M_fmul(X86EMU_FPU_DOUBLE, destoffset); - break; - case 2: - x86emu_fpu_M_fcom(X86EMU_FPU_DOUBLE, destoffset); - break; - case 3: - x86emu_fpu_M_fcomp(X86EMU_FPU_DOUBLE, destoffset); - break; - case 4: - x86emu_fpu_M_fsub(X86EMU_FPU_DOUBLE, destoffset); - break; - case 5: - x86emu_fpu_M_fsubr(X86EMU_FPU_DOUBLE, destoffset); - break; - case 6: - x86emu_fpu_M_fdiv(X86EMU_FPU_DOUBLE, destoffset); - break; - case 7: - x86emu_fpu_M_fdivr(X86EMU_FPU_DOUBLE, destoffset); - break; - } - } -#endif - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR_NO_TRACE(); -} - -#ifdef DEBUG - -static char *x86emu_fpu_op_dd_tab[] = { - "FLD\tQWORD PTR ", "ESC_DD\t29,", "FST\tQWORD PTR ", "FSTP\tQWORD PTR ", - "FRSTOR\t", "ESC_DD\t2D,", "FSAVE\t", "FSTSW\t", - - "FLD\tQWORD PTR ", "ESC_DD\t29,", "FST\tQWORD PTR ", "FSTP\tQWORD PTR ", - "FRSTOR\t", "ESC_DD\t2D,", "FSAVE\t", "FSTSW\t", - - "FLD\tQWORD PTR ", "ESC_DD\t29,", "FST\tQWORD PTR ", "FSTP\tQWORD PTR ", - "FRSTOR\t", "ESC_DD\t2D,", "FSAVE\t", "FSTSW\t", - - "FFREE\t", "FXCH\t", "FST\t", "FSTP\t", - "ESC_DD\t2C,", "ESC_DD\t2D,", "ESC_DD\t2E,", "ESC_DD\t2F,", -}; - -#endif /* DEBUG */ - -/* opcode=0xdd */ -void x86emuOp_esc_coprocess_dd(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - u8 stkelem; - - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); - DECODE_PRINTINSTR32(x86emu_fpu_op_dd_tab, mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - break; - case 3: /* register to register */ - stkelem = (u8)rl; - DECODE_PRINTF2("\tST(%d),ST\n", stkelem); - break; - } -#ifdef X86EMU_FPU_PRESENT - switch (mod) { - case 3: - switch (rh) { - case 0: - x86emu_fpu_R_ffree(stkelem); - break; - case 1: - x86emu_fpu_R_fxch(stkelem); - break; - case 2: - x86emu_fpu_R_fst(stkelem); /* register version */ - break; - case 3: - x86emu_fpu_R_fstp(stkelem); /* register version */ - break; - default: - x86emu_fpu_illegal(); - break; - } - break; - default: - switch (rh) { - case 0: - x86emu_fpu_M_fld(X86EMU_FPU_DOUBLE, destoffset); - break; - case 1: - x86emu_fpu_illegal(); - break; - case 2: - x86emu_fpu_M_fst(X86EMU_FPU_DOUBLE, destoffset); - break; - case 3: - x86emu_fpu_M_fstp(X86EMU_FPU_DOUBLE, destoffset); - break; - case 4: - x86emu_fpu_M_frstor(X86EMU_FPU_WORD, destoffset); - break; - case 5: - x86emu_fpu_illegal(); - break; - case 6: - x86emu_fpu_M_fsave(X86EMU_FPU_WORD, destoffset); - break; - case 7: - x86emu_fpu_M_fstsw(X86EMU_FPU_WORD, destoffset); - break; - } - } -#endif - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR_NO_TRACE(); -} - -#ifdef DEBUG - -static char *x86emu_fpu_op_de_tab[] = -{ - "FIADD\tWORD PTR ", "FIMUL\tWORD PTR ", "FICOM\tWORD PTR ", - "FICOMP\tWORD PTR ", - "FISUB\tWORD PTR ", "FISUBR\tWORD PTR ", "FIDIV\tWORD PTR ", - "FIDIVR\tWORD PTR ", - - "FIADD\tWORD PTR ", "FIMUL\tWORD PTR ", "FICOM\tWORD PTR ", - "FICOMP\tWORD PTR ", - "FISUB\tWORD PTR ", "FISUBR\tWORD PTR ", "FIDIV\tWORD PTR ", - "FIDIVR\tWORD PTR ", - - "FIADD\tWORD PTR ", "FIMUL\tWORD PTR ", "FICOM\tWORD PTR ", - "FICOMP\tWORD PTR ", - "FISUB\tWORD PTR ", "FISUBR\tWORD PTR ", "FIDIV\tWORD PTR ", - "FIDIVR\tWORD PTR ", - - "FADDP\t", "FMULP\t", "FCOMP\t", "FCOMPP\t", - "FSUBRP\t", "FSUBP\t", "FDIVRP\t", "FDIVP\t", -}; - -#endif /* DEBUG */ - -/* opcode=0xde */ -void x86emuOp_esc_coprocess_de(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - u8 stkelem; - - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); - DECODE_PRINTINSTR32(x86emu_fpu_op_de_tab, mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - break; - case 3: /* register to register */ - stkelem = (u8)rl; - DECODE_PRINTF2("\tST(%d),ST\n", stkelem); - break; - } -#ifdef X86EMU_FPU_PRESENT - switch (mod) { - case 3: - switch (rh) { - case 0: - x86emu_fpu_R_faddp(stkelem, X86EMU_FPU_STKTOP); - break; - case 1: - x86emu_fpu_R_fmulp(stkelem, X86EMU_FPU_STKTOP); - break; - case 2: - x86emu_fpu_R_fcomp(stkelem, X86EMU_FPU_STKTOP); - break; - case 3: - if (stkelem == 1) - x86emu_fpu_R_fcompp(stkelem, X86EMU_FPU_STKTOP); - else - x86emu_fpu_illegal(); - break; - case 4: - x86emu_fpu_R_fsubrp(stkelem, X86EMU_FPU_STKTOP); - break; - case 5: - x86emu_fpu_R_fsubp(stkelem, X86EMU_FPU_STKTOP); - break; - case 6: - x86emu_fpu_R_fdivrp(stkelem, X86EMU_FPU_STKTOP); - break; - case 7: - x86emu_fpu_R_fdivp(stkelem, X86EMU_FPU_STKTOP); - break; - } - break; - default: - switch (rh) { - case 0: - x86emu_fpu_M_fiadd(X86EMU_FPU_WORD, destoffset); - break; - case 1: - x86emu_fpu_M_fimul(X86EMU_FPU_WORD, destoffset); - break; - case 2: - x86emu_fpu_M_ficom(X86EMU_FPU_WORD, destoffset); - break; - case 3: - x86emu_fpu_M_ficomp(X86EMU_FPU_WORD, destoffset); - break; - case 4: - x86emu_fpu_M_fisub(X86EMU_FPU_WORD, destoffset); - break; - case 5: - x86emu_fpu_M_fisubr(X86EMU_FPU_WORD, destoffset); - break; - case 6: - x86emu_fpu_M_fidiv(X86EMU_FPU_WORD, destoffset); - break; - case 7: - x86emu_fpu_M_fidivr(X86EMU_FPU_WORD, destoffset); - break; - } - } -#endif - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR_NO_TRACE(); -} - -#ifdef DEBUG - -static char *x86emu_fpu_op_df_tab[] = { - /* mod == 00 */ - "FILD\tWORD PTR ", "ESC_DF\t39\n", "FIST\tWORD PTR ", "FISTP\tWORD PTR ", - "FBLD\tTBYTE PTR ", "FILD\tQWORD PTR ", "FBSTP\tTBYTE PTR ", - "FISTP\tQWORD PTR ", - - /* mod == 01 */ - "FILD\tWORD PTR ", "ESC_DF\t39 ", "FIST\tWORD PTR ", "FISTP\tWORD PTR ", - "FBLD\tTBYTE PTR ", "FILD\tQWORD PTR ", "FBSTP\tTBYTE PTR ", - "FISTP\tQWORD PTR ", - - /* mod == 10 */ - "FILD\tWORD PTR ", "ESC_DF\t39 ", "FIST\tWORD PTR ", "FISTP\tWORD PTR ", - "FBLD\tTBYTE PTR ", "FILD\tQWORD PTR ", "FBSTP\tTBYTE PTR ", - "FISTP\tQWORD PTR ", - - /* mod == 11 */ - "FFREE\t", "FXCH\t", "FST\t", "FSTP\t", - "ESC_DF\t3C,", "ESC_DF\t3D,", "ESC_DF\t3E,", "ESC_DF\t3F," -}; - -#endif /* DEBUG */ - -/* opcode=0xdf */ -void x86emuOp_esc_coprocess_df(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - u8 stkelem; - - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); - DECODE_PRINTINSTR32(x86emu_fpu_op_df_tab, mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - break; - case 3: /* register to register */ - stkelem = (u8)rl; - DECODE_PRINTF2("\tST(%d)\n", stkelem); - break; - } -#ifdef X86EMU_FPU_PRESENT - switch (mod) { - case 3: - switch (rh) { - case 0: - x86emu_fpu_R_ffree(stkelem); - break; - case 1: - x86emu_fpu_R_fxch(stkelem); - break; - case 2: - x86emu_fpu_R_fst(stkelem); /* register version */ - break; - case 3: - x86emu_fpu_R_fstp(stkelem); /* register version */ - break; - default: - x86emu_fpu_illegal(); - break; - } - break; - default: - switch (rh) { - case 0: - x86emu_fpu_M_fild(X86EMU_FPU_WORD, destoffset); - break; - case 1: - x86emu_fpu_illegal(); - break; - case 2: - x86emu_fpu_M_fist(X86EMU_FPU_WORD, destoffset); - break; - case 3: - x86emu_fpu_M_fistp(X86EMU_FPU_WORD, destoffset); - break; - case 4: - x86emu_fpu_M_fbld(X86EMU_FPU_BSD, destoffset); - break; - case 5: - x86emu_fpu_M_fild(X86EMU_FPU_LONG, destoffset); - break; - case 6: - x86emu_fpu_M_fbstp(X86EMU_FPU_BSD, destoffset); - break; - case 7: - x86emu_fpu_M_fistp(X86EMU_FPU_LONG, destoffset); - break; - } - } -#endif - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR_NO_TRACE(); -} diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/makefile b/board/MAI/bios_emulator/scitech/src/x86emu/makefile deleted file mode 100644 index 8ce2e9e848..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/makefile +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################# -# -# Realmode X86 Emulator Library -# -# Copyright (C) 1996-1999 SciTech Software, Inc. -# -# ======================================================================== -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, -# provided that the above copyright notice appear in all copies and that -# both that copyright notice and this permission notice appear in -# supporting documentation, and that the name of the authors not be used -# in advertising or publicity pertaining to distribution of the software -# without specific, written prior permission. The authors makes no -# representations about the suitability of this software for any purpose. -# It is provided "as is" without express or implied warranty. -# -# THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -# EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. -# -# ======================================================================== -# -# Descripton: Generic makefile for the x86emu library. Requires -# the SciTech Software makefile definitions package to be -# installed, which uses the DMAKE make program. -# -############################################################################# - -.IMPORT .IGNORE: DEBUG - -#---------------------------------------------------------------------------- -# Define the lists of object files -#---------------------------------------------------------------------------- - -OBJECTS = sys$O decode$O ops$O ops2$O prim_ops$O fpu$O debug$O -CFLAGS += -DSCITECH -.IF $(DEBUG) -CFLAGS += -DDEBUG -.ENDIF -LIBCLEAN = *.dll *.lib *.a -LIBFILE = $(LP)x86emu$L - -#---------------------------------------------------------------------------- -# Sample test programs -#---------------------------------------------------------------------------- - -all: $(LIBFILE) - -validate$E: validate$O $(LIBFILE) - -#---------------------------------------------------------------------------- -# Define the list of object files to create dependency information for -#---------------------------------------------------------------------------- - -DEPEND_OBJ = validate$O $(OBJECTS) - -.INCLUDE: "$(SCITECH)/makedefs/common.mk" diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/makefile.cross b/board/MAI/bios_emulator/scitech/src/x86emu/makefile.cross deleted file mode 100644 index 0bce9a96e5..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/makefile.cross +++ /dev/null @@ -1,82 +0,0 @@ -############################################################################# -# -# Realmode X86 Emulator Library -# -# Copyright (C) 1996-1999 SciTech Software, Inc. -# -# ======================================================================== -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, -# provided that the above copyright notice appear in all copies and that -# both that copyright notice and this permission notice appear in -# supporting documentation, and that the name of the authors not be used -# in advertising or publicity pertaining to distribution of the software -# without specific, written prior permission. The authors makes no -# representations about the suitability of this software for any purpose. -# It is provided "as is" without express or implied warranty. -# -# THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -# EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. -# -# ======================================================================== -# -# Descripton: Linux specific makefile for the x86emu library. -# -############################################################################# - -CC = $(CROSS_COMPILE)gcc -AR = $(CROSS_COMPILE)ar - -TARGETLIB = libx86emu.a -TARGETDEBUGLIB =libx86emud.a - -OBJS=\ -decode.o \ -fpu.o \ -ops.o \ -ops2.o \ -prim_ops.o \ -sys.o - -DEBUGOBJS=debug.d \ - decode.d \ - fpu.d \ - ops.d \ - ops2.d \ - prim_ops.d \ - sys.d - -.SUFFIXES: .d - -all: $(TARGETLIB) $(TARGETDEBUGLIB) - -$(TARGETLIB): $(OBJS) - $(AR) rv $(TARGETLIB) $(OBJS) - -$(TARGETDEBUGLIB): $(DEBUGOBJS) - $(AR) rv $(TARGETDEBUGLIB) $(DEBUGOBJS) - -INCS = -I. -Ix86emu -I../../include -CFLAGS = -D__DRIVER__ -DFORCE_POST -D_CEXPORT= -DNO_LONG_LONG -Dprintk=printf -fsigned-char -fomit-frame-pointer -fPIC -ffixed-r14 -meabi -CDEBUGFLAGS = -DDEBUG - -.c.o: - $(CC) -g -O2 -Wall -c $(CFLAGS) $(INCS) $*.c - -.c.d: - $(CC) -g -O2 -Wall -c -o$*.d $(CFLAGS) $(CDEBUGFLAGS) $(INCS) $*.c - -.cpp.o: - $(CC) -c $(CFLAGS) $(INCS) $*.cpp - -clean: - rm -f *.a *.o *.d - -validate: validate.o libx86emu.a - $(CC) -o validate validate.o -lx86emu -L. diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/makefile.linux b/board/MAI/bios_emulator/scitech/src/x86emu/makefile.linux deleted file mode 100644 index f74b88d4c8..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/makefile.linux +++ /dev/null @@ -1,81 +0,0 @@ -############################################################################# -# -# Realmode X86 Emulator Library -# -# Copyright (C) 1996-1999 SciTech Software, Inc. -# -# ======================================================================== -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, -# provided that the above copyright notice appear in all copies and that -# both that copyright notice and this permission notice appear in -# supporting documentation, and that the name of the authors not be used -# in advertising or publicity pertaining to distribution of the software -# without specific, written prior permission. The authors makes no -# representations about the suitability of this software for any purpose. -# It is provided "as is" without express or implied warranty. -# -# THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -# EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. -# -# ======================================================================== -# -# Descripton: Linux specific makefile for the x86emu library. -# -############################################################################# - -TARGETLIB = libx86emu.a -TARGETDEBUGLIB =libx86emud.a - -OBJS=\ -decode.o \ -fpu.o \ -ops.o \ -ops2.o \ -prim_ops.o \ -pregs.o \ -sys.o - -DEBUGOBJS=debug.d \ - decode.d \ - fpu.d \ - ops.d \ - ops2.d \ - prim_ops.d \ - pregs.d \ - sys.d - -.SUFFIXES: .d - -all: $(TARGETLIB) $(TARGETDEBUGLIB) - -$(TARGETLIB): $(OBJS) - ar rv $(TARGETLIB) $(OBJS) - -$(TARGETDEBUGLIB): $(DEBUGOBJS) - ar rv $(TARGETDEBUGLIB) $(DEBUGOBJS) - -INCS = -I. -Ix86emu -I../../include -CFLAGS = -D__DRIVER__ -DFORCE_POST -D_CEXPORT= -DNO_LONG_LONG -CDEBUGFLAGS = -DDEBUG - -.c.o: - gcc -g -O -Wall -c $(CFLAGS) $(INCS) $*.c - -.c.d: - gcc -g -O -Wall -c -o$*.d $(CFLAGS) $(CDEBUGFLAGS) $(INCS) $*.c - -.cpp.o: - gcc -c $(CFLAGS) $(INCS) $*.cpp - -clean: - rm -f *.a *.o *.d - -validate: validate.o libx86emu.a - gcc -o validate validate.o -lx86emu -L. diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/makefile.uboot b/board/MAI/bios_emulator/scitech/src/x86emu/makefile.uboot deleted file mode 100644 index af9ae1f589..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/makefile.uboot +++ /dev/null @@ -1,80 +0,0 @@ -############################################################################# -# -# Realmode X86 Emulator Library -# -# Copyright (C) 1996-1999 SciTech Software, Inc. -# -# ======================================================================== -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, -# provided that the above copyright notice appear in all copies and that -# both that copyright notice and this permission notice appear in -# supporting documentation, and that the name of the authors not be used -# in advertising or publicity pertaining to distribution of the software -# without specific, written prior permission. The authors makes no -# representations about the suitability of this software for any purpose. -# It is provided "as is" without express or implied warranty. -# -# THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -# EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. -# -# ======================================================================== -# -# Descripton: Linux specific makefile for the x86emu library. -# -############################################################################# -CC = $(CROSS_COMPILE)gcc -AR = $(CROSS_COMPILE)ar -TARGETLIB = libx86emu.a -TARGETDEBUGLIB =libx86emud.a - -OBJS=\ -decode.o \ -fpu.o \ -ops.o \ -ops2.o \ -prim_ops.o \ -sys.o - -DEBUGOBJS=debug.d \ - decode.d \ - fpu.d \ - ops.d \ - ops2.d \ - prim_ops.d \ - sys.d - -.SUFFIXES: .d - -all: $(TARGETLIB) $(TARGETDEBUGLIB) - -$(TARGETLIB): $(OBJS) - $(AR) rv $(TARGETLIB) $(OBJS) - -$(TARGETDEBUGLIB): $(DEBUGOBJS) - $(AR) rv $(TARGETDEBUGLIB) $(DEBUGOBJS) - -INCS = -I. -Ix86emu -I../../include -CFLAGS = -D__DRIVER__ -DFORCE_POST -D_CEXPORT= -DNO_LONG_LONG -Dprintk=printf -fsigned-char -fomit-frame-pointer -fPIC -ffixed-r14 -meabi -CDEBUGFLAGS = -DDEBUG - -.c.o: - $(CC) -g -O2 -Wall -c $(CFLAGS) $(INCS) $*.c - -.c.d: - $(CC) -g -O2 -Wall -c -o$*.d $(CFLAGS) $(CDEBUGFLAGS) $(INCS) $*.c - -.cpp.o: - $(CC) -c $(CFLAGS) $(INCS) $*.cpp - -clean: - rm -f *.a *.o *.d - -validate: validate.o libx86emu.a - $(CC) -o validate validate.o -lx86emu -L. diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/ops.c b/board/MAI/bios_emulator/scitech/src/x86emu/ops.c deleted file mode 100644 index 2d4f93eee4..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/ops.c +++ /dev/null @@ -1,11701 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: This file includes subroutines to implement the decoding -* and emulation of all the x86 processor instructions. -* -* There are approximately 250 subroutines in here, which correspond -* to the 256 byte-"opcodes" found on the 8086. The table which -* dispatches this is found in the files optab.[ch]. -* -* Each opcode proc has a comment preceeding it which gives it's table -* address. Several opcodes are missing (undefined) in the table. -* -* Each proc includes information for decoding (DECODE_PRINTF and -* DECODE_PRINTF2), debugging (TRACE_REGS, SINGLE_STEP), and misc -* functions (START_OF_INSTR, END_OF_INSTR). -* -* Many of the procedures are *VERY* similar in coding. This has -* allowed for a very large amount of code to be generated in a fairly -* short amount of time (i.e. cut, paste, and modify). The result is -* that much of the code below could have been folded into subroutines -* for a large reduction in size of this file. The downside would be -* that there would be a penalty in execution speed. The file could -* also have been *MUCH* larger by inlining certain functions which -* were called. This could have resulted even faster execution. The -* prime directive I used to decide whether to inline the code or to -* modularize it, was basically: 1) no unnecessary subroutine calls, -* 2) no routines more than about 200 lines in size, and 3) modularize -* any code that I might not get right the first time. The fetch_* -* subroutines fall into the latter category. The The decode_* fall -* into the second category. The coding of the "switch(mod){ .... }" -* in many of the subroutines below falls into the first category. -* Especially, the coding of {add,and,or,sub,...}_{byte,word} -* subroutines are an especially glaring case of the third guideline. -* Since so much of the code is cloned from other modules (compare -* opcode #00 to opcode #01), making the basic operations subroutine -* calls is especially important; otherwise mistakes in coding an -* "add" would represent a nightmare in maintenance. -* -****************************************************************************/ - -#include "x86emu/x86emui.h" - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -PARAMETERS: -op1 - Instruction op code - -REMARKS: -Handles illegal opcodes. -****************************************************************************/ -void x86emuOp_illegal_op( - u8 op1) -{ - START_OF_INSTR(); - DECODE_PRINTF("ILLEGAL X86 OPCODE\n"); - TRACE_REGS(); - printk("%04x:%04x: %02X ILLEGAL X86 OPCODE!\n", - M.x86.R_CS, M.x86.R_IP-1,op1); - HALT_SYS(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x00 -****************************************************************************/ -void x86emuOp_add_byte_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - u8 *destreg, *srcreg; - u8 destval; - - START_OF_INSTR(); - DECODE_PRINTF("ADD\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = add_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = add_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = add_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = add_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x01 -****************************************************************************/ -void x86emuOp_add_word_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("ADD\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = add_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = add_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = add_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = add_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = add_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = add_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = add_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = add_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x02 -****************************************************************************/ -void x86emuOp_add_byte_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint srcoffset; - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("ADD\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = add_byte(*destreg, srcval); - break; - case 1: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = add_byte(*destreg, srcval); - break; - case 2: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = add_byte(*destreg, srcval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = add_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x03 -****************************************************************************/ -void x86emuOp_add_word_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("ADD\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = add_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = add_word(*destreg, srcval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = add_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = add_word(*destreg, srcval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = add_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = add_word(*destreg, srcval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = add_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = add_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x04 -****************************************************************************/ -void x86emuOp_add_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("ADD\tAL,"); - srcval = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - M.x86.R_AL = add_byte(M.x86.R_AL, srcval); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x05 -****************************************************************************/ -void x86emuOp_add_word_AX_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("ADD\tEAX,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("ADD\tAX,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EAX = add_long(M.x86.R_EAX, srcval); - } else { - M.x86.R_AX = add_word(M.x86.R_AX, (u16)srcval); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x06 -****************************************************************************/ -void x86emuOp_push_ES(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("PUSH\tES\n"); - TRACE_AND_STEP(); - push_word(M.x86.R_ES); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x07 -****************************************************************************/ -void x86emuOp_pop_ES(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("POP\tES\n"); - TRACE_AND_STEP(); - M.x86.R_ES = pop_word(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x08 -****************************************************************************/ -void x86emuOp_or_byte_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint destoffset; - u8 destval; - - START_OF_INSTR(); - DECODE_PRINTF("OR\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = or_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = or_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = or_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = or_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x09 -****************************************************************************/ -void x86emuOp_or_word_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("OR\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = or_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = or_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = or_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = or_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = or_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = or_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = or_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = or_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0a -****************************************************************************/ -void x86emuOp_or_byte_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint srcoffset; - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("OR\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = or_byte(*destreg, srcval); - break; - case 1: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = or_byte(*destreg, srcval); - break; - case 2: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = or_byte(*destreg, srcval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = or_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0b -****************************************************************************/ -void x86emuOp_or_word_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("OR\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = or_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = or_word(*destreg, srcval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = or_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = or_word(*destreg, srcval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = or_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = or_word(*destreg, srcval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = or_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = or_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0c -****************************************************************************/ -void x86emuOp_or_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("OR\tAL,"); - srcval = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - M.x86.R_AL = or_byte(M.x86.R_AL, srcval); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0d -****************************************************************************/ -void x86emuOp_or_word_AX_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("OR\tEAX,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("OR\tAX,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EAX = or_long(M.x86.R_EAX, srcval); - } else { - M.x86.R_AX = or_word(M.x86.R_AX, (u16)srcval); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0e -****************************************************************************/ -void x86emuOp_push_CS(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("PUSH\tCS\n"); - TRACE_AND_STEP(); - push_word(M.x86.R_CS); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f. Escape for two-byte opcode (286 or better) -****************************************************************************/ -void x86emuOp_two_byte(u8 X86EMU_UNUSED(op1)) -{ - u8 op2 = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++)); - INC_DECODED_INST_LEN(1); - (*x86emu_optab2[op2])(op2); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x10 -****************************************************************************/ -void x86emuOp_adc_byte_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint destoffset; - u8 destval; - - START_OF_INSTR(); - DECODE_PRINTF("ADC\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = adc_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = adc_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = adc_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = adc_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x11 -****************************************************************************/ -void x86emuOp_adc_word_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("ADC\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = adc_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = adc_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = adc_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = adc_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = adc_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = adc_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = adc_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = adc_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x12 -****************************************************************************/ -void x86emuOp_adc_byte_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint srcoffset; - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("ADC\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = adc_byte(*destreg, srcval); - break; - case 1: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = adc_byte(*destreg, srcval); - break; - case 2: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = adc_byte(*destreg, srcval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = adc_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x13 -****************************************************************************/ -void x86emuOp_adc_word_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("ADC\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = adc_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = adc_word(*destreg, srcval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = adc_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = adc_word(*destreg, srcval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = adc_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = adc_word(*destreg, srcval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = adc_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = adc_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x14 -****************************************************************************/ -void x86emuOp_adc_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("ADC\tAL,"); - srcval = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - M.x86.R_AL = adc_byte(M.x86.R_AL, srcval); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x15 -****************************************************************************/ -void x86emuOp_adc_word_AX_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("ADC\tEAX,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("ADC\tAX,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EAX = adc_long(M.x86.R_EAX, srcval); - } else { - M.x86.R_AX = adc_word(M.x86.R_AX, (u16)srcval); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x16 -****************************************************************************/ -void x86emuOp_push_SS(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("PUSH\tSS\n"); - TRACE_AND_STEP(); - push_word(M.x86.R_SS); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x17 -****************************************************************************/ -void x86emuOp_pop_SS(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("POP\tSS\n"); - TRACE_AND_STEP(); - M.x86.R_SS = pop_word(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x18 -****************************************************************************/ -void x86emuOp_sbb_byte_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint destoffset; - u8 destval; - - START_OF_INSTR(); - DECODE_PRINTF("SBB\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sbb_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sbb_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sbb_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sbb_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x19 -****************************************************************************/ -void x86emuOp_sbb_word_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("SBB\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sbb_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sbb_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sbb_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sbb_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sbb_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sbb_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sbb_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sbb_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x1a -****************************************************************************/ -void x86emuOp_sbb_byte_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint srcoffset; - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("SBB\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sbb_byte(*destreg, srcval); - break; - case 1: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sbb_byte(*destreg, srcval); - break; - case 2: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sbb_byte(*destreg, srcval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sbb_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x1b -****************************************************************************/ -void x86emuOp_sbb_word_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("SBB\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sbb_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sbb_word(*destreg, srcval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sbb_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sbb_word(*destreg, srcval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sbb_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sbb_word(*destreg, srcval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sbb_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sbb_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x1c -****************************************************************************/ -void x86emuOp_sbb_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("SBB\tAL,"); - srcval = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - M.x86.R_AL = sbb_byte(M.x86.R_AL, srcval); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x1d -****************************************************************************/ -void x86emuOp_sbb_word_AX_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("SBB\tEAX,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("SBB\tAX,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EAX = sbb_long(M.x86.R_EAX, srcval); - } else { - M.x86.R_AX = sbb_word(M.x86.R_AX, (u16)srcval); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x1e -****************************************************************************/ -void x86emuOp_push_DS(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("PUSH\tDS\n"); - TRACE_AND_STEP(); - push_word(M.x86.R_DS); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x1f -****************************************************************************/ -void x86emuOp_pop_DS(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("POP\tDS\n"); - TRACE_AND_STEP(); - M.x86.R_DS = pop_word(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x20 -****************************************************************************/ -void x86emuOp_and_byte_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint destoffset; - u8 destval; - - START_OF_INSTR(); - DECODE_PRINTF("AND\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = and_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = and_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = and_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = and_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x21 -****************************************************************************/ -void x86emuOp_and_word_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("AND\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = and_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = and_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = and_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = and_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = and_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = and_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = and_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = and_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x22 -****************************************************************************/ -void x86emuOp_and_byte_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint srcoffset; - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("AND\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = and_byte(*destreg, srcval); - break; - case 1: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = and_byte(*destreg, srcval); - break; - case 2: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = and_byte(*destreg, srcval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = and_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x23 -****************************************************************************/ -void x86emuOp_and_word_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("AND\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = and_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = and_word(*destreg, srcval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = and_long(*destreg, srcval); - break; - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = and_word(*destreg, srcval); - break; - } - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = and_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = and_word(*destreg, srcval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = and_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = and_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x24 -****************************************************************************/ -void x86emuOp_and_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("AND\tAL,"); - srcval = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - M.x86.R_AL = and_byte(M.x86.R_AL, srcval); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x25 -****************************************************************************/ -void x86emuOp_and_word_AX_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("AND\tEAX,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("AND\tAX,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EAX = and_long(M.x86.R_EAX, srcval); - } else { - M.x86.R_AX = and_word(M.x86.R_AX, (u16)srcval); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x26 -****************************************************************************/ -void x86emuOp_segovr_ES(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("ES:\n"); - TRACE_AND_STEP(); - M.x86.mode |= SYSMODE_SEGOVR_ES; - /* - * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4 - * opcode subroutines we do not want to do this. - */ - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x27 -****************************************************************************/ -void x86emuOp_daa(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("DAA\n"); - TRACE_AND_STEP(); - M.x86.R_AL = daa_byte(M.x86.R_AL); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x28 -****************************************************************************/ -void x86emuOp_sub_byte_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint destoffset; - u8 destval; - - START_OF_INSTR(); - DECODE_PRINTF("SUB\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sub_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sub_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sub_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sub_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x29 -****************************************************************************/ -void x86emuOp_sub_word_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("SUB\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sub_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sub_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sub_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sub_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sub_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = sub_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sub_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sub_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x2a -****************************************************************************/ -void x86emuOp_sub_byte_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint srcoffset; - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("SUB\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sub_byte(*destreg, srcval); - break; - case 1: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sub_byte(*destreg, srcval); - break; - case 2: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sub_byte(*destreg, srcval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sub_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x2b -****************************************************************************/ -void x86emuOp_sub_word_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("SUB\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sub_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sub_word(*destreg, srcval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sub_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sub_word(*destreg, srcval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sub_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sub_word(*destreg, srcval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sub_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = sub_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x2c -****************************************************************************/ -void x86emuOp_sub_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("SUB\tAL,"); - srcval = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - M.x86.R_AL = sub_byte(M.x86.R_AL, srcval); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x2d -****************************************************************************/ -void x86emuOp_sub_word_AX_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("SUB\tEAX,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("SUB\tAX,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EAX = sub_long(M.x86.R_EAX, srcval); - } else { - M.x86.R_AX = sub_word(M.x86.R_AX, (u16)srcval); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x2e -****************************************************************************/ -void x86emuOp_segovr_CS(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("CS:\n"); - TRACE_AND_STEP(); - M.x86.mode |= SYSMODE_SEGOVR_CS; - /* note no DECODE_CLEAR_SEGOVR here. */ - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x2f -****************************************************************************/ -void x86emuOp_das(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("DAS\n"); - TRACE_AND_STEP(); - M.x86.R_AL = das_byte(M.x86.R_AL); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x30 -****************************************************************************/ -void x86emuOp_xor_byte_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint destoffset; - u8 destval; - - START_OF_INSTR(); - DECODE_PRINTF("XOR\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = xor_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = xor_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = xor_byte(destval, *srcreg); - store_data_byte(destoffset, destval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = xor_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x31 -****************************************************************************/ -void x86emuOp_xor_word_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("XOR\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = xor_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = xor_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = xor_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = xor_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = xor_long(destval, *srcreg); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = xor_word(destval, *srcreg); - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = xor_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = xor_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x32 -****************************************************************************/ -void x86emuOp_xor_byte_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint srcoffset; - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("XOR\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = xor_byte(*destreg, srcval); - break; - case 1: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = xor_byte(*destreg, srcval); - break; - case 2: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = xor_byte(*destreg, srcval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = xor_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x33 -****************************************************************************/ -void x86emuOp_xor_word_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("XOR\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = xor_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = xor_word(*destreg, srcval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = xor_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = xor_word(*destreg, srcval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = xor_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = xor_word(*destreg, srcval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = xor_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = xor_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x34 -****************************************************************************/ -void x86emuOp_xor_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("XOR\tAL,"); - srcval = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - M.x86.R_AL = xor_byte(M.x86.R_AL, srcval); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x35 -****************************************************************************/ -void x86emuOp_xor_word_AX_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("XOR\tEAX,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("XOR\tAX,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EAX = xor_long(M.x86.R_EAX, srcval); - } else { - M.x86.R_AX = xor_word(M.x86.R_AX, (u16)srcval); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x36 -****************************************************************************/ -void x86emuOp_segovr_SS(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("SS:\n"); - TRACE_AND_STEP(); - M.x86.mode |= SYSMODE_SEGOVR_SS; - /* no DECODE_CLEAR_SEGOVR ! */ - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x37 -****************************************************************************/ -void x86emuOp_aaa(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("AAA\n"); - TRACE_AND_STEP(); - M.x86.R_AX = aaa_word(M.x86.R_AX); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x38 -****************************************************************************/ -void x86emuOp_cmp_byte_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - u8 *destreg, *srcreg; - u8 destval; - - START_OF_INSTR(); - DECODE_PRINTF("CMP\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_byte(destval, *srcreg); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_byte(destval, *srcreg); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_byte(destval, *srcreg); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x39 -****************************************************************************/ -void x86emuOp_cmp_word_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("CMP\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_long(destval, *srcreg); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_word(destval, *srcreg); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_long(destval, *srcreg); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_word(destval, *srcreg); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_long(destval, *srcreg); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_word(destval, *srcreg); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x3a -****************************************************************************/ -void x86emuOp_cmp_byte_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint srcoffset; - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("CMP\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_byte(*destreg, srcval); - break; - case 1: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_byte(*destreg, srcval); - break; - case 2: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_byte(*destreg, srcval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x3b -****************************************************************************/ -void x86emuOp_cmp_word_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("CMP\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_word(*destreg, srcval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_word(*destreg, srcval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_word(*destreg, srcval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - cmp_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x3c -****************************************************************************/ -void x86emuOp_cmp_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("CMP\tAL,"); - srcval = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - cmp_byte(M.x86.R_AL, srcval); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x3d -****************************************************************************/ -void x86emuOp_cmp_word_AX_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("CMP\tEAX,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("CMP\tAX,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - cmp_long(M.x86.R_EAX, srcval); - } else { - cmp_word(M.x86.R_AX, (u16)srcval); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x3e -****************************************************************************/ -void x86emuOp_segovr_DS(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("DS:\n"); - TRACE_AND_STEP(); - M.x86.mode |= SYSMODE_SEGOVR_DS; - /* NO DECODE_CLEAR_SEGOVR! */ - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x3f -****************************************************************************/ -void x86emuOp_aas(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("AAS\n"); - TRACE_AND_STEP(); - M.x86.R_AX = aas_word(M.x86.R_AX); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x40 -****************************************************************************/ -void x86emuOp_inc_AX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("INC\tEAX\n"); - } else { - DECODE_PRINTF("INC\tAX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EAX = inc_long(M.x86.R_EAX); - } else { - M.x86.R_AX = inc_word(M.x86.R_AX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x41 -****************************************************************************/ -void x86emuOp_inc_CX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("INC\tECX\n"); - } else { - DECODE_PRINTF("INC\tCX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_ECX = inc_long(M.x86.R_ECX); - } else { - M.x86.R_CX = inc_word(M.x86.R_CX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x42 -****************************************************************************/ -void x86emuOp_inc_DX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("INC\tEDX\n"); - } else { - DECODE_PRINTF("INC\tDX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EDX = inc_long(M.x86.R_EDX); - } else { - M.x86.R_DX = inc_word(M.x86.R_DX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x43 -****************************************************************************/ -void x86emuOp_inc_BX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("INC\tEBX\n"); - } else { - DECODE_PRINTF("INC\tBX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EBX = inc_long(M.x86.R_EBX); - } else { - M.x86.R_BX = inc_word(M.x86.R_BX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x44 -****************************************************************************/ -void x86emuOp_inc_SP(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("INC\tESP\n"); - } else { - DECODE_PRINTF("INC\tSP\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_ESP = inc_long(M.x86.R_ESP); - } else { - M.x86.R_SP = inc_word(M.x86.R_SP); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x45 -****************************************************************************/ -void x86emuOp_inc_BP(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("INC\tEBP\n"); - } else { - DECODE_PRINTF("INC\tBP\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EBP = inc_long(M.x86.R_EBP); - } else { - M.x86.R_BP = inc_word(M.x86.R_BP); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x46 -****************************************************************************/ -void x86emuOp_inc_SI(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("INC\tESI\n"); - } else { - DECODE_PRINTF("INC\tSI\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_ESI = inc_long(M.x86.R_ESI); - } else { - M.x86.R_SI = inc_word(M.x86.R_SI); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x47 -****************************************************************************/ -void x86emuOp_inc_DI(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("INC\tEDI\n"); - } else { - DECODE_PRINTF("INC\tDI\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EDI = inc_long(M.x86.R_EDI); - } else { - M.x86.R_DI = inc_word(M.x86.R_DI); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x48 -****************************************************************************/ -void x86emuOp_dec_AX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("DEC\tEAX\n"); - } else { - DECODE_PRINTF("DEC\tAX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EAX = dec_long(M.x86.R_EAX); - } else { - M.x86.R_AX = dec_word(M.x86.R_AX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x49 -****************************************************************************/ -void x86emuOp_dec_CX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("DEC\tECX\n"); - } else { - DECODE_PRINTF("DEC\tCX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_ECX = dec_long(M.x86.R_ECX); - } else { - M.x86.R_CX = dec_word(M.x86.R_CX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x4a -****************************************************************************/ -void x86emuOp_dec_DX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("DEC\tEDX\n"); - } else { - DECODE_PRINTF("DEC\tDX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EDX = dec_long(M.x86.R_EDX); - } else { - M.x86.R_DX = dec_word(M.x86.R_DX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x4b -****************************************************************************/ -void x86emuOp_dec_BX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("DEC\tEBX\n"); - } else { - DECODE_PRINTF("DEC\tBX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EBX = dec_long(M.x86.R_EBX); - } else { - M.x86.R_BX = dec_word(M.x86.R_BX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x4c -****************************************************************************/ -void x86emuOp_dec_SP(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("DEC\tESP\n"); - } else { - DECODE_PRINTF("DEC\tSP\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_ESP = dec_long(M.x86.R_ESP); - } else { - M.x86.R_SP = dec_word(M.x86.R_SP); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x4d -****************************************************************************/ -void x86emuOp_dec_BP(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("DEC\tEBP\n"); - } else { - DECODE_PRINTF("DEC\tBP\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EBP = dec_long(M.x86.R_EBP); - } else { - M.x86.R_BP = dec_word(M.x86.R_BP); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x4e -****************************************************************************/ -void x86emuOp_dec_SI(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("DEC\tESI\n"); - } else { - DECODE_PRINTF("DEC\tSI\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_ESI = dec_long(M.x86.R_ESI); - } else { - M.x86.R_SI = dec_word(M.x86.R_SI); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x4f -****************************************************************************/ -void x86emuOp_dec_DI(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("DEC\tEDI\n"); - } else { - DECODE_PRINTF("DEC\tDI\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EDI = dec_long(M.x86.R_EDI); - } else { - M.x86.R_DI = dec_word(M.x86.R_DI); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x50 -****************************************************************************/ -void x86emuOp_push_AX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("PUSH\tEAX\n"); - } else { - DECODE_PRINTF("PUSH\tAX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - push_long(M.x86.R_EAX); - } else { - push_word(M.x86.R_AX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x51 -****************************************************************************/ -void x86emuOp_push_CX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("PUSH\tECX\n"); - } else { - DECODE_PRINTF("PUSH\tCX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - push_long(M.x86.R_ECX); - } else { - push_word(M.x86.R_CX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x52 -****************************************************************************/ -void x86emuOp_push_DX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("PUSH\tEDX\n"); - } else { - DECODE_PRINTF("PUSH\tDX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - push_long(M.x86.R_EDX); - } else { - push_word(M.x86.R_DX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x53 -****************************************************************************/ -void x86emuOp_push_BX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("PUSH\tEBX\n"); - } else { - DECODE_PRINTF("PUSH\tBX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - push_long(M.x86.R_EBX); - } else { - push_word(M.x86.R_BX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x54 -****************************************************************************/ -void x86emuOp_push_SP(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("PUSH\tESP\n"); - } else { - DECODE_PRINTF("PUSH\tSP\n"); - } - TRACE_AND_STEP(); - /* Always push (E)SP, since we are emulating an i386 and above - * processor. This is necessary as some BIOS'es use this to check - * what type of processor is in the system. - */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - push_long(M.x86.R_ESP); - } else { - push_word((u16)(M.x86.R_SP)); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x55 -****************************************************************************/ -void x86emuOp_push_BP(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("PUSH\tEBP\n"); - } else { - DECODE_PRINTF("PUSH\tBP\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - push_long(M.x86.R_EBP); - } else { - push_word(M.x86.R_BP); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x56 -****************************************************************************/ -void x86emuOp_push_SI(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("PUSH\tESI\n"); - } else { - DECODE_PRINTF("PUSH\tSI\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - push_long(M.x86.R_ESI); - } else { - push_word(M.x86.R_SI); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x57 -****************************************************************************/ -void x86emuOp_push_DI(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("PUSH\tEDI\n"); - } else { - DECODE_PRINTF("PUSH\tDI\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - push_long(M.x86.R_EDI); - } else { - push_word(M.x86.R_DI); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x58 -****************************************************************************/ -void x86emuOp_pop_AX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("POP\tEAX\n"); - } else { - DECODE_PRINTF("POP\tAX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EAX = pop_long(); - } else { - M.x86.R_AX = pop_word(); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x59 -****************************************************************************/ -void x86emuOp_pop_CX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("POP\tECX\n"); - } else { - DECODE_PRINTF("POP\tCX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_ECX = pop_long(); - } else { - M.x86.R_CX = pop_word(); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x5a -****************************************************************************/ -void x86emuOp_pop_DX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("POP\tEDX\n"); - } else { - DECODE_PRINTF("POP\tDX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EDX = pop_long(); - } else { - M.x86.R_DX = pop_word(); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x5b -****************************************************************************/ -void x86emuOp_pop_BX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("POP\tEBX\n"); - } else { - DECODE_PRINTF("POP\tBX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EBX = pop_long(); - } else { - M.x86.R_BX = pop_word(); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x5c -****************************************************************************/ -void x86emuOp_pop_SP(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("POP\tESP\n"); - } else { - DECODE_PRINTF("POP\tSP\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_ESP = pop_long(); - } else { - M.x86.R_SP = pop_word(); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x5d -****************************************************************************/ -void x86emuOp_pop_BP(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("POP\tEBP\n"); - } else { - DECODE_PRINTF("POP\tBP\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EBP = pop_long(); - } else { - M.x86.R_BP = pop_word(); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x5e -****************************************************************************/ -void x86emuOp_pop_SI(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("POP\tESI\n"); - } else { - DECODE_PRINTF("POP\tSI\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_ESI = pop_long(); - } else { - M.x86.R_SI = pop_word(); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x5f -****************************************************************************/ -void x86emuOp_pop_DI(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("POP\tEDI\n"); - } else { - DECODE_PRINTF("POP\tDI\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EDI = pop_long(); - } else { - M.x86.R_DI = pop_word(); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x60 -****************************************************************************/ -void x86emuOp_push_all(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("PUSHAD\n"); - } else { - DECODE_PRINTF("PUSHA\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 old_sp = M.x86.R_ESP; - - push_long(M.x86.R_EAX); - push_long(M.x86.R_ECX); - push_long(M.x86.R_EDX); - push_long(M.x86.R_EBX); - push_long(old_sp); - push_long(M.x86.R_EBP); - push_long(M.x86.R_ESI); - push_long(M.x86.R_EDI); - } else { - u16 old_sp = M.x86.R_SP; - - push_word(M.x86.R_AX); - push_word(M.x86.R_CX); - push_word(M.x86.R_DX); - push_word(M.x86.R_BX); - push_word(old_sp); - push_word(M.x86.R_BP); - push_word(M.x86.R_SI); - push_word(M.x86.R_DI); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x61 -****************************************************************************/ -void x86emuOp_pop_all(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("POPAD\n"); - } else { - DECODE_PRINTF("POPA\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EDI = pop_long(); - M.x86.R_ESI = pop_long(); - M.x86.R_EBP = pop_long(); - M.x86.R_ESP += 4; /* skip ESP */ - M.x86.R_EBX = pop_long(); - M.x86.R_EDX = pop_long(); - M.x86.R_ECX = pop_long(); - M.x86.R_EAX = pop_long(); - } else { - M.x86.R_DI = pop_word(); - M.x86.R_SI = pop_word(); - M.x86.R_BP = pop_word(); - M.x86.R_SP += 2; /* skip SP */ - M.x86.R_BX = pop_word(); - M.x86.R_DX = pop_word(); - M.x86.R_CX = pop_word(); - M.x86.R_AX = pop_word(); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/*opcode 0x62 ILLEGAL OP, calls x86emuOp_illegal_op() */ -/*opcode 0x63 ILLEGAL OP, calls x86emuOp_illegal_op() */ - -/**************************************************************************** -REMARKS: -Handles opcode 0x64 -****************************************************************************/ -void x86emuOp_segovr_FS(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("FS:\n"); - TRACE_AND_STEP(); - M.x86.mode |= SYSMODE_SEGOVR_FS; - /* - * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4 - * opcode subroutines we do not want to do this. - */ - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x65 -****************************************************************************/ -void x86emuOp_segovr_GS(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("GS:\n"); - TRACE_AND_STEP(); - M.x86.mode |= SYSMODE_SEGOVR_GS; - /* - * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4 - * opcode subroutines we do not want to do this. - */ - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x66 - prefix for 32-bit register -****************************************************************************/ -void x86emuOp_prefix_data(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("DATA:\n"); - TRACE_AND_STEP(); - M.x86.mode |= SYSMODE_PREFIX_DATA; - /* note no DECODE_CLEAR_SEGOVR here. */ - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x67 - prefix for 32-bit address -****************************************************************************/ -void x86emuOp_prefix_addr(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("ADDR:\n"); - TRACE_AND_STEP(); - M.x86.mode |= SYSMODE_PREFIX_ADDR; - /* note no DECODE_CLEAR_SEGOVR here. */ - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x68 -****************************************************************************/ -void x86emuOp_push_word_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 imm; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - imm = fetch_long_imm(); - } else { - imm = fetch_word_imm(); - } - DECODE_PRINTF2("PUSH\t%x\n", imm); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - push_long(imm); - } else { - push_word((u16)imm); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x69 -****************************************************************************/ -void x86emuOp_imul_word_IMM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("IMUL\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - u32 res_lo,res_hi; - s32 imm; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_long(srcoffset); - imm = fetch_long_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - TRACE_AND_STEP(); - imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm); - if (res_hi != 0) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u32)res_lo; - } else { - u16 *destreg; - u16 srcval; - u32 res; - s16 imm; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_word(srcoffset); - imm = fetch_word_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - TRACE_AND_STEP(); - res = (s16)srcval * (s16)imm; - if (res > 0xFFFF) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u16)res; - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - u32 res_lo,res_hi; - s32 imm; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_long(srcoffset); - imm = fetch_long_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - TRACE_AND_STEP(); - imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm); - if (res_hi != 0) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u32)res_lo; - } else { - u16 *destreg; - u16 srcval; - u32 res; - s16 imm; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_word(srcoffset); - imm = fetch_word_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - TRACE_AND_STEP(); - res = (s16)srcval * (s16)imm; - if (res > 0xFFFF) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u16)res; - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - u32 res_lo,res_hi; - s32 imm; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_long(srcoffset); - imm = fetch_long_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - TRACE_AND_STEP(); - imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm); - if (res_hi != 0) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u32)res_lo; - } else { - u16 *destreg; - u16 srcval; - u32 res; - s16 imm; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_word(srcoffset); - imm = fetch_word_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - TRACE_AND_STEP(); - res = (s16)srcval * (s16)imm; - if (res > 0xFFFF) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u16)res; - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - u32 res_lo,res_hi; - s32 imm; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rl); - imm = fetch_long_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - TRACE_AND_STEP(); - imul_long_direct(&res_lo,&res_hi,(s32)*srcreg,(s32)imm); - if (res_hi != 0) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u32)res_lo; - } else { - u16 *destreg,*srcreg; - u32 res; - s16 imm; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rl); - imm = fetch_word_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - res = (s16)*srcreg * (s16)imm; - if (res > 0xFFFF) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u16)res; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x6a -****************************************************************************/ -void x86emuOp_push_byte_IMM(u8 X86EMU_UNUSED(op1)) -{ - s16 imm; - - START_OF_INSTR(); - imm = (s8)fetch_byte_imm(); - DECODE_PRINTF2("PUSH\t%d\n", imm); - TRACE_AND_STEP(); - push_word(imm); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x6b -****************************************************************************/ -void x86emuOp_imul_byte_IMM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint srcoffset; - s8 imm; - - START_OF_INSTR(); - DECODE_PRINTF("IMUL\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - u32 res_lo,res_hi; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_long(srcoffset); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - TRACE_AND_STEP(); - imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm); - if (res_hi != 0) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u32)res_lo; - } else { - u16 *destreg; - u16 srcval; - u32 res; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_word(srcoffset); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - TRACE_AND_STEP(); - res = (s16)srcval * (s16)imm; - if (res > 0xFFFF) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u16)res; - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - u32 res_lo,res_hi; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_long(srcoffset); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - TRACE_AND_STEP(); - imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm); - if (res_hi != 0) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u32)res_lo; - } else { - u16 *destreg; - u16 srcval; - u32 res; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_word(srcoffset); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - TRACE_AND_STEP(); - res = (s16)srcval * (s16)imm; - if (res > 0xFFFF) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u16)res; - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - u32 res_lo,res_hi; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_long(srcoffset); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - TRACE_AND_STEP(); - imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm); - if (res_hi != 0) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u32)res_lo; - } else { - u16 *destreg; - u16 srcval; - u32 res; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_word(srcoffset); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - TRACE_AND_STEP(); - res = (s16)srcval * (s16)imm; - if (res > 0xFFFF) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u16)res; - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - u32 res_lo,res_hi; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rl); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - TRACE_AND_STEP(); - imul_long_direct(&res_lo,&res_hi,(s32)*srcreg,(s32)imm); - if (res_hi != 0) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u32)res_lo; - } else { - u16 *destreg,*srcreg; - u32 res; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rl); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%d\n", (s32)imm); - res = (s16)*srcreg * (s16)imm; - if (res > 0xFFFF) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u16)res; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x6c -****************************************************************************/ -void x86emuOp_ins_byte(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("INSB\n"); - ins(1); - TRACE_AND_STEP(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x6d -****************************************************************************/ -void x86emuOp_ins_word(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("INSD\n"); - ins(4); - } else { - DECODE_PRINTF("INSW\n"); - ins(2); - } - TRACE_AND_STEP(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x6e -****************************************************************************/ -void x86emuOp_outs_byte(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("OUTSB\n"); - outs(1); - TRACE_AND_STEP(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x6f -****************************************************************************/ -void x86emuOp_outs_word(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("OUTSD\n"); - outs(4); - } else { - DECODE_PRINTF("OUTSW\n"); - outs(2); - } - TRACE_AND_STEP(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x70 -****************************************************************************/ -void x86emuOp_jump_near_O(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - - /* jump to byte offset if overflow flag is set */ - START_OF_INSTR(); - DECODE_PRINTF("JO\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - if (ACCESS_FLAG(F_OF)) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x71 -****************************************************************************/ -void x86emuOp_jump_near_NO(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - - /* jump to byte offset if overflow is not set */ - START_OF_INSTR(); - DECODE_PRINTF("JNO\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - if (!ACCESS_FLAG(F_OF)) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x72 -****************************************************************************/ -void x86emuOp_jump_near_B(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - - /* jump to byte offset if carry flag is set. */ - START_OF_INSTR(); - DECODE_PRINTF("JB\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - if (ACCESS_FLAG(F_CF)) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x73 -****************************************************************************/ -void x86emuOp_jump_near_NB(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - - /* jump to byte offset if carry flag is clear. */ - START_OF_INSTR(); - DECODE_PRINTF("JNB\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - if (!ACCESS_FLAG(F_CF)) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x74 -****************************************************************************/ -void x86emuOp_jump_near_Z(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - - /* jump to byte offset if zero flag is set. */ - START_OF_INSTR(); - DECODE_PRINTF("JZ\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - if (ACCESS_FLAG(F_ZF)) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x75 -****************************************************************************/ -void x86emuOp_jump_near_NZ(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - - /* jump to byte offset if zero flag is clear. */ - START_OF_INSTR(); - DECODE_PRINTF("JNZ\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - if (!ACCESS_FLAG(F_ZF)) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x76 -****************************************************************************/ -void x86emuOp_jump_near_BE(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - - /* jump to byte offset if carry flag is set or if the zero - flag is set. */ - START_OF_INSTR(); - DECODE_PRINTF("JBE\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - if (ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF)) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x77 -****************************************************************************/ -void x86emuOp_jump_near_NBE(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - - /* jump to byte offset if carry flag is clear and if the zero - flag is clear */ - START_OF_INSTR(); - DECODE_PRINTF("JNBE\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - if (!(ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF))) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x78 -****************************************************************************/ -void x86emuOp_jump_near_S(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - - /* jump to byte offset if sign flag is set */ - START_OF_INSTR(); - DECODE_PRINTF("JS\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - if (ACCESS_FLAG(F_SF)) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x79 -****************************************************************************/ -void x86emuOp_jump_near_NS(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - - /* jump to byte offset if sign flag is clear */ - START_OF_INSTR(); - DECODE_PRINTF("JNS\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - if (!ACCESS_FLAG(F_SF)) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x7a -****************************************************************************/ -void x86emuOp_jump_near_P(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - - /* jump to byte offset if parity flag is set (even parity) */ - START_OF_INSTR(); - DECODE_PRINTF("JP\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - if (ACCESS_FLAG(F_PF)) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x7b -****************************************************************************/ -void x86emuOp_jump_near_NP(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - - /* jump to byte offset if parity flag is clear (odd parity) */ - START_OF_INSTR(); - DECODE_PRINTF("JNP\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - if (!ACCESS_FLAG(F_PF)) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x7c -****************************************************************************/ -void x86emuOp_jump_near_L(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - int sf, of; - - /* jump to byte offset if sign flag not equal to overflow flag. */ - START_OF_INSTR(); - DECODE_PRINTF("JL\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - sf = ACCESS_FLAG(F_SF) != 0; - of = ACCESS_FLAG(F_OF) != 0; - if (sf ^ of) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x7d -****************************************************************************/ -void x86emuOp_jump_near_NL(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - int sf, of; - - /* jump to byte offset if sign flag not equal to overflow flag. */ - START_OF_INSTR(); - DECODE_PRINTF("JNL\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - sf = ACCESS_FLAG(F_SF) != 0; - of = ACCESS_FLAG(F_OF) != 0; - /* note: inverse of above, but using == instead of xor. */ - if (sf == of) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x7e -****************************************************************************/ -void x86emuOp_jump_near_LE(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - int sf, of; - - /* jump to byte offset if sign flag not equal to overflow flag - or the zero flag is set */ - START_OF_INSTR(); - DECODE_PRINTF("JLE\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - sf = ACCESS_FLAG(F_SF) != 0; - of = ACCESS_FLAG(F_OF) != 0; - if ((sf ^ of) || ACCESS_FLAG(F_ZF)) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x7f -****************************************************************************/ -void x86emuOp_jump_near_NLE(u8 X86EMU_UNUSED(op1)) -{ - s8 offset; - u16 target; - int sf, of; - - /* jump to byte offset if sign flag equal to overflow flag. - and the zero flag is clear */ - START_OF_INSTR(); - DECODE_PRINTF("JNLE\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + (s16)offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - sf = ACCESS_FLAG(F_SF) != 0; - of = ACCESS_FLAG(F_OF) != 0; - if ((sf == of) && !ACCESS_FLAG(F_ZF)) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -static u8 (*opc80_byte_operation[])(u8 d, u8 s) = -{ - add_byte, /* 00 */ - or_byte, /* 01 */ - adc_byte, /* 02 */ - sbb_byte, /* 03 */ - and_byte, /* 04 */ - sub_byte, /* 05 */ - xor_byte, /* 06 */ - cmp_byte, /* 07 */ -}; - -/**************************************************************************** -REMARKS: -Handles opcode 0x80 -****************************************************************************/ -void x86emuOp_opc80_byte_RM_IMM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg; - uint destoffset; - u8 imm; - u8 destval; - - /* - * Weirdo special case instruction format. Part of the opcode - * held below in "RH". Doubly nested case would result, except - * that the decoded instruction - */ - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); -#ifdef DEBUG - if (DEBUG_DECODE()) { - /* XXX DECODE_PRINTF may be changed to something more - general, so that it is important to leave the strings - in the same format, even though the result is that the - above test is done twice. */ - - switch (rh) { - case 0: - DECODE_PRINTF("ADD\t"); - break; - case 1: - DECODE_PRINTF("OR\t"); - break; - case 2: - DECODE_PRINTF("ADC\t"); - break; - case 3: - DECODE_PRINTF("SBB\t"); - break; - case 4: - DECODE_PRINTF("AND\t"); - break; - case 5: - DECODE_PRINTF("SUB\t"); - break; - case 6: - DECODE_PRINTF("XOR\t"); - break; - case 7: - DECODE_PRINTF("CMP\t"); - break; - } - } -#endif - /* know operation, decode the mod byte to find the addressing - mode. */ - switch (mod) { - case 0: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - imm = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc80_byte_operation[rh]) (destval, imm); - if (rh != 7) - store_data_byte(destoffset, destval); - break; - case 1: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - imm = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc80_byte_operation[rh]) (destval, imm); - if (rh != 7) - store_data_byte(destoffset, destval); - break; - case 2: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - imm = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc80_byte_operation[rh]) (destval, imm); - if (rh != 7) - store_data_byte(destoffset, destval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF(","); - imm = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc80_byte_operation[rh]) (*destreg, imm); - if (rh != 7) - *destreg = destval; - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -static u16 (*opc81_word_operation[])(u16 d, u16 s) = -{ - add_word, /*00 */ - or_word, /*01 */ - adc_word, /*02 */ - sbb_word, /*03 */ - and_word, /*04 */ - sub_word, /*05 */ - xor_word, /*06 */ - cmp_word, /*07 */ -}; - -static u32 (*opc81_long_operation[])(u32 d, u32 s) = -{ - add_long, /*00 */ - or_long, /*01 */ - adc_long, /*02 */ - sbb_long, /*03 */ - and_long, /*04 */ - sub_long, /*05 */ - xor_long, /*06 */ - cmp_long, /*07 */ -}; - -/**************************************************************************** -REMARKS: -Handles opcode 0x81 -****************************************************************************/ -void x86emuOp_opc81_word_RM_IMM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - /* - * Weirdo special case instruction format. Part of the opcode - * held below in "RH". Doubly nested case would result, except - * that the decoded instruction - */ - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); -#ifdef DEBUG - if (DEBUG_DECODE()) { - /* XXX DECODE_PRINTF may be changed to something more - general, so that it is important to leave the strings - in the same format, even though the result is that the - above test is done twice. */ - - switch (rh) { - case 0: - DECODE_PRINTF("ADD\t"); - break; - case 1: - DECODE_PRINTF("OR\t"); - break; - case 2: - DECODE_PRINTF("ADC\t"); - break; - case 3: - DECODE_PRINTF("SBB\t"); - break; - case 4: - DECODE_PRINTF("AND\t"); - break; - case 5: - DECODE_PRINTF("SUB\t"); - break; - case 6: - DECODE_PRINTF("XOR\t"); - break; - case 7: - DECODE_PRINTF("CMP\t"); - break; - } - } -#endif - /* - * Know operation, decode the mod byte to find the addressing - * mode. - */ - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval,imm; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - imm = fetch_long_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc81_long_operation[rh]) (destval, imm); - if (rh != 7) - store_data_long(destoffset, destval); - } else { - u16 destval,imm; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - imm = fetch_word_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc81_word_operation[rh]) (destval, imm); - if (rh != 7) - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval,imm; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - imm = fetch_long_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc81_long_operation[rh]) (destval, imm); - if (rh != 7) - store_data_long(destoffset, destval); - } else { - u16 destval,imm; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - imm = fetch_word_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc81_word_operation[rh]) (destval, imm); - if (rh != 7) - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval,imm; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - imm = fetch_long_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc81_long_operation[rh]) (destval, imm); - if (rh != 7) - store_data_long(destoffset, destval); - } else { - u16 destval,imm; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - imm = fetch_word_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc81_word_operation[rh]) (destval, imm); - if (rh != 7) - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 destval,imm; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - imm = fetch_long_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc81_long_operation[rh]) (*destreg, imm); - if (rh != 7) - *destreg = destval; - } else { - u16 *destreg; - u16 destval,imm; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - imm = fetch_word_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc81_word_operation[rh]) (*destreg, imm); - if (rh != 7) - *destreg = destval; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -static u8 (*opc82_byte_operation[])(u8 s, u8 d) = -{ - add_byte, /*00 */ - or_byte, /*01 */ /*YYY UNUSED ???? */ - adc_byte, /*02 */ - sbb_byte, /*03 */ - and_byte, /*04 */ /*YYY UNUSED ???? */ - sub_byte, /*05 */ - xor_byte, /*06 */ /*YYY UNUSED ???? */ - cmp_byte, /*07 */ -}; - -/**************************************************************************** -REMARKS: -Handles opcode 0x82 -****************************************************************************/ -void x86emuOp_opc82_byte_RM_IMM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg; - uint destoffset; - u8 imm; - u8 destval; - - /* - * Weirdo special case instruction format. Part of the opcode - * held below in "RH". Doubly nested case would result, except - * that the decoded instruction Similar to opcode 81, except that - * the immediate byte is sign extended to a word length. - */ - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); -#ifdef DEBUG - if (DEBUG_DECODE()) { - /* XXX DECODE_PRINTF may be changed to something more - general, so that it is important to leave the strings - in the same format, even though the result is that the - above test is done twice. */ - switch (rh) { - case 0: - DECODE_PRINTF("ADD\t"); - break; - case 1: - DECODE_PRINTF("OR\t"); - break; - case 2: - DECODE_PRINTF("ADC\t"); - break; - case 3: - DECODE_PRINTF("SBB\t"); - break; - case 4: - DECODE_PRINTF("AND\t"); - break; - case 5: - DECODE_PRINTF("SUB\t"); - break; - case 6: - DECODE_PRINTF("XOR\t"); - break; - case 7: - DECODE_PRINTF("CMP\t"); - break; - } - } -#endif - /* know operation, decode the mod byte to find the addressing - mode. */ - switch (mod) { - case 0: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm00_address(rl); - destval = fetch_data_byte(destoffset); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc82_byte_operation[rh]) (destval, imm); - if (rh != 7) - store_data_byte(destoffset, destval); - break; - case 1: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm01_address(rl); - destval = fetch_data_byte(destoffset); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc82_byte_operation[rh]) (destval, imm); - if (rh != 7) - store_data_byte(destoffset, destval); - break; - case 2: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm10_address(rl); - destval = fetch_data_byte(destoffset); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc82_byte_operation[rh]) (destval, imm); - if (rh != 7) - store_data_byte(destoffset, destval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc82_byte_operation[rh]) (*destreg, imm); - if (rh != 7) - *destreg = destval; - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -static u16 (*opc83_word_operation[])(u16 s, u16 d) = -{ - add_word, /*00 */ - or_word, /*01 */ /*YYY UNUSED ???? */ - adc_word, /*02 */ - sbb_word, /*03 */ - and_word, /*04 */ /*YYY UNUSED ???? */ - sub_word, /*05 */ - xor_word, /*06 */ /*YYY UNUSED ???? */ - cmp_word, /*07 */ -}; - -static u32 (*opc83_long_operation[])(u32 s, u32 d) = -{ - add_long, /*00 */ - or_long, /*01 */ /*YYY UNUSED ???? */ - adc_long, /*02 */ - sbb_long, /*03 */ - and_long, /*04 */ /*YYY UNUSED ???? */ - sub_long, /*05 */ - xor_long, /*06 */ /*YYY UNUSED ???? */ - cmp_long, /*07 */ -}; - -/**************************************************************************** -REMARKS: -Handles opcode 0x83 -****************************************************************************/ -void x86emuOp_opc83_word_RM_IMM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - /* - * Weirdo special case instruction format. Part of the opcode - * held below in "RH". Doubly nested case would result, except - * that the decoded instruction Similar to opcode 81, except that - * the immediate byte is sign extended to a word length. - */ - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); -#ifdef DEBUG - if (DEBUG_DECODE()) { - /* XXX DECODE_PRINTF may be changed to something more - general, so that it is important to leave the strings - in the same format, even though the result is that the - above test is done twice. */ - switch (rh) { - case 0: - DECODE_PRINTF("ADD\t"); - break; - case 1: - DECODE_PRINTF("OR\t"); - break; - case 2: - DECODE_PRINTF("ADC\t"); - break; - case 3: - DECODE_PRINTF("SBB\t"); - break; - case 4: - DECODE_PRINTF("AND\t"); - break; - case 5: - DECODE_PRINTF("SUB\t"); - break; - case 6: - DECODE_PRINTF("XOR\t"); - break; - case 7: - DECODE_PRINTF("CMP\t"); - break; - } - } -#endif - /* know operation, decode the mod byte to find the addressing - mode. */ - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval,imm; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm00_address(rl); - destval = fetch_data_long(destoffset); - imm = (s8) fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc83_long_operation[rh]) (destval, imm); - if (rh != 7) - store_data_long(destoffset, destval); - } else { - u16 destval,imm; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm00_address(rl); - destval = fetch_data_word(destoffset); - imm = (s8) fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc83_word_operation[rh]) (destval, imm); - if (rh != 7) - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval,imm; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm01_address(rl); - destval = fetch_data_long(destoffset); - imm = (s8) fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc83_long_operation[rh]) (destval, imm); - if (rh != 7) - store_data_long(destoffset, destval); - } else { - u16 destval,imm; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm01_address(rl); - destval = fetch_data_word(destoffset); - imm = (s8) fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc83_word_operation[rh]) (destval, imm); - if (rh != 7) - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval,imm; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm10_address(rl); - destval = fetch_data_long(destoffset); - imm = (s8) fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc83_long_operation[rh]) (destval, imm); - if (rh != 7) - store_data_long(destoffset, destval); - } else { - u16 destval,imm; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm10_address(rl); - destval = fetch_data_word(destoffset); - imm = (s8) fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc83_word_operation[rh]) (destval, imm); - if (rh != 7) - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 destval,imm; - - destreg = DECODE_RM_LONG_REGISTER(rl); - imm = (s8) fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc83_long_operation[rh]) (*destreg, imm); - if (rh != 7) - *destreg = destval; - } else { - u16 *destreg; - u16 destval,imm; - - destreg = DECODE_RM_WORD_REGISTER(rl); - imm = (s8) fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - destval = (*opc83_word_operation[rh]) (*destreg, imm); - if (rh != 7) - *destreg = destval; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x84 -****************************************************************************/ -void x86emuOp_test_byte_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint destoffset; - u8 destval; - - START_OF_INSTR(); - DECODE_PRINTF("TEST\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - test_byte(destval, *srcreg); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - test_byte(destval, *srcreg); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - test_byte(destval, *srcreg); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - test_byte(*destreg, *srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x85 -****************************************************************************/ -void x86emuOp_test_word_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("TEST\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - test_long(destval, *srcreg); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - test_word(destval, *srcreg); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - test_long(destval, *srcreg); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - test_word(destval, *srcreg); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - test_long(destval, *srcreg); - } else { - u16 destval; - u16 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - test_word(destval, *srcreg); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - test_long(*destreg, *srcreg); - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - test_word(*destreg, *srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x86 -****************************************************************************/ -void x86emuOp_xchg_byte_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint destoffset; - u8 destval; - u8 tmp; - - START_OF_INSTR(); - DECODE_PRINTF("XCHG\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - tmp = *srcreg; - *srcreg = destval; - destval = tmp; - store_data_byte(destoffset, destval); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - tmp = *srcreg; - *srcreg = destval; - destval = tmp; - store_data_byte(destoffset, destval); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_byte(destoffset); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - tmp = *srcreg; - *srcreg = destval; - destval = tmp; - store_data_byte(destoffset, destval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - tmp = *srcreg; - *srcreg = *destreg; - *destreg = tmp; - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x87 -****************************************************************************/ -void x86emuOp_xchg_word_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("XCHG\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *srcreg; - u32 destval,tmp; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - tmp = *srcreg; - *srcreg = destval; - destval = tmp; - store_data_long(destoffset, destval); - } else { - u16 *srcreg; - u16 destval,tmp; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - tmp = *srcreg; - *srcreg = destval; - destval = tmp; - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *srcreg; - u32 destval,tmp; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - tmp = *srcreg; - *srcreg = destval; - destval = tmp; - store_data_long(destoffset, destval); - } else { - u16 *srcreg; - u16 destval,tmp; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - tmp = *srcreg; - *srcreg = destval; - destval = tmp; - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *srcreg; - u32 destval,tmp; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_long(destoffset); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - tmp = *srcreg; - *srcreg = destval; - destval = tmp; - store_data_long(destoffset, destval); - } else { - u16 *srcreg; - u16 destval,tmp; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - destval = fetch_data_word(destoffset); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - tmp = *srcreg; - *srcreg = destval; - destval = tmp; - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - u32 tmp; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - tmp = *srcreg; - *srcreg = *destreg; - *destreg = tmp; - } else { - u16 *destreg,*srcreg; - u16 tmp; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - tmp = *srcreg; - *srcreg = *destreg; - *destreg = tmp; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x88 -****************************************************************************/ -void x86emuOp_mov_byte_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - store_data_byte(destoffset, *srcreg); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - store_data_byte(destoffset, *srcreg); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - store_data_byte(destoffset, *srcreg); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = *srcreg; - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x89 -****************************************************************************/ -void x86emuOp_mov_word_RM_R(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - store_data_long(destoffset, *srcreg); - } else { - u16 *srcreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - store_data_word(destoffset, *srcreg); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - store_data_long(destoffset, *srcreg); - } else { - u16 *srcreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - store_data_word(destoffset, *srcreg); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - store_data_long(destoffset, *srcreg); - } else { - u16 *srcreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - store_data_word(destoffset, *srcreg); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = *srcreg; - } else { - u16 *destreg,*srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = *srcreg; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x8a -****************************************************************************/ -void x86emuOp_mov_byte_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg, *srcreg; - uint srcoffset; - u8 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - break; - case 1: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - break; - case 2: - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = *srcreg; - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x8b -****************************************************************************/ -void x86emuOp_mov_word_R_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_long(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg, *srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = *srcreg; - } else { - u16 *destreg, *srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = *srcreg; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x8c -****************************************************************************/ -void x86emuOp_mov_word_RM_SR(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u16 *destreg, *srcreg; - uint destoffset; - u16 destval; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - srcreg = decode_rm_seg_register(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = *srcreg; - store_data_word(destoffset, destval); - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - srcreg = decode_rm_seg_register(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = *srcreg; - store_data_word(destoffset, destval); - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - srcreg = decode_rm_seg_register(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = *srcreg; - store_data_word(destoffset, destval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - srcreg = decode_rm_seg_register(rh); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = *srcreg; - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x8d -****************************************************************************/ -void x86emuOp_lea_word_R_M(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u16 *srcreg; - uint destoffset; - -/* - * TODO: Need to handle address size prefix! - * - * lea eax,[eax+ebx*2] ?? - */ - - START_OF_INSTR(); - DECODE_PRINTF("LEA\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *srcreg = (u16)destoffset; - break; - case 1: - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *srcreg = (u16)destoffset; - break; - case 2: - srcreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *srcreg = (u16)destoffset; - break; - case 3: /* register to register */ - /* undefined. Do nothing. */ - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x8e -****************************************************************************/ -void x86emuOp_mov_word_SR_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u16 *destreg, *srcreg; - uint srcoffset; - u16 srcval; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destreg = decode_rm_seg_register(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - break; - case 1: - destreg = decode_rm_seg_register(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - break; - case 2: - destreg = decode_rm_seg_register(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - break; - case 3: /* register to register */ - destreg = decode_rm_seg_register(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = *srcreg; - break; - } - /* - * Clean up, and reset all the R_xSP pointers to the correct - * locations. This is about 3x too much overhead (doing all the - * segreg ptrs when only one is needed, but this instruction - * *cannot* be that common, and this isn't too much work anyway. - */ - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x8f -****************************************************************************/ -void x86emuOp_pop_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("POP\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - if (rh != 0) { - DECODE_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n"); - HALT_SYS(); - } - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = pop_long(); - store_data_long(destoffset, destval); - } else { - u16 destval; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = pop_word(); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = pop_long(); - store_data_long(destoffset, destval); - } else { - u16 destval; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = pop_word(); - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = pop_long(); - store_data_long(destoffset, destval); - } else { - u16 destval; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - destval = pop_word(); - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = pop_long(); - } else { - u16 *destreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = pop_word(); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x90 -****************************************************************************/ -void x86emuOp_nop(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("NOP\n"); - TRACE_AND_STEP(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x91 -****************************************************************************/ -void x86emuOp_xchg_word_AX_CX(u8 X86EMU_UNUSED(op1)) -{ - u32 tmp; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("XCHG\tEAX,ECX\n"); - } else { - DECODE_PRINTF("XCHG\tAX,CX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - tmp = M.x86.R_EAX; - M.x86.R_EAX = M.x86.R_ECX; - M.x86.R_ECX = tmp; - } else { - tmp = M.x86.R_AX; - M.x86.R_AX = M.x86.R_CX; - M.x86.R_CX = (u16)tmp; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x92 -****************************************************************************/ -void x86emuOp_xchg_word_AX_DX(u8 X86EMU_UNUSED(op1)) -{ - u32 tmp; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("XCHG\tEAX,EDX\n"); - } else { - DECODE_PRINTF("XCHG\tAX,DX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - tmp = M.x86.R_EAX; - M.x86.R_EAX = M.x86.R_EDX; - M.x86.R_EDX = tmp; - } else { - tmp = M.x86.R_AX; - M.x86.R_AX = M.x86.R_DX; - M.x86.R_DX = (u16)tmp; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x93 -****************************************************************************/ -void x86emuOp_xchg_word_AX_BX(u8 X86EMU_UNUSED(op1)) -{ - u32 tmp; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("XCHG\tEAX,EBX\n"); - } else { - DECODE_PRINTF("XCHG\tAX,BX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - tmp = M.x86.R_EAX; - M.x86.R_EAX = M.x86.R_EBX; - M.x86.R_EBX = tmp; - } else { - tmp = M.x86.R_AX; - M.x86.R_AX = M.x86.R_BX; - M.x86.R_BX = (u16)tmp; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x94 -****************************************************************************/ -void x86emuOp_xchg_word_AX_SP(u8 X86EMU_UNUSED(op1)) -{ - u32 tmp; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("XCHG\tEAX,ESP\n"); - } else { - DECODE_PRINTF("XCHG\tAX,SP\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - tmp = M.x86.R_EAX; - M.x86.R_EAX = M.x86.R_ESP; - M.x86.R_ESP = tmp; - } else { - tmp = M.x86.R_AX; - M.x86.R_AX = M.x86.R_SP; - M.x86.R_SP = (u16)tmp; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x95 -****************************************************************************/ -void x86emuOp_xchg_word_AX_BP(u8 X86EMU_UNUSED(op1)) -{ - u32 tmp; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("XCHG\tEAX,EBP\n"); - } else { - DECODE_PRINTF("XCHG\tAX,BP\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - tmp = M.x86.R_EAX; - M.x86.R_EAX = M.x86.R_EBP; - M.x86.R_EBP = tmp; - } else { - tmp = M.x86.R_AX; - M.x86.R_AX = M.x86.R_BP; - M.x86.R_BP = (u16)tmp; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x96 -****************************************************************************/ -void x86emuOp_xchg_word_AX_SI(u8 X86EMU_UNUSED(op1)) -{ - u32 tmp; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("XCHG\tEAX,ESI\n"); - } else { - DECODE_PRINTF("XCHG\tAX,SI\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - tmp = M.x86.R_EAX; - M.x86.R_EAX = M.x86.R_ESI; - M.x86.R_ESI = tmp; - } else { - tmp = M.x86.R_AX; - M.x86.R_AX = M.x86.R_SI; - M.x86.R_SI = (u16)tmp; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x97 -****************************************************************************/ -void x86emuOp_xchg_word_AX_DI(u8 X86EMU_UNUSED(op1)) -{ - u32 tmp; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("XCHG\tEAX,EDI\n"); - } else { - DECODE_PRINTF("XCHG\tAX,DI\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - tmp = M.x86.R_EAX; - M.x86.R_EAX = M.x86.R_EDI; - M.x86.R_EDI = tmp; - } else { - tmp = M.x86.R_AX; - M.x86.R_AX = M.x86.R_DI; - M.x86.R_DI = (u16)tmp; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x98 -****************************************************************************/ -void x86emuOp_cbw(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("CWDE\n"); - } else { - DECODE_PRINTF("CBW\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - if (M.x86.R_AX & 0x8000) { - M.x86.R_EAX |= 0xffff0000; - } else { - M.x86.R_EAX &= 0x0000ffff; - } - } else { - if (M.x86.R_AL & 0x80) { - M.x86.R_AH = 0xff; - } else { - M.x86.R_AH = 0x0; - } - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x99 -****************************************************************************/ -void x86emuOp_cwd(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("CDQ\n"); - } else { - DECODE_PRINTF("CWD\n"); - } - DECODE_PRINTF("CWD\n"); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - if (M.x86.R_EAX & 0x80000000) { - M.x86.R_EDX = 0xffffffff; - } else { - M.x86.R_EDX = 0x0; - } - } else { - if (M.x86.R_AX & 0x8000) { - M.x86.R_DX = 0xffff; - } else { - M.x86.R_DX = 0x0; - } - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x9a -****************************************************************************/ -void x86emuOp_call_far_IMM(u8 X86EMU_UNUSED(op1)) -{ - u16 farseg, faroff; - - START_OF_INSTR(); - DECODE_PRINTF("CALL\t"); - faroff = fetch_word_imm(); - farseg = fetch_word_imm(); - DECODE_PRINTF2("%04x:", farseg); - DECODE_PRINTF2("%04x\n", faroff); - CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, farseg, faroff, "FAR "); - - /* XXX - * - * Hooked interrupt vectors calling into our "BIOS" will cause - * problems unless all intersegment stuff is checked for BIOS - * access. Check needed here. For moment, let it alone. - */ - TRACE_AND_STEP(); - push_word(M.x86.R_CS); - M.x86.R_CS = farseg; - push_word(M.x86.R_IP); - M.x86.R_IP = faroff; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x9b -****************************************************************************/ -void x86emuOp_wait(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("WAIT"); - TRACE_AND_STEP(); - /* NADA. */ - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x9c -****************************************************************************/ -void x86emuOp_pushf_word(u8 X86EMU_UNUSED(op1)) -{ - u32 flags; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("PUSHFD\n"); - } else { - DECODE_PRINTF("PUSHF\n"); - } - TRACE_AND_STEP(); - - /* clear out *all* bits not representing flags, and turn on real bits */ - flags = (M.x86.R_EFLG & F_MSK) | F_ALWAYS_ON; - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - push_long(flags); - } else { - push_word((u16)flags); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x9d -****************************************************************************/ -void x86emuOp_popf_word(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("POPFD\n"); - } else { - DECODE_PRINTF("POPF\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EFLG = pop_long(); - } else { - M.x86.R_FLG = pop_word(); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x9e -****************************************************************************/ -void x86emuOp_sahf(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("SAHF\n"); - TRACE_AND_STEP(); - /* clear the lower bits of the flag register */ - M.x86.R_FLG &= 0xffffff00; - /* or in the AH register into the flags register */ - M.x86.R_FLG |= M.x86.R_AH; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x9f -****************************************************************************/ -void x86emuOp_lahf(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("LAHF\n"); - TRACE_AND_STEP(); - M.x86.R_AH = (u8)(M.x86.R_FLG & 0xff); - /*undocumented TC++ behavior??? Nope. It's documented, but - you have too look real hard to notice it. */ - M.x86.R_AH |= 0x2; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xa0 -****************************************************************************/ -void x86emuOp_mov_AL_M_IMM(u8 X86EMU_UNUSED(op1)) -{ - u16 offset; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\tAL,"); - offset = fetch_word_imm(); - DECODE_PRINTF2("[%04x]\n", offset); - TRACE_AND_STEP(); - M.x86.R_AL = fetch_data_byte(offset); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xa1 -****************************************************************************/ -void x86emuOp_mov_AX_M_IMM(u8 X86EMU_UNUSED(op1)) -{ - u16 offset; - - START_OF_INSTR(); - offset = fetch_word_imm(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF2("MOV\tEAX,[%04x]\n", offset); - } else { - DECODE_PRINTF2("MOV\tAX,[%04x]\n", offset); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EAX = fetch_data_long(offset); - } else { - M.x86.R_AX = fetch_data_word(offset); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xa2 -****************************************************************************/ -void x86emuOp_mov_M_AL_IMM(u8 X86EMU_UNUSED(op1)) -{ - u16 offset; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\t"); - offset = fetch_word_imm(); - DECODE_PRINTF2("[%04x],AL\n", offset); - TRACE_AND_STEP(); - store_data_byte(offset, M.x86.R_AL); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xa3 -****************************************************************************/ -void x86emuOp_mov_M_AX_IMM(u8 X86EMU_UNUSED(op1)) -{ - u16 offset; - - START_OF_INSTR(); - offset = fetch_word_imm(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF2("MOV\t[%04x],EAX\n", offset); - } else { - DECODE_PRINTF2("MOV\t[%04x],AX\n", offset); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - store_data_long(offset, M.x86.R_EAX); - } else { - store_data_word(offset, M.x86.R_AX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xa4 -****************************************************************************/ -void x86emuOp_movs_byte(u8 X86EMU_UNUSED(op1)) -{ - u8 val; - u32 count; - int inc; - - START_OF_INSTR(); - DECODE_PRINTF("MOVS\tBYTE\n"); - if (ACCESS_FLAG(F_DF)) /* down */ - inc = -1; - else - inc = 1; - TRACE_AND_STEP(); - count = 1; - if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { - /* dont care whether REPE or REPNE */ - /* move them until CX is ZERO. */ - count = M.x86.R_CX; - M.x86.R_CX = 0; - M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); - } - while (count--) { - val = fetch_data_byte(M.x86.R_SI); - store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, val); - M.x86.R_SI += inc; - M.x86.R_DI += inc; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xa5 -****************************************************************************/ -void x86emuOp_movs_word(u8 X86EMU_UNUSED(op1)) -{ - u32 val; - int inc; - u32 count; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("MOVS\tDWORD\n"); - if (ACCESS_FLAG(F_DF)) /* down */ - inc = -4; - else - inc = 4; - } else { - DECODE_PRINTF("MOVS\tWORD\n"); - if (ACCESS_FLAG(F_DF)) /* down */ - inc = -2; - else - inc = 2; - } - TRACE_AND_STEP(); - count = 1; - if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { - /* dont care whether REPE or REPNE */ - /* move them until CX is ZERO. */ - count = M.x86.R_CX; - M.x86.R_CX = 0; - M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); - } - while (count--) { - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - val = fetch_data_long(M.x86.R_SI); - store_data_long_abs(M.x86.R_ES, M.x86.R_DI, val); - } else { - val = fetch_data_word(M.x86.R_SI); - store_data_word_abs(M.x86.R_ES, M.x86.R_DI, (u16)val); - } - M.x86.R_SI += inc; - M.x86.R_DI += inc; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xa6 -****************************************************************************/ -void x86emuOp_cmps_byte(u8 X86EMU_UNUSED(op1)) -{ - s8 val1, val2; - int inc; - - START_OF_INSTR(); - DECODE_PRINTF("CMPS\tBYTE\n"); - TRACE_AND_STEP(); - if (ACCESS_FLAG(F_DF)) /* down */ - inc = -1; - else - inc = 1; - - if (M.x86.mode & SYSMODE_PREFIX_REPE) { - /* REPE */ - /* move them until CX is ZERO. */ - while (M.x86.R_CX != 0) { - val1 = fetch_data_byte(M.x86.R_SI); - val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI); - cmp_byte(val1, val2); - M.x86.R_CX -= 1; - M.x86.R_SI += inc; - M.x86.R_DI += inc; - if (ACCESS_FLAG(F_ZF) == 0) - break; - } - M.x86.mode &= ~SYSMODE_PREFIX_REPE; - } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) { - /* REPNE */ - /* move them until CX is ZERO. */ - while (M.x86.R_CX != 0) { - val1 = fetch_data_byte(M.x86.R_SI); - val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI); - cmp_byte(val1, val2); - M.x86.R_CX -= 1; - M.x86.R_SI += inc; - M.x86.R_DI += inc; - if (ACCESS_FLAG(F_ZF)) - break; /* zero flag set means equal */ - } - M.x86.mode &= ~SYSMODE_PREFIX_REPNE; - } else { - val1 = fetch_data_byte(M.x86.R_SI); - val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI); - cmp_byte(val1, val2); - M.x86.R_SI += inc; - M.x86.R_DI += inc; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xa7 -****************************************************************************/ -void x86emuOp_cmps_word(u8 X86EMU_UNUSED(op1)) -{ - u32 val1,val2; - int inc; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("CMPS\tDWORD\n"); - if (ACCESS_FLAG(F_DF)) /* down */ - inc = -4; - else - inc = 4; - } else { - DECODE_PRINTF("CMPS\tWORD\n"); - if (ACCESS_FLAG(F_DF)) /* down */ - inc = -2; - else - inc = 2; - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_REPE) { - /* REPE */ - /* move them until CX is ZERO. */ - while (M.x86.R_CX != 0) { - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - val1 = fetch_data_long(M.x86.R_SI); - val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI); - cmp_long(val1, val2); - } else { - val1 = fetch_data_word(M.x86.R_SI); - val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI); - cmp_word((u16)val1, (u16)val2); - } - M.x86.R_CX -= 1; - M.x86.R_SI += inc; - M.x86.R_DI += inc; - if (ACCESS_FLAG(F_ZF) == 0) - break; - } - M.x86.mode &= ~SYSMODE_PREFIX_REPE; - } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) { - /* REPNE */ - /* move them until CX is ZERO. */ - while (M.x86.R_CX != 0) { - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - val1 = fetch_data_long(M.x86.R_SI); - val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI); - cmp_long(val1, val2); - } else { - val1 = fetch_data_word(M.x86.R_SI); - val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI); - cmp_word((u16)val1, (u16)val2); - } - M.x86.R_CX -= 1; - M.x86.R_SI += inc; - M.x86.R_DI += inc; - if (ACCESS_FLAG(F_ZF)) - break; /* zero flag set means equal */ - } - M.x86.mode &= ~SYSMODE_PREFIX_REPNE; - } else { - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - val1 = fetch_data_long(M.x86.R_SI); - val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI); - cmp_long(val1, val2); - } else { - val1 = fetch_data_word(M.x86.R_SI); - val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI); - cmp_word((u16)val1, (u16)val2); - } - M.x86.R_SI += inc; - M.x86.R_DI += inc; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xa8 -****************************************************************************/ -void x86emuOp_test_AL_IMM(u8 X86EMU_UNUSED(op1)) -{ - int imm; - - START_OF_INSTR(); - DECODE_PRINTF("TEST\tAL,"); - imm = fetch_byte_imm(); - DECODE_PRINTF2("%04x\n", imm); - TRACE_AND_STEP(); - test_byte(M.x86.R_AL, (u8)imm); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xa9 -****************************************************************************/ -void x86emuOp_test_AX_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("TEST\tEAX,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("TEST\tAX,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - test_long(M.x86.R_EAX, srcval); - } else { - test_word(M.x86.R_AX, (u16)srcval); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xaa -****************************************************************************/ -void x86emuOp_stos_byte(u8 X86EMU_UNUSED(op1)) -{ - int inc; - - START_OF_INSTR(); - DECODE_PRINTF("STOS\tBYTE\n"); - if (ACCESS_FLAG(F_DF)) /* down */ - inc = -1; - else - inc = 1; - TRACE_AND_STEP(); - if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { - /* dont care whether REPE or REPNE */ - /* move them until CX is ZERO. */ - while (M.x86.R_CX != 0) { - store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AL); - M.x86.R_CX -= 1; - M.x86.R_DI += inc; - } - M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); - } else { - store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AL); - M.x86.R_DI += inc; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xab -****************************************************************************/ -void x86emuOp_stos_word(u8 X86EMU_UNUSED(op1)) -{ - int inc; - u32 count; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("STOS\tDWORD\n"); - if (ACCESS_FLAG(F_DF)) /* down */ - inc = -4; - else - inc = 4; - } else { - DECODE_PRINTF("STOS\tWORD\n"); - if (ACCESS_FLAG(F_DF)) /* down */ - inc = -2; - else - inc = 2; - } - TRACE_AND_STEP(); - count = 1; - if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { - /* dont care whether REPE or REPNE */ - /* move them until CX is ZERO. */ - count = M.x86.R_CX; - M.x86.R_CX = 0; - M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); - } - while (count--) { - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - store_data_long_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_EAX); - } else { - store_data_word_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AX); - } - M.x86.R_DI += inc; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xac -****************************************************************************/ -void x86emuOp_lods_byte(u8 X86EMU_UNUSED(op1)) -{ - int inc; - - START_OF_INSTR(); - DECODE_PRINTF("LODS\tBYTE\n"); - TRACE_AND_STEP(); - if (ACCESS_FLAG(F_DF)) /* down */ - inc = -1; - else - inc = 1; - if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { - /* dont care whether REPE or REPNE */ - /* move them until CX is ZERO. */ - while (M.x86.R_CX != 0) { - M.x86.R_AL = fetch_data_byte(M.x86.R_SI); - M.x86.R_CX -= 1; - M.x86.R_SI += inc; - } - M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); - } else { - M.x86.R_AL = fetch_data_byte(M.x86.R_SI); - M.x86.R_SI += inc; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xad -****************************************************************************/ -void x86emuOp_lods_word(u8 X86EMU_UNUSED(op1)) -{ - int inc; - u32 count; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("LODS\tDWORD\n"); - if (ACCESS_FLAG(F_DF)) /* down */ - inc = -4; - else - inc = 4; - } else { - DECODE_PRINTF("LODS\tWORD\n"); - if (ACCESS_FLAG(F_DF)) /* down */ - inc = -2; - else - inc = 2; - } - TRACE_AND_STEP(); - count = 1; - if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { - /* dont care whether REPE or REPNE */ - /* move them until CX is ZERO. */ - count = M.x86.R_CX; - M.x86.R_CX = 0; - M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); - } - while (count--) { - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EAX = fetch_data_long(M.x86.R_SI); - } else { - M.x86.R_AX = fetch_data_word(M.x86.R_SI); - } - M.x86.R_SI += inc; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xae -****************************************************************************/ -void x86emuOp_scas_byte(u8 X86EMU_UNUSED(op1)) -{ - s8 val2; - int inc; - - START_OF_INSTR(); - DECODE_PRINTF("SCAS\tBYTE\n"); - TRACE_AND_STEP(); - if (ACCESS_FLAG(F_DF)) /* down */ - inc = -1; - else - inc = 1; - if (M.x86.mode & SYSMODE_PREFIX_REPE) { - /* REPE */ - /* move them until CX is ZERO. */ - while (M.x86.R_CX != 0) { - val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI); - cmp_byte(M.x86.R_AL, val2); - M.x86.R_CX -= 1; - M.x86.R_DI += inc; - if (ACCESS_FLAG(F_ZF) == 0) - break; - } - M.x86.mode &= ~SYSMODE_PREFIX_REPE; - } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) { - /* REPNE */ - /* move them until CX is ZERO. */ - while (M.x86.R_CX != 0) { - val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI); - cmp_byte(M.x86.R_AL, val2); - M.x86.R_CX -= 1; - M.x86.R_DI += inc; - if (ACCESS_FLAG(F_ZF)) - break; /* zero flag set means equal */ - } - M.x86.mode &= ~SYSMODE_PREFIX_REPNE; - } else { - val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI); - cmp_byte(M.x86.R_AL, val2); - M.x86.R_DI += inc; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xaf -****************************************************************************/ -void x86emuOp_scas_word(u8 X86EMU_UNUSED(op1)) -{ - int inc; - u32 val; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("SCAS\tDWORD\n"); - if (ACCESS_FLAG(F_DF)) /* down */ - inc = -4; - else - inc = 4; - } else { - DECODE_PRINTF("SCAS\tWORD\n"); - if (ACCESS_FLAG(F_DF)) /* down */ - inc = -2; - else - inc = 2; - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_REPE) { - /* REPE */ - /* move them until CX is ZERO. */ - while (M.x86.R_CX != 0) { - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI); - cmp_long(M.x86.R_EAX, val); - } else { - val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI); - cmp_word(M.x86.R_AX, (u16)val); - } - M.x86.R_CX -= 1; - M.x86.R_DI += inc; - if (ACCESS_FLAG(F_ZF) == 0) - break; - } - M.x86.mode &= ~SYSMODE_PREFIX_REPE; - } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) { - /* REPNE */ - /* move them until CX is ZERO. */ - while (M.x86.R_CX != 0) { - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI); - cmp_long(M.x86.R_EAX, val); - } else { - val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI); - cmp_word(M.x86.R_AX, (u16)val); - } - M.x86.R_CX -= 1; - M.x86.R_DI += inc; - if (ACCESS_FLAG(F_ZF)) - break; /* zero flag set means equal */ - } - M.x86.mode &= ~SYSMODE_PREFIX_REPNE; - } else { - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI); - cmp_long(M.x86.R_EAX, val); - } else { - val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI); - cmp_word(M.x86.R_AX, (u16)val); - } - M.x86.R_DI += inc; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xb0 -****************************************************************************/ -void x86emuOp_mov_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 imm; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\tAL,"); - imm = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - M.x86.R_AL = imm; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xb1 -****************************************************************************/ -void x86emuOp_mov_byte_CL_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 imm; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\tCL,"); - imm = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - M.x86.R_CL = imm; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xb2 -****************************************************************************/ -void x86emuOp_mov_byte_DL_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 imm; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\tDL,"); - imm = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - M.x86.R_DL = imm; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xb3 -****************************************************************************/ -void x86emuOp_mov_byte_BL_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 imm; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\tBL,"); - imm = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - M.x86.R_BL = imm; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xb4 -****************************************************************************/ -void x86emuOp_mov_byte_AH_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 imm; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\tAH,"); - imm = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - M.x86.R_AH = imm; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xb5 -****************************************************************************/ -void x86emuOp_mov_byte_CH_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 imm; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\tCH,"); - imm = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - M.x86.R_CH = imm; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xb6 -****************************************************************************/ -void x86emuOp_mov_byte_DH_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 imm; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\tDH,"); - imm = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - M.x86.R_DH = imm; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xb7 -****************************************************************************/ -void x86emuOp_mov_byte_BH_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 imm; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\tBH,"); - imm = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", imm); - TRACE_AND_STEP(); - M.x86.R_BH = imm; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xb8 -****************************************************************************/ -void x86emuOp_mov_word_AX_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("MOV\tEAX,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("MOV\tAX,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EAX = srcval; - } else { - M.x86.R_AX = (u16)srcval; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xb9 -****************************************************************************/ -void x86emuOp_mov_word_CX_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("MOV\tECX,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("MOV\tCX,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_ECX = srcval; - } else { - M.x86.R_CX = (u16)srcval; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xba -****************************************************************************/ -void x86emuOp_mov_word_DX_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("MOV\tEDX,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("MOV\tDX,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EDX = srcval; - } else { - M.x86.R_DX = (u16)srcval; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xbb -****************************************************************************/ -void x86emuOp_mov_word_BX_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("MOV\tEBX,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("MOV\tBX,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EBX = srcval; - } else { - M.x86.R_BX = (u16)srcval; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xbc -****************************************************************************/ -void x86emuOp_mov_word_SP_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("MOV\tESP,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("MOV\tSP,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_ESP = srcval; - } else { - M.x86.R_SP = (u16)srcval; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xbd -****************************************************************************/ -void x86emuOp_mov_word_BP_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("MOV\tEBP,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("MOV\tBP,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EBP = srcval; - } else { - M.x86.R_BP = (u16)srcval; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xbe -****************************************************************************/ -void x86emuOp_mov_word_SI_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("MOV\tESI,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("MOV\tSI,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_ESI = srcval; - } else { - M.x86.R_SI = (u16)srcval; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xbf -****************************************************************************/ -void x86emuOp_mov_word_DI_IMM(u8 X86EMU_UNUSED(op1)) -{ - u32 srcval; - - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("MOV\tEDI,"); - srcval = fetch_long_imm(); - } else { - DECODE_PRINTF("MOV\tDI,"); - srcval = fetch_word_imm(); - } - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EDI = srcval; - } else { - M.x86.R_DI = (u16)srcval; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/* used by opcodes c0, d0, and d2. */ -static u8(*opcD0_byte_operation[])(u8 d, u8 s) = -{ - rol_byte, - ror_byte, - rcl_byte, - rcr_byte, - shl_byte, - shr_byte, - shl_byte, /* sal_byte === shl_byte by definition */ - sar_byte, -}; - -/**************************************************************************** -REMARKS: -Handles opcode 0xc0 -****************************************************************************/ -void x86emuOp_opcC0_byte_RM_MEM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg; - uint destoffset; - u8 destval; - u8 amt; - - /* - * Yet another weirdo special case instruction format. Part of - * the opcode held below in "RH". Doubly nested case would - * result, except that the decoded instruction - */ - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); -#ifdef DEBUG - if (DEBUG_DECODE()) { - /* XXX DECODE_PRINTF may be changed to something more - general, so that it is important to leave the strings - in the same format, even though the result is that the - above test is done twice. */ - - switch (rh) { - case 0: - DECODE_PRINTF("ROL\t"); - break; - case 1: - DECODE_PRINTF("ROR\t"); - break; - case 2: - DECODE_PRINTF("RCL\t"); - break; - case 3: - DECODE_PRINTF("RCR\t"); - break; - case 4: - DECODE_PRINTF("SHL\t"); - break; - case 5: - DECODE_PRINTF("SHR\t"); - break; - case 6: - DECODE_PRINTF("SAL\t"); - break; - case 7: - DECODE_PRINTF("SAR\t"); - break; - } - } -#endif - /* know operation, decode the mod byte to find the addressing - mode. */ - switch (mod) { - case 0: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm00_address(rl); - amt = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", amt); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = (*opcD0_byte_operation[rh]) (destval, amt); - store_data_byte(destoffset, destval); - break; - case 1: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm01_address(rl); - amt = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", amt); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = (*opcD0_byte_operation[rh]) (destval, amt); - store_data_byte(destoffset, destval); - break; - case 2: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm10_address(rl); - amt = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", amt); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = (*opcD0_byte_operation[rh]) (destval, amt); - store_data_byte(destoffset, destval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - amt = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", amt); - TRACE_AND_STEP(); - destval = (*opcD0_byte_operation[rh]) (*destreg, amt); - *destreg = destval; - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/* used by opcodes c1, d1, and d3. */ -static u16(*opcD1_word_operation[])(u16 s, u8 d) = -{ - rol_word, - ror_word, - rcl_word, - rcr_word, - shl_word, - shr_word, - shl_word, /* sal_byte === shl_byte by definition */ - sar_word, -}; - -/* used by opcodes c1, d1, and d3. */ -static u32 (*opcD1_long_operation[])(u32 s, u8 d) = -{ - rol_long, - ror_long, - rcl_long, - rcr_long, - shl_long, - shr_long, - shl_long, /* sal_byte === shl_byte by definition */ - sar_long, -}; - -/**************************************************************************** -REMARKS: -Handles opcode 0xc1 -****************************************************************************/ -void x86emuOp_opcC1_word_RM_MEM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - u8 amt; - - /* - * Yet another weirdo special case instruction format. Part of - * the opcode held below in "RH". Doubly nested case would - * result, except that the decoded instruction - */ - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); -#ifdef DEBUG - if (DEBUG_DECODE()) { - /* XXX DECODE_PRINTF may be changed to something more - general, so that it is important to leave the strings - in the same format, even though the result is that the - above test is done twice. */ - - switch (rh) { - case 0: - DECODE_PRINTF("ROL\t"); - break; - case 1: - DECODE_PRINTF("ROR\t"); - break; - case 2: - DECODE_PRINTF("RCL\t"); - break; - case 3: - DECODE_PRINTF("RCR\t"); - break; - case 4: - DECODE_PRINTF("SHL\t"); - break; - case 5: - DECODE_PRINTF("SHR\t"); - break; - case 6: - DECODE_PRINTF("SAL\t"); - break; - case 7: - DECODE_PRINTF("SAR\t"); - break; - } - } -#endif - /* know operation, decode the mod byte to find the addressing - mode. */ - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm00_address(rl); - amt = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", amt); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_long_operation[rh]) (destval, amt); - store_data_long(destoffset, destval); - } else { - u16 destval; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm00_address(rl); - amt = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", amt); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_word_operation[rh]) (destval, amt); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm01_address(rl); - amt = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", amt); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_long_operation[rh]) (destval, amt); - store_data_long(destoffset, destval); - } else { - u16 destval; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm01_address(rl); - amt = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", amt); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_word_operation[rh]) (destval, amt); - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm10_address(rl); - amt = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", amt); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_long_operation[rh]) (destval, amt); - store_data_long(destoffset, destval); - } else { - u16 destval; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm10_address(rl); - amt = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", amt); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_word_operation[rh]) (destval, amt); - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - amt = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", amt); - TRACE_AND_STEP(); - *destreg = (*opcD1_long_operation[rh]) (*destreg, amt); - } else { - u16 *destreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - amt = fetch_byte_imm(); - DECODE_PRINTF2(",%x\n", amt); - TRACE_AND_STEP(); - *destreg = (*opcD1_word_operation[rh]) (*destreg, amt); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xc2 -****************************************************************************/ -void x86emuOp_ret_near_IMM(u8 X86EMU_UNUSED(op1)) -{ - u16 imm; - - START_OF_INSTR(); - DECODE_PRINTF("RET\t"); - imm = fetch_word_imm(); - DECODE_PRINTF2("%x\n", imm); - RETURN_TRACE("RET",M.x86.saved_cs,M.x86.saved_ip); - TRACE_AND_STEP(); - M.x86.R_IP = pop_word(); - M.x86.R_SP += imm; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xc3 -****************************************************************************/ -void x86emuOp_ret_near(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("RET\n"); - RETURN_TRACE("RET",M.x86.saved_cs,M.x86.saved_ip); - TRACE_AND_STEP(); - M.x86.R_IP = pop_word(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xc4 -****************************************************************************/ -void x86emuOp_les_R_IMM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rh, rl; - u16 *dstreg; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("LES\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - dstreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *dstreg = fetch_data_word(srcoffset); - M.x86.R_ES = fetch_data_word(srcoffset + 2); - break; - case 1: - dstreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *dstreg = fetch_data_word(srcoffset); - M.x86.R_ES = fetch_data_word(srcoffset + 2); - break; - case 2: - dstreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *dstreg = fetch_data_word(srcoffset); - M.x86.R_ES = fetch_data_word(srcoffset + 2); - break; - case 3: /* register to register */ - /* UNDEFINED! */ - TRACE_AND_STEP(); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xc5 -****************************************************************************/ -void x86emuOp_lds_R_IMM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rh, rl; - u16 *dstreg; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("LDS\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - dstreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *dstreg = fetch_data_word(srcoffset); - M.x86.R_DS = fetch_data_word(srcoffset + 2); - break; - case 1: - dstreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *dstreg = fetch_data_word(srcoffset); - M.x86.R_DS = fetch_data_word(srcoffset + 2); - break; - case 2: - dstreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *dstreg = fetch_data_word(srcoffset); - M.x86.R_DS = fetch_data_word(srcoffset + 2); - break; - case 3: /* register to register */ - /* UNDEFINED! */ - TRACE_AND_STEP(); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xc6 -****************************************************************************/ -void x86emuOp_mov_byte_RM_IMM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg; - uint destoffset; - u8 imm; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - if (rh != 0) { - DECODE_PRINTF("ILLEGAL DECODE OF OPCODE c6\n"); - HALT_SYS(); - } - switch (mod) { - case 0: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm00_address(rl); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%2x\n", imm); - TRACE_AND_STEP(); - store_data_byte(destoffset, imm); - break; - case 1: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm01_address(rl); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%2x\n", imm); - TRACE_AND_STEP(); - store_data_byte(destoffset, imm); - break; - case 2: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm10_address(rl); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%2x\n", imm); - TRACE_AND_STEP(); - store_data_byte(destoffset, imm); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - imm = fetch_byte_imm(); - DECODE_PRINTF2(",%2x\n", imm); - TRACE_AND_STEP(); - *destreg = imm; - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xc7 -****************************************************************************/ -void x86emuOp_mov_word_RM_IMM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("MOV\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - if (rh != 0) { - DECODE_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n"); - HALT_SYS(); - } - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 imm; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm00_address(rl); - imm = fetch_long_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - store_data_long(destoffset, imm); - } else { - u16 imm; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm00_address(rl); - imm = fetch_word_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - store_data_word(destoffset, imm); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 imm; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm01_address(rl); - imm = fetch_long_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - store_data_long(destoffset, imm); - } else { - u16 imm; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm01_address(rl); - imm = fetch_word_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - store_data_word(destoffset, imm); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 imm; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm10_address(rl); - imm = fetch_long_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - store_data_long(destoffset, imm); - } else { - u16 imm; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm10_address(rl); - imm = fetch_word_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - store_data_word(destoffset, imm); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 imm; - - destreg = DECODE_RM_LONG_REGISTER(rl); - imm = fetch_long_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - *destreg = imm; - } else { - u16 *destreg; - u16 imm; - - destreg = DECODE_RM_WORD_REGISTER(rl); - imm = fetch_word_imm(); - DECODE_PRINTF2(",%x\n", imm); - TRACE_AND_STEP(); - *destreg = imm; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xc8 -****************************************************************************/ -void x86emuOp_enter(u8 X86EMU_UNUSED(op1)) -{ - u16 local,frame_pointer; - u8 nesting; - int i; - - START_OF_INSTR(); - local = fetch_word_imm(); - nesting = fetch_byte_imm(); - DECODE_PRINTF2("ENTER %x\n", local); - DECODE_PRINTF2(",%x\n", nesting); - TRACE_AND_STEP(); - push_word(M.x86.R_BP); - frame_pointer = M.x86.R_SP; - if (nesting > 0) { - for (i = 1; i < nesting; i++) { - M.x86.R_BP -= 2; - push_word(fetch_data_word_abs(M.x86.R_SS, M.x86.R_BP)); - } - push_word(frame_pointer); - } - M.x86.R_BP = frame_pointer; - M.x86.R_SP = (u16)(M.x86.R_SP - local); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xc9 -****************************************************************************/ -void x86emuOp_leave(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("LEAVE\n"); - TRACE_AND_STEP(); - M.x86.R_SP = M.x86.R_BP; - M.x86.R_BP = pop_word(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xca -****************************************************************************/ -void x86emuOp_ret_far_IMM(u8 X86EMU_UNUSED(op1)) -{ - u16 imm; - - START_OF_INSTR(); - DECODE_PRINTF("RETF\t"); - imm = fetch_word_imm(); - DECODE_PRINTF2("%x\n", imm); - RETURN_TRACE("RETF",M.x86.saved_cs,M.x86.saved_ip); - TRACE_AND_STEP(); - M.x86.R_IP = pop_word(); - M.x86.R_CS = pop_word(); - M.x86.R_SP += imm; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xcb -****************************************************************************/ -void x86emuOp_ret_far(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("RETF\n"); - RETURN_TRACE("RETF",M.x86.saved_cs,M.x86.saved_ip); - TRACE_AND_STEP(); - M.x86.R_IP = pop_word(); - M.x86.R_CS = pop_word(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xcc -****************************************************************************/ -void x86emuOp_int3(u8 X86EMU_UNUSED(op1)) -{ - u16 tmp; - - START_OF_INSTR(); - DECODE_PRINTF("INT 3\n"); - tmp = (u16) mem_access_word(3 * 4 + 2); - /* access the segment register */ - TRACE_AND_STEP(); - if (_X86EMU_intrTab[3]) { - (*_X86EMU_intrTab[3])(3); - } else { - push_word((u16)M.x86.R_FLG); - CLEAR_FLAG(F_IF); - CLEAR_FLAG(F_TF); - push_word(M.x86.R_CS); - M.x86.R_CS = mem_access_word(3 * 4 + 2); - push_word(M.x86.R_IP); - M.x86.R_IP = mem_access_word(3 * 4); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xcd -****************************************************************************/ -void x86emuOp_int_IMM(u8 X86EMU_UNUSED(op1)) -{ - u16 tmp; - u8 intnum; - - START_OF_INSTR(); - DECODE_PRINTF("INT\t"); - intnum = fetch_byte_imm(); - DECODE_PRINTF2("%x\n", intnum); - tmp = mem_access_word(intnum * 4 + 2); - TRACE_AND_STEP(); - if (_X86EMU_intrTab[intnum]) { - (*_X86EMU_intrTab[intnum])(intnum); - } else { - push_word((u16)M.x86.R_FLG); - CLEAR_FLAG(F_IF); - CLEAR_FLAG(F_TF); - push_word(M.x86.R_CS); - M.x86.R_CS = mem_access_word(intnum * 4 + 2); - push_word(M.x86.R_IP); - M.x86.R_IP = mem_access_word(intnum * 4); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xce -****************************************************************************/ -void x86emuOp_into(u8 X86EMU_UNUSED(op1)) -{ - u16 tmp; - - START_OF_INSTR(); - DECODE_PRINTF("INTO\n"); - TRACE_AND_STEP(); - if (ACCESS_FLAG(F_OF)) { - tmp = mem_access_word(4 * 4 + 2); - if (_X86EMU_intrTab[4]) { - (*_X86EMU_intrTab[4])(4); - } else { - push_word((u16)M.x86.R_FLG); - CLEAR_FLAG(F_IF); - CLEAR_FLAG(F_TF); - push_word(M.x86.R_CS); - M.x86.R_CS = mem_access_word(4 * 4 + 2); - push_word(M.x86.R_IP); - M.x86.R_IP = mem_access_word(4 * 4); - } - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xcf -****************************************************************************/ -void x86emuOp_iret(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("IRET\n"); - - TRACE_AND_STEP(); - - M.x86.R_IP = pop_word(); - M.x86.R_CS = pop_word(); - M.x86.R_FLG = pop_word(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xd0 -****************************************************************************/ -void x86emuOp_opcD0_byte_RM_1(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg; - uint destoffset; - u8 destval; - - /* - * Yet another weirdo special case instruction format. Part of - * the opcode held below in "RH". Doubly nested case would - * result, except that the decoded instruction - */ - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); -#ifdef DEBUG - if (DEBUG_DECODE()) { - /* XXX DECODE_PRINTF may be changed to something more - general, so that it is important to leave the strings - in the same format, even though the result is that the - above test is done twice. */ - switch (rh) { - case 0: - DECODE_PRINTF("ROL\t"); - break; - case 1: - DECODE_PRINTF("ROR\t"); - break; - case 2: - DECODE_PRINTF("RCL\t"); - break; - case 3: - DECODE_PRINTF("RCR\t"); - break; - case 4: - DECODE_PRINTF("SHL\t"); - break; - case 5: - DECODE_PRINTF("SHR\t"); - break; - case 6: - DECODE_PRINTF("SAL\t"); - break; - case 7: - DECODE_PRINTF("SAR\t"); - break; - } - } -#endif - /* know operation, decode the mod byte to find the addressing - mode. */ - switch (mod) { - case 0: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(",1\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = (*opcD0_byte_operation[rh]) (destval, 1); - store_data_byte(destoffset, destval); - break; - case 1: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(",1\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = (*opcD0_byte_operation[rh]) (destval, 1); - store_data_byte(destoffset, destval); - break; - case 2: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(",1\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = (*opcD0_byte_operation[rh]) (destval, 1); - store_data_byte(destoffset, destval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF(",1\n"); - TRACE_AND_STEP(); - destval = (*opcD0_byte_operation[rh]) (*destreg, 1); - *destreg = destval; - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xd1 -****************************************************************************/ -void x86emuOp_opcD1_word_RM_1(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - /* - * Yet another weirdo special case instruction format. Part of - * the opcode held below in "RH". Doubly nested case would - * result, except that the decoded instruction - */ - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); -#ifdef DEBUG - if (DEBUG_DECODE()) { - /* XXX DECODE_PRINTF may be changed to something more - general, so that it is important to leave the strings - in the same format, even though the result is that the - above test is done twice. */ - switch (rh) { - case 0: - DECODE_PRINTF("ROL\t"); - break; - case 1: - DECODE_PRINTF("ROR\t"); - break; - case 2: - DECODE_PRINTF("RCL\t"); - break; - case 3: - DECODE_PRINTF("RCR\t"); - break; - case 4: - DECODE_PRINTF("SHL\t"); - break; - case 5: - DECODE_PRINTF("SHR\t"); - break; - case 6: - DECODE_PRINTF("SAL\t"); - break; - case 7: - DECODE_PRINTF("SAR\t"); - break; - } - } -#endif - /* know operation, decode the mod byte to find the addressing - mode. */ - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(",1\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_long_operation[rh]) (destval, 1); - store_data_long(destoffset, destval); - } else { - u16 destval; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(",1\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_word_operation[rh]) (destval, 1); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(",1\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_long_operation[rh]) (destval, 1); - store_data_long(destoffset, destval); - } else { - u16 destval; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(",1\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_word_operation[rh]) (destval, 1); - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(",1\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_long_operation[rh]) (destval, 1); - store_data_long(destoffset, destval); - } else { - u16 destval; - - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(",1\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_word_operation[rh]) (destval, 1); - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *destreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(",1\n"); - TRACE_AND_STEP(); - destval = (*opcD1_long_operation[rh]) (*destreg, 1); - *destreg = destval; - } else { - u16 destval; - u16 *destreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(",1\n"); - TRACE_AND_STEP(); - destval = (*opcD1_word_operation[rh]) (*destreg, 1); - *destreg = destval; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xd2 -****************************************************************************/ -void x86emuOp_opcD2_byte_RM_CL(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg; - uint destoffset; - u8 destval; - u8 amt; - - /* - * Yet another weirdo special case instruction format. Part of - * the opcode held below in "RH". Doubly nested case would - * result, except that the decoded instruction - */ - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); -#ifdef DEBUG - if (DEBUG_DECODE()) { - /* XXX DECODE_PRINTF may be changed to something more - general, so that it is important to leave the strings - in the same format, even though the result is that the - above test is done twice. */ - switch (rh) { - case 0: - DECODE_PRINTF("ROL\t"); - break; - case 1: - DECODE_PRINTF("ROR\t"); - break; - case 2: - DECODE_PRINTF("RCL\t"); - break; - case 3: - DECODE_PRINTF("RCR\t"); - break; - case 4: - DECODE_PRINTF("SHL\t"); - break; - case 5: - DECODE_PRINTF("SHR\t"); - break; - case 6: - DECODE_PRINTF("SAL\t"); - break; - case 7: - DECODE_PRINTF("SAR\t"); - break; - } - } -#endif - /* know operation, decode the mod byte to find the addressing - mode. */ - amt = M.x86.R_CL; - switch (mod) { - case 0: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(",CL\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = (*opcD0_byte_operation[rh]) (destval, amt); - store_data_byte(destoffset, destval); - break; - case 1: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(",CL\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = (*opcD0_byte_operation[rh]) (destval, amt); - store_data_byte(destoffset, destval); - break; - case 2: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(",CL\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = (*opcD0_byte_operation[rh]) (destval, amt); - store_data_byte(destoffset, destval); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - destval = (*opcD0_byte_operation[rh]) (*destreg, amt); - *destreg = destval; - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xd3 -****************************************************************************/ -void x86emuOp_opcD3_word_RM_CL(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - u8 amt; - - /* - * Yet another weirdo special case instruction format. Part of - * the opcode held below in "RH". Doubly nested case would - * result, except that the decoded instruction - */ - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); -#ifdef DEBUG - if (DEBUG_DECODE()) { - /* XXX DECODE_PRINTF may be changed to something more - general, so that it is important to leave the strings - in the same format, even though the result is that the - above test is done twice. */ - switch (rh) { - case 0: - DECODE_PRINTF("ROL\t"); - break; - case 1: - DECODE_PRINTF("ROR\t"); - break; - case 2: - DECODE_PRINTF("RCL\t"); - break; - case 3: - DECODE_PRINTF("RCR\t"); - break; - case 4: - DECODE_PRINTF("SHL\t"); - break; - case 5: - DECODE_PRINTF("SHR\t"); - break; - case 6: - DECODE_PRINTF("SAL\t"); - break; - case 7: - DECODE_PRINTF("SAR\t"); - break; - } - } -#endif - /* know operation, decode the mod byte to find the addressing - mode. */ - amt = M.x86.R_CL; - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(",CL\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_long_operation[rh]) (destval, amt); - store_data_long(destoffset, destval); - } else { - u16 destval; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(",CL\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_word_operation[rh]) (destval, amt); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(",CL\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_long_operation[rh]) (destval, amt); - store_data_long(destoffset, destval); - } else { - u16 destval; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(",CL\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_word_operation[rh]) (destval, amt); - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("DWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(",CL\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_long_operation[rh]) (destval, amt); - store_data_long(destoffset, destval); - } else { - u16 destval; - - DECODE_PRINTF("WORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(",CL\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = (*opcD1_word_operation[rh]) (destval, amt); - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - *destreg = (*opcD1_long_operation[rh]) (*destreg, amt); - } else { - u16 *destreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - *destreg = (*opcD1_word_operation[rh]) (*destreg, amt); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xd4 -****************************************************************************/ -void x86emuOp_aam(u8 X86EMU_UNUSED(op1)) -{ - u8 a; - - START_OF_INSTR(); - DECODE_PRINTF("AAM\n"); - a = fetch_byte_imm(); /* this is a stupid encoding. */ - if (a != 10) { - DECODE_PRINTF("ERROR DECODING AAM\n"); - TRACE_REGS(); - HALT_SYS(); - } - TRACE_AND_STEP(); - /* note the type change here --- returning AL and AH in AX. */ - M.x86.R_AX = aam_word(M.x86.R_AL); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xd5 -****************************************************************************/ -void x86emuOp_aad(u8 X86EMU_UNUSED(op1)) -{ - u8 a; - - START_OF_INSTR(); - DECODE_PRINTF("AAD\n"); - a = fetch_byte_imm(); - TRACE_AND_STEP(); - M.x86.R_AX = aad_word(M.x86.R_AX); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/* opcode 0xd6 ILLEGAL OPCODE */ - -/**************************************************************************** -REMARKS: -Handles opcode 0xd7 -****************************************************************************/ -void x86emuOp_xlat(u8 X86EMU_UNUSED(op1)) -{ - u16 addr; - - START_OF_INSTR(); - DECODE_PRINTF("XLAT\n"); - TRACE_AND_STEP(); - addr = (u16)(M.x86.R_BX + (u8)M.x86.R_AL); - M.x86.R_AL = fetch_data_byte(addr); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/* instuctions D8 .. DF are in i87_ops.c */ - -/**************************************************************************** -REMARKS: -Handles opcode 0xe0 -****************************************************************************/ -void x86emuOp_loopne(u8 X86EMU_UNUSED(op1)) -{ - s16 ip; - - START_OF_INSTR(); - DECODE_PRINTF("LOOPNE\t"); - ip = (s8) fetch_byte_imm(); - ip += (s16) M.x86.R_IP; - DECODE_PRINTF2("%04x\n", ip); - TRACE_AND_STEP(); - M.x86.R_CX -= 1; - if (M.x86.R_CX != 0 && !ACCESS_FLAG(F_ZF)) /* CX != 0 and !ZF */ - M.x86.R_IP = ip; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xe1 -****************************************************************************/ -void x86emuOp_loope(u8 X86EMU_UNUSED(op1)) -{ - s16 ip; - - START_OF_INSTR(); - DECODE_PRINTF("LOOPE\t"); - ip = (s8) fetch_byte_imm(); - ip += (s16) M.x86.R_IP; - DECODE_PRINTF2("%04x\n", ip); - TRACE_AND_STEP(); - M.x86.R_CX -= 1; - if (M.x86.R_CX != 0 && ACCESS_FLAG(F_ZF)) /* CX != 0 and ZF */ - M.x86.R_IP = ip; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xe2 -****************************************************************************/ -void x86emuOp_loop(u8 X86EMU_UNUSED(op1)) -{ - s16 ip; - - START_OF_INSTR(); - DECODE_PRINTF("LOOP\t"); - ip = (s8) fetch_byte_imm(); - ip += (s16) M.x86.R_IP; - DECODE_PRINTF2("%04x\n", ip); - TRACE_AND_STEP(); - M.x86.R_CX -= 1; - if (M.x86.R_CX != 0) - M.x86.R_IP = ip; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xe3 -****************************************************************************/ -void x86emuOp_jcxz(u8 X86EMU_UNUSED(op1)) -{ - u16 target; - s8 offset; - - /* jump to byte offset if overflow flag is set */ - START_OF_INSTR(); - DECODE_PRINTF("JCXZ\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - if (M.x86.R_CX == 0) - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xe4 -****************************************************************************/ -void x86emuOp_in_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 port; - - START_OF_INSTR(); - DECODE_PRINTF("IN\t"); - port = (u8) fetch_byte_imm(); - DECODE_PRINTF2("%x,AL\n", port); - TRACE_AND_STEP(); - M.x86.R_AL = (*sys_inb)(port); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xe5 -****************************************************************************/ -void x86emuOp_in_word_AX_IMM(u8 X86EMU_UNUSED(op1)) -{ - u8 port; - - START_OF_INSTR(); - DECODE_PRINTF("IN\t"); - port = (u8) fetch_byte_imm(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF2("EAX,%x\n", port); - } else { - DECODE_PRINTF2("AX,%x\n", port); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EAX = (*sys_inl)(port); - } else { - M.x86.R_AX = (*sys_inw)(port); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xe6 -****************************************************************************/ -void x86emuOp_out_byte_IMM_AL(u8 X86EMU_UNUSED(op1)) -{ - u8 port; - - START_OF_INSTR(); - DECODE_PRINTF("OUT\t"); - port = (u8) fetch_byte_imm(); - DECODE_PRINTF2("%x,AL\n", port); - TRACE_AND_STEP(); - (*sys_outb)(port, M.x86.R_AL); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xe7 -****************************************************************************/ -void x86emuOp_out_word_IMM_AX(u8 X86EMU_UNUSED(op1)) -{ - u8 port; - - START_OF_INSTR(); - DECODE_PRINTF("OUT\t"); - port = (u8) fetch_byte_imm(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF2("%x,EAX\n", port); - } else { - DECODE_PRINTF2("%x,AX\n", port); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - (*sys_outl)(port, M.x86.R_EAX); - } else { - (*sys_outw)(port, M.x86.R_AX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xe8 -****************************************************************************/ -void x86emuOp_call_near_IMM(u8 X86EMU_UNUSED(op1)) -{ - s16 ip; - - START_OF_INSTR(); - DECODE_PRINTF("CALL\t"); - ip = (s16) fetch_word_imm(); - ip += (s16) M.x86.R_IP; /* CHECK SIGN */ - DECODE_PRINTF2("%04x\n", ip); - CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, ip, ""); - TRACE_AND_STEP(); - push_word(M.x86.R_IP); - M.x86.R_IP = ip; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xe9 -****************************************************************************/ -void x86emuOp_jump_near_IMM(u8 X86EMU_UNUSED(op1)) -{ - int ip; - - START_OF_INSTR(); - DECODE_PRINTF("JMP\t"); - ip = (s16)fetch_word_imm(); - ip += (s16)M.x86.R_IP; - DECODE_PRINTF2("%04x\n", ip); - TRACE_AND_STEP(); - M.x86.R_IP = (u16)ip; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xea -****************************************************************************/ -void x86emuOp_jump_far_IMM(u8 X86EMU_UNUSED(op1)) -{ - u16 cs, ip; - - START_OF_INSTR(); - DECODE_PRINTF("JMP\tFAR "); - ip = fetch_word_imm(); - cs = fetch_word_imm(); - DECODE_PRINTF2("%04x:", cs); - DECODE_PRINTF2("%04x\n", ip); - TRACE_AND_STEP(); - M.x86.R_IP = ip; - M.x86.R_CS = cs; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xeb -****************************************************************************/ -void x86emuOp_jump_byte_IMM(u8 X86EMU_UNUSED(op1)) -{ - u16 target; - s8 offset; - - START_OF_INSTR(); - DECODE_PRINTF("JMP\t"); - offset = (s8)fetch_byte_imm(); - target = (u16)(M.x86.R_IP + offset); - DECODE_PRINTF2("%x\n", target); - TRACE_AND_STEP(); - M.x86.R_IP = target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xec -****************************************************************************/ -void x86emuOp_in_byte_AL_DX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("IN\tAL,DX\n"); - TRACE_AND_STEP(); - M.x86.R_AL = (*sys_inb)(M.x86.R_DX); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xed -****************************************************************************/ -void x86emuOp_in_word_AX_DX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("IN\tEAX,DX\n"); - } else { - DECODE_PRINTF("IN\tAX,DX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_EAX = (*sys_inl)(M.x86.R_DX); - } else { - M.x86.R_AX = (*sys_inw)(M.x86.R_DX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xee -****************************************************************************/ -void x86emuOp_out_byte_DX_AL(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("OUT\tDX,AL\n"); - TRACE_AND_STEP(); - (*sys_outb)(M.x86.R_DX, M.x86.R_AL); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xef -****************************************************************************/ -void x86emuOp_out_word_DX_AX(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("OUT\tDX,EAX\n"); - } else { - DECODE_PRINTF("OUT\tDX,AX\n"); - } - TRACE_AND_STEP(); - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - (*sys_outl)(M.x86.R_DX, M.x86.R_EAX); - } else { - (*sys_outw)(M.x86.R_DX, M.x86.R_AX); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xf0 -****************************************************************************/ -void x86emuOp_lock(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("LOCK:\n"); - TRACE_AND_STEP(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/*opcode 0xf1 ILLEGAL OPERATION */ - -/**************************************************************************** -REMARKS: -Handles opcode 0xf2 -****************************************************************************/ -void x86emuOp_repne(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("REPNE\n"); - TRACE_AND_STEP(); - M.x86.mode |= SYSMODE_PREFIX_REPNE; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xf3 -****************************************************************************/ -void x86emuOp_repe(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("REPE\n"); - TRACE_AND_STEP(); - M.x86.mode |= SYSMODE_PREFIX_REPE; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xf4 -****************************************************************************/ -void x86emuOp_halt(u8 X86EMU_UNUSED(op1)) -{ - START_OF_INSTR(); - DECODE_PRINTF("HALT\n"); - TRACE_AND_STEP(); - HALT_SYS(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xf5 -****************************************************************************/ -void x86emuOp_cmc(u8 X86EMU_UNUSED(op1)) -{ - /* complement the carry flag. */ - START_OF_INSTR(); - DECODE_PRINTF("CMC\n"); - TRACE_AND_STEP(); - TOGGLE_FLAG(F_CF); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xf6 -****************************************************************************/ -void x86emuOp_opcF6_byte_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - u8 *destreg; - uint destoffset; - u8 destval, srcval; - - /* long, drawn out code follows. Double switch for a total - of 32 cases. */ - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: /* mod=00 */ - switch (rh) { - case 0: /* test byte imm */ - DECODE_PRINTF("TEST\tBYTE PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - srcval = fetch_byte_imm(); - DECODE_PRINTF2("%02x\n", srcval); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - test_byte(destval, srcval); - break; - case 1: - DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n"); - HALT_SYS(); - break; - case 2: - DECODE_PRINTF("NOT\tBYTE PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = not_byte(destval); - store_data_byte(destoffset, destval); - break; - case 3: - DECODE_PRINTF("NEG\tBYTE PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = neg_byte(destval); - store_data_byte(destoffset, destval); - break; - case 4: - DECODE_PRINTF("MUL\tBYTE PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - mul_byte(destval); - break; - case 5: - DECODE_PRINTF("IMUL\tBYTE PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - imul_byte(destval); - break; - case 6: - DECODE_PRINTF("DIV\tBYTE PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - div_byte(destval); - break; - case 7: - DECODE_PRINTF("IDIV\tBYTE PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - idiv_byte(destval); - break; - } - break; /* end mod==00 */ - case 1: /* mod=01 */ - switch (rh) { - case 0: /* test byte imm */ - DECODE_PRINTF("TEST\tBYTE PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - srcval = fetch_byte_imm(); - DECODE_PRINTF2("%02x\n", srcval); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - test_byte(destval, srcval); - break; - case 1: - DECODE_PRINTF("ILLEGAL OP MOD=01 RH=01 OP=F6\n"); - HALT_SYS(); - break; - case 2: - DECODE_PRINTF("NOT\tBYTE PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = not_byte(destval); - store_data_byte(destoffset, destval); - break; - case 3: - DECODE_PRINTF("NEG\tBYTE PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = neg_byte(destval); - store_data_byte(destoffset, destval); - break; - case 4: - DECODE_PRINTF("MUL\tBYTE PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - mul_byte(destval); - break; - case 5: - DECODE_PRINTF("IMUL\tBYTE PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - imul_byte(destval); - break; - case 6: - DECODE_PRINTF("DIV\tBYTE PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - div_byte(destval); - break; - case 7: - DECODE_PRINTF("IDIV\tBYTE PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - idiv_byte(destval); - break; - } - break; /* end mod==01 */ - case 2: /* mod=10 */ - switch (rh) { - case 0: /* test byte imm */ - DECODE_PRINTF("TEST\tBYTE PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - srcval = fetch_byte_imm(); - DECODE_PRINTF2("%02x\n", srcval); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - test_byte(destval, srcval); - break; - case 1: - DECODE_PRINTF("ILLEGAL OP MOD=10 RH=01 OP=F6\n"); - HALT_SYS(); - break; - case 2: - DECODE_PRINTF("NOT\tBYTE PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = not_byte(destval); - store_data_byte(destoffset, destval); - break; - case 3: - DECODE_PRINTF("NEG\tBYTE PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = neg_byte(destval); - store_data_byte(destoffset, destval); - break; - case 4: - DECODE_PRINTF("MUL\tBYTE PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - mul_byte(destval); - break; - case 5: - DECODE_PRINTF("IMUL\tBYTE PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - imul_byte(destval); - break; - case 6: - DECODE_PRINTF("DIV\tBYTE PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - div_byte(destval); - break; - case 7: - DECODE_PRINTF("IDIV\tBYTE PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - idiv_byte(destval); - break; - } - break; /* end mod==10 */ - case 3: /* mod=11 */ - switch (rh) { - case 0: /* test byte imm */ - DECODE_PRINTF("TEST\t"); - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF(","); - srcval = fetch_byte_imm(); - DECODE_PRINTF2("%02x\n", srcval); - TRACE_AND_STEP(); - test_byte(*destreg, srcval); - break; - case 1: - DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n"); - HALT_SYS(); - break; - case 2: - DECODE_PRINTF("NOT\t"); - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = not_byte(*destreg); - break; - case 3: - DECODE_PRINTF("NEG\t"); - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = neg_byte(*destreg); - break; - case 4: - DECODE_PRINTF("MUL\t"); - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - mul_byte(*destreg); /*!!! */ - break; - case 5: - DECODE_PRINTF("IMUL\t"); - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - imul_byte(*destreg); - break; - case 6: - DECODE_PRINTF("DIV\t"); - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - div_byte(*destreg); - break; - case 7: - DECODE_PRINTF("IDIV\t"); - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - idiv_byte(*destreg); - break; - } - break; /* end mod==11 */ - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xf7 -****************************************************************************/ -void x86emuOp_opcF7_word_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rl, rh; - uint destoffset; - - /* long, drawn out code follows. Double switch for a total - of 32 cases. */ - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: /* mod=00 */ - switch (rh) { - case 0: /* test word imm */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval,srcval; - - DECODE_PRINTF("TEST\tDWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - srcval = fetch_long_imm(); - DECODE_PRINTF2("%x\n", srcval); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - test_long(destval, srcval); - } else { - u16 destval,srcval; - - DECODE_PRINTF("TEST\tWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - srcval = fetch_word_imm(); - DECODE_PRINTF2("%x\n", srcval); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - test_word(destval, srcval); - } - break; - case 1: - DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F7\n"); - HALT_SYS(); - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("NOT\tDWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = not_long(destval); - store_data_long(destoffset, destval); - } else { - u16 destval; - - DECODE_PRINTF("NOT\tWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = not_word(destval); - store_data_word(destoffset, destval); - } - break; - case 3: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("NEG\tDWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = neg_long(destval); - store_data_long(destoffset, destval); - } else { - u16 destval; - - DECODE_PRINTF("NEG\tWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = neg_word(destval); - store_data_word(destoffset, destval); - } - break; - case 4: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("MUL\tDWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - mul_long(destval); - } else { - u16 destval; - - DECODE_PRINTF("MUL\tWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - mul_word(destval); - } - break; - case 5: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("IMUL\tDWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - imul_long(destval); - } else { - u16 destval; - - DECODE_PRINTF("IMUL\tWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - imul_word(destval); - } - break; - case 6: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("DIV\tDWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - div_long(destval); - } else { - u16 destval; - - DECODE_PRINTF("DIV\tWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - div_word(destval); - } - break; - case 7: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("IDIV\tDWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - idiv_long(destval); - } else { - u16 destval; - - DECODE_PRINTF("IDIV\tWORD PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - idiv_word(destval); - } - break; - } - break; /* end mod==00 */ - case 1: /* mod=01 */ - switch (rh) { - case 0: /* test word imm */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval,srcval; - - DECODE_PRINTF("TEST\tDWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - srcval = fetch_long_imm(); - DECODE_PRINTF2("%x\n", srcval); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - test_long(destval, srcval); - } else { - u16 destval,srcval; - - DECODE_PRINTF("TEST\tWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - srcval = fetch_word_imm(); - DECODE_PRINTF2("%x\n", srcval); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - test_word(destval, srcval); - } - break; - case 1: - DECODE_PRINTF("ILLEGAL OP MOD=01 RH=01 OP=F6\n"); - HALT_SYS(); - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("NOT\tDWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = not_long(destval); - store_data_long(destoffset, destval); - } else { - u16 destval; - - DECODE_PRINTF("NOT\tWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = not_word(destval); - store_data_word(destoffset, destval); - } - break; - case 3: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("NEG\tDWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = neg_long(destval); - store_data_long(destoffset, destval); - } else { - u16 destval; - - DECODE_PRINTF("NEG\tWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = neg_word(destval); - store_data_word(destoffset, destval); - } - break; - case 4: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("MUL\tDWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - mul_long(destval); - } else { - u16 destval; - - DECODE_PRINTF("MUL\tWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - mul_word(destval); - } - break; - case 5: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("IMUL\tDWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - imul_long(destval); - } else { - u16 destval; - - DECODE_PRINTF("IMUL\tWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - imul_word(destval); - } - break; - case 6: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("DIV\tDWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - div_long(destval); - } else { - u16 destval; - - DECODE_PRINTF("DIV\tWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - div_word(destval); - } - break; - case 7: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("IDIV\tDWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - idiv_long(destval); - } else { - u16 destval; - - DECODE_PRINTF("IDIV\tWORD PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - idiv_word(destval); - } - break; - } - break; /* end mod==01 */ - case 2: /* mod=10 */ - switch (rh) { - case 0: /* test word imm */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval,srcval; - - DECODE_PRINTF("TEST\tDWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - srcval = fetch_long_imm(); - DECODE_PRINTF2("%x\n", srcval); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - test_long(destval, srcval); - } else { - u16 destval,srcval; - - DECODE_PRINTF("TEST\tWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - srcval = fetch_word_imm(); - DECODE_PRINTF2("%x\n", srcval); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - test_word(destval, srcval); - } - break; - case 1: - DECODE_PRINTF("ILLEGAL OP MOD=10 RH=01 OP=F6\n"); - HALT_SYS(); - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("NOT\tDWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = not_long(destval); - store_data_long(destoffset, destval); - } else { - u16 destval; - - DECODE_PRINTF("NOT\tWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = not_word(destval); - store_data_word(destoffset, destval); - } - break; - case 3: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("NEG\tDWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = neg_long(destval); - store_data_long(destoffset, destval); - } else { - u16 destval; - - DECODE_PRINTF("NEG\tWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = neg_word(destval); - store_data_word(destoffset, destval); - } - break; - case 4: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("MUL\tDWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - mul_long(destval); - } else { - u16 destval; - - DECODE_PRINTF("MUL\tWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - mul_word(destval); - } - break; - case 5: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("IMUL\tDWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - imul_long(destval); - } else { - u16 destval; - - DECODE_PRINTF("IMUL\tWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - imul_word(destval); - } - break; - case 6: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("DIV\tDWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - div_long(destval); - } else { - u16 destval; - - DECODE_PRINTF("DIV\tWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - div_word(destval); - } - break; - case 7: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - DECODE_PRINTF("IDIV\tDWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - idiv_long(destval); - } else { - u16 destval; - - DECODE_PRINTF("IDIV\tWORD PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - idiv_word(destval); - } - break; - } - break; /* end mod==10 */ - case 3: /* mod=11 */ - switch (rh) { - case 0: /* test word imm */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - DECODE_PRINTF("TEST\t"); - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - srcval = fetch_long_imm(); - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - test_long(*destreg, srcval); - } else { - u16 *destreg; - u16 srcval; - - DECODE_PRINTF("TEST\t"); - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - srcval = fetch_word_imm(); - DECODE_PRINTF2("%x\n", srcval); - TRACE_AND_STEP(); - test_word(*destreg, srcval); - } - break; - case 1: - DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n"); - HALT_SYS(); - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - - DECODE_PRINTF("NOT\t"); - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = not_long(*destreg); - } else { - u16 *destreg; - - DECODE_PRINTF("NOT\t"); - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = not_word(*destreg); - } - break; - case 3: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - - DECODE_PRINTF("NEG\t"); - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = neg_long(*destreg); - } else { - u16 *destreg; - - DECODE_PRINTF("NEG\t"); - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = neg_word(*destreg); - } - break; - case 4: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - - DECODE_PRINTF("MUL\t"); - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - mul_long(*destreg); /*!!! */ - } else { - u16 *destreg; - - DECODE_PRINTF("MUL\t"); - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - mul_word(*destreg); /*!!! */ - } - break; - case 5: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - - DECODE_PRINTF("IMUL\t"); - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - imul_long(*destreg); - } else { - u16 *destreg; - - DECODE_PRINTF("IMUL\t"); - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - imul_word(*destreg); - } - break; - case 6: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - - DECODE_PRINTF("DIV\t"); - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - div_long(*destreg); - } else { - u16 *destreg; - - DECODE_PRINTF("DIV\t"); - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - div_word(*destreg); - } - break; - case 7: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - - DECODE_PRINTF("IDIV\t"); - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - idiv_long(*destreg); - } else { - u16 *destreg; - - DECODE_PRINTF("IDIV\t"); - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - idiv_word(*destreg); - } - break; - } - break; /* end mod==11 */ - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xf8 -****************************************************************************/ -void x86emuOp_clc(u8 X86EMU_UNUSED(op1)) -{ - /* clear the carry flag. */ - START_OF_INSTR(); - DECODE_PRINTF("CLC\n"); - TRACE_AND_STEP(); - CLEAR_FLAG(F_CF); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xf9 -****************************************************************************/ -void x86emuOp_stc(u8 X86EMU_UNUSED(op1)) -{ - /* set the carry flag. */ - START_OF_INSTR(); - DECODE_PRINTF("STC\n"); - TRACE_AND_STEP(); - SET_FLAG(F_CF); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xfa -****************************************************************************/ -void x86emuOp_cli(u8 X86EMU_UNUSED(op1)) -{ - /* clear interrupts. */ - START_OF_INSTR(); - DECODE_PRINTF("CLI\n"); - TRACE_AND_STEP(); - CLEAR_FLAG(F_IF); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xfb -****************************************************************************/ -void x86emuOp_sti(u8 X86EMU_UNUSED(op1)) -{ - /* enable interrupts. */ - START_OF_INSTR(); - DECODE_PRINTF("STI\n"); - TRACE_AND_STEP(); - SET_FLAG(F_IF); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xfc -****************************************************************************/ -void x86emuOp_cld(u8 X86EMU_UNUSED(op1)) -{ - /* clear interrupts. */ - START_OF_INSTR(); - DECODE_PRINTF("CLD\n"); - TRACE_AND_STEP(); - CLEAR_FLAG(F_DF); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xfd -****************************************************************************/ -void x86emuOp_std(u8 X86EMU_UNUSED(op1)) -{ - /* clear interrupts. */ - START_OF_INSTR(); - DECODE_PRINTF("STD\n"); - TRACE_AND_STEP(); - SET_FLAG(F_DF); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xfe -****************************************************************************/ -void x86emuOp_opcFE_byte_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rh, rl; - u8 destval; - uint destoffset; - u8 *destreg; - - /* Yet another special case instruction. */ - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); -#ifdef DEBUG - if (DEBUG_DECODE()) { - /* XXX DECODE_PRINTF may be changed to something more - general, so that it is important to leave the strings - in the same format, even though the result is that the - above test is done twice. */ - - switch (rh) { - case 0: - DECODE_PRINTF("INC\t"); - break; - case 1: - DECODE_PRINTF("DEC\t"); - break; - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - DECODE_PRINTF2("ILLEGAL OP MAJOR OP 0xFE MINOR OP %x \n", mod); - HALT_SYS(); - break; - } - } -#endif - switch (mod) { - case 0: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - switch (rh) { - case 0: /* inc word ptr ... */ - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = inc_byte(destval); - store_data_byte(destoffset, destval); - break; - case 1: /* dec word ptr ... */ - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = dec_byte(destval); - store_data_byte(destoffset, destval); - break; - } - break; - case 1: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - switch (rh) { - case 0: - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = inc_byte(destval); - store_data_byte(destoffset, destval); - break; - case 1: - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = dec_byte(destval); - store_data_byte(destoffset, destval); - break; - } - break; - case 2: - DECODE_PRINTF("BYTE PTR "); - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - switch (rh) { - case 0: - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = inc_byte(destval); - store_data_byte(destoffset, destval); - break; - case 1: - destval = fetch_data_byte(destoffset); - TRACE_AND_STEP(); - destval = dec_byte(destval); - store_data_byte(destoffset, destval); - break; - } - break; - case 3: - destreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - switch (rh) { - case 0: - TRACE_AND_STEP(); - *destreg = inc_byte(*destreg); - break; - case 1: - TRACE_AND_STEP(); - *destreg = dec_byte(*destreg); - break; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0xff -****************************************************************************/ -void x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1)) -{ - int mod, rh, rl; - uint destoffset = 0; - u16 *destreg; - u16 destval,destval2; - - /* Yet another special case instruction. */ - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); -#ifdef DEBUG - if (DEBUG_DECODE()) { - /* XXX DECODE_PRINTF may be changed to something more - general, so that it is important to leave the strings - in the same format, even though the result is that the - above test is done twice. */ - - switch (rh) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("INC\tDWORD PTR "); - } else { - DECODE_PRINTF("INC\tWORD PTR "); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - DECODE_PRINTF("DEC\tDWORD PTR "); - } else { - DECODE_PRINTF("DEC\tWORD PTR "); - } - break; - case 2: - DECODE_PRINTF("CALL\t "); - break; - case 3: - DECODE_PRINTF("CALL\tFAR "); - break; - case 4: - DECODE_PRINTF("JMP\t"); - break; - case 5: - DECODE_PRINTF("JMP\tFAR "); - break; - case 6: - DECODE_PRINTF("PUSH\t"); - break; - case 7: - DECODE_PRINTF("ILLEGAL DECODING OF OPCODE FF\t"); - HALT_SYS(); - break; - } - } -#endif - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - switch (rh) { - case 0: /* inc word ptr ... */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = inc_long(destval); - store_data_long(destoffset, destval); - } else { - u16 destval; - - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = inc_word(destval); - store_data_word(destoffset, destval); - } - break; - case 1: /* dec word ptr ... */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = dec_long(destval); - store_data_long(destoffset, destval); - } else { - u16 destval; - - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = dec_word(destval); - store_data_word(destoffset, destval); - } - break; - case 2: /* call word ptr ... */ - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - push_word(M.x86.R_IP); - M.x86.R_IP = destval; - break; - case 3: /* call far ptr ... */ - destval = fetch_data_word(destoffset); - destval2 = fetch_data_word(destoffset + 2); - TRACE_AND_STEP(); - push_word(M.x86.R_CS); - M.x86.R_CS = destval2; - push_word(M.x86.R_IP); - M.x86.R_IP = destval; - break; - case 4: /* jmp word ptr ... */ - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - M.x86.R_IP = destval; - break; - case 5: /* jmp far ptr ... */ - destval = fetch_data_word(destoffset); - destval2 = fetch_data_word(destoffset + 2); - TRACE_AND_STEP(); - M.x86.R_IP = destval; - M.x86.R_CS = destval2; - break; - case 6: /* push word ptr ... */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - push_long(destval); - } else { - u16 destval; - - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - push_word(destval); - } - break; - } - break; - case 1: - destoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - switch (rh) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = inc_long(destval); - store_data_long(destoffset, destval); - } else { - u16 destval; - - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = inc_word(destval); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = dec_long(destval); - store_data_long(destoffset, destval); - } else { - u16 destval; - - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = dec_word(destval); - store_data_word(destoffset, destval); - } - break; - case 2: /* call word ptr ... */ - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - push_word(M.x86.R_IP); - M.x86.R_IP = destval; - break; - case 3: /* call far ptr ... */ - destval = fetch_data_word(destoffset); - destval2 = fetch_data_word(destoffset + 2); - TRACE_AND_STEP(); - push_word(M.x86.R_CS); - M.x86.R_CS = destval2; - push_word(M.x86.R_IP); - M.x86.R_IP = destval; - break; - case 4: /* jmp word ptr ... */ - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - M.x86.R_IP = destval; - break; - case 5: /* jmp far ptr ... */ - destval = fetch_data_word(destoffset); - destval2 = fetch_data_word(destoffset + 2); - TRACE_AND_STEP(); - M.x86.R_IP = destval; - M.x86.R_CS = destval2; - break; - case 6: /* push word ptr ... */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - push_long(destval); - } else { - u16 destval; - - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - push_word(destval); - } - break; - } - break; - case 2: - destoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - switch (rh) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = inc_long(destval); - store_data_long(destoffset, destval); - } else { - u16 destval; - - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = inc_word(destval); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - destval = dec_long(destval); - store_data_long(destoffset, destval); - } else { - u16 destval; - - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - destval = dec_word(destval); - store_data_word(destoffset, destval); - } - break; - case 2: /* call word ptr ... */ - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - push_word(M.x86.R_IP); - M.x86.R_IP = destval; - break; - case 3: /* call far ptr ... */ - destval = fetch_data_word(destoffset); - destval2 = fetch_data_word(destoffset + 2); - TRACE_AND_STEP(); - push_word(M.x86.R_CS); - M.x86.R_CS = destval2; - push_word(M.x86.R_IP); - M.x86.R_IP = destval; - break; - case 4: /* jmp word ptr ... */ - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - M.x86.R_IP = destval; - break; - case 5: /* jmp far ptr ... */ - destval = fetch_data_word(destoffset); - destval2 = fetch_data_word(destoffset + 2); - TRACE_AND_STEP(); - M.x86.R_IP = destval; - M.x86.R_CS = destval2; - break; - case 6: /* push word ptr ... */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - - destval = fetch_data_long(destoffset); - TRACE_AND_STEP(); - push_long(destval); - } else { - u16 destval; - - destval = fetch_data_word(destoffset); - TRACE_AND_STEP(); - push_word(destval); - } - break; - } - break; - case 3: - switch (rh) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = inc_long(*destreg); - } else { - u16 *destreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = inc_word(*destreg); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = dec_long(*destreg); - } else { - u16 *destreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = dec_word(*destreg); - } - break; - case 2: /* call word ptr ... */ - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - push_word(M.x86.R_IP); - M.x86.R_IP = *destreg; - break; - case 3: /* jmp far ptr ... */ - DECODE_PRINTF("OPERATION UNDEFINED 0XFF \n"); - TRACE_AND_STEP(); - HALT_SYS(); - break; - - case 4: /* jmp ... */ - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - M.x86.R_IP = (u16) (*destreg); - break; - case 5: /* jmp far ptr ... */ - DECODE_PRINTF("OPERATION UNDEFINED 0XFF \n"); - TRACE_AND_STEP(); - HALT_SYS(); - break; - case 6: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - push_long(*destreg); - } else { - u16 *destreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - push_word(*destreg); - } - break; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/*************************************************************************** - * Single byte operation code table: - **************************************************************************/ -void (*x86emu_optab[256])(u8) = -{ -/* 0x00 */ x86emuOp_add_byte_RM_R, -/* 0x01 */ x86emuOp_add_word_RM_R, -/* 0x02 */ x86emuOp_add_byte_R_RM, -/* 0x03 */ x86emuOp_add_word_R_RM, -/* 0x04 */ x86emuOp_add_byte_AL_IMM, -/* 0x05 */ x86emuOp_add_word_AX_IMM, -/* 0x06 */ x86emuOp_push_ES, -/* 0x07 */ x86emuOp_pop_ES, - -/* 0x08 */ x86emuOp_or_byte_RM_R, -/* 0x09 */ x86emuOp_or_word_RM_R, -/* 0x0a */ x86emuOp_or_byte_R_RM, -/* 0x0b */ x86emuOp_or_word_R_RM, -/* 0x0c */ x86emuOp_or_byte_AL_IMM, -/* 0x0d */ x86emuOp_or_word_AX_IMM, -/* 0x0e */ x86emuOp_push_CS, -/* 0x0f */ x86emuOp_two_byte, - -/* 0x10 */ x86emuOp_adc_byte_RM_R, -/* 0x11 */ x86emuOp_adc_word_RM_R, -/* 0x12 */ x86emuOp_adc_byte_R_RM, -/* 0x13 */ x86emuOp_adc_word_R_RM, -/* 0x14 */ x86emuOp_adc_byte_AL_IMM, -/* 0x15 */ x86emuOp_adc_word_AX_IMM, -/* 0x16 */ x86emuOp_push_SS, -/* 0x17 */ x86emuOp_pop_SS, - -/* 0x18 */ x86emuOp_sbb_byte_RM_R, -/* 0x19 */ x86emuOp_sbb_word_RM_R, -/* 0x1a */ x86emuOp_sbb_byte_R_RM, -/* 0x1b */ x86emuOp_sbb_word_R_RM, -/* 0x1c */ x86emuOp_sbb_byte_AL_IMM, -/* 0x1d */ x86emuOp_sbb_word_AX_IMM, -/* 0x1e */ x86emuOp_push_DS, -/* 0x1f */ x86emuOp_pop_DS, - -/* 0x20 */ x86emuOp_and_byte_RM_R, -/* 0x21 */ x86emuOp_and_word_RM_R, -/* 0x22 */ x86emuOp_and_byte_R_RM, -/* 0x23 */ x86emuOp_and_word_R_RM, -/* 0x24 */ x86emuOp_and_byte_AL_IMM, -/* 0x25 */ x86emuOp_and_word_AX_IMM, -/* 0x26 */ x86emuOp_segovr_ES, -/* 0x27 */ x86emuOp_daa, - -/* 0x28 */ x86emuOp_sub_byte_RM_R, -/* 0x29 */ x86emuOp_sub_word_RM_R, -/* 0x2a */ x86emuOp_sub_byte_R_RM, -/* 0x2b */ x86emuOp_sub_word_R_RM, -/* 0x2c */ x86emuOp_sub_byte_AL_IMM, -/* 0x2d */ x86emuOp_sub_word_AX_IMM, -/* 0x2e */ x86emuOp_segovr_CS, -/* 0x2f */ x86emuOp_das, - -/* 0x30 */ x86emuOp_xor_byte_RM_R, -/* 0x31 */ x86emuOp_xor_word_RM_R, -/* 0x32 */ x86emuOp_xor_byte_R_RM, -/* 0x33 */ x86emuOp_xor_word_R_RM, -/* 0x34 */ x86emuOp_xor_byte_AL_IMM, -/* 0x35 */ x86emuOp_xor_word_AX_IMM, -/* 0x36 */ x86emuOp_segovr_SS, -/* 0x37 */ x86emuOp_aaa, - -/* 0x38 */ x86emuOp_cmp_byte_RM_R, -/* 0x39 */ x86emuOp_cmp_word_RM_R, -/* 0x3a */ x86emuOp_cmp_byte_R_RM, -/* 0x3b */ x86emuOp_cmp_word_R_RM, -/* 0x3c */ x86emuOp_cmp_byte_AL_IMM, -/* 0x3d */ x86emuOp_cmp_word_AX_IMM, -/* 0x3e */ x86emuOp_segovr_DS, -/* 0x3f */ x86emuOp_aas, - -/* 0x40 */ x86emuOp_inc_AX, -/* 0x41 */ x86emuOp_inc_CX, -/* 0x42 */ x86emuOp_inc_DX, -/* 0x43 */ x86emuOp_inc_BX, -/* 0x44 */ x86emuOp_inc_SP, -/* 0x45 */ x86emuOp_inc_BP, -/* 0x46 */ x86emuOp_inc_SI, -/* 0x47 */ x86emuOp_inc_DI, - -/* 0x48 */ x86emuOp_dec_AX, -/* 0x49 */ x86emuOp_dec_CX, -/* 0x4a */ x86emuOp_dec_DX, -/* 0x4b */ x86emuOp_dec_BX, -/* 0x4c */ x86emuOp_dec_SP, -/* 0x4d */ x86emuOp_dec_BP, -/* 0x4e */ x86emuOp_dec_SI, -/* 0x4f */ x86emuOp_dec_DI, - -/* 0x50 */ x86emuOp_push_AX, -/* 0x51 */ x86emuOp_push_CX, -/* 0x52 */ x86emuOp_push_DX, -/* 0x53 */ x86emuOp_push_BX, -/* 0x54 */ x86emuOp_push_SP, -/* 0x55 */ x86emuOp_push_BP, -/* 0x56 */ x86emuOp_push_SI, -/* 0x57 */ x86emuOp_push_DI, - -/* 0x58 */ x86emuOp_pop_AX, -/* 0x59 */ x86emuOp_pop_CX, -/* 0x5a */ x86emuOp_pop_DX, -/* 0x5b */ x86emuOp_pop_BX, -/* 0x5c */ x86emuOp_pop_SP, -/* 0x5d */ x86emuOp_pop_BP, -/* 0x5e */ x86emuOp_pop_SI, -/* 0x5f */ x86emuOp_pop_DI, - -/* 0x60 */ x86emuOp_push_all, -/* 0x61 */ x86emuOp_pop_all, -/* 0x62 */ x86emuOp_illegal_op, /* bound */ -/* 0x63 */ x86emuOp_illegal_op, /* arpl */ -/* 0x64 */ x86emuOp_segovr_FS, -/* 0x65 */ x86emuOp_segovr_GS, -/* 0x66 */ x86emuOp_prefix_data, -/* 0x67 */ x86emuOp_prefix_addr, - -/* 0x68 */ x86emuOp_push_word_IMM, -/* 0x69 */ x86emuOp_imul_word_IMM, -/* 0x6a */ x86emuOp_push_byte_IMM, -/* 0x6b */ x86emuOp_imul_byte_IMM, -/* 0x6c */ x86emuOp_ins_byte, -/* 0x6d */ x86emuOp_ins_word, -/* 0x6e */ x86emuOp_outs_byte, -/* 0x6f */ x86emuOp_outs_word, - -/* 0x70 */ x86emuOp_jump_near_O, -/* 0x71 */ x86emuOp_jump_near_NO, -/* 0x72 */ x86emuOp_jump_near_B, -/* 0x73 */ x86emuOp_jump_near_NB, -/* 0x74 */ x86emuOp_jump_near_Z, -/* 0x75 */ x86emuOp_jump_near_NZ, -/* 0x76 */ x86emuOp_jump_near_BE, -/* 0x77 */ x86emuOp_jump_near_NBE, - -/* 0x78 */ x86emuOp_jump_near_S, -/* 0x79 */ x86emuOp_jump_near_NS, -/* 0x7a */ x86emuOp_jump_near_P, -/* 0x7b */ x86emuOp_jump_near_NP, -/* 0x7c */ x86emuOp_jump_near_L, -/* 0x7d */ x86emuOp_jump_near_NL, -/* 0x7e */ x86emuOp_jump_near_LE, -/* 0x7f */ x86emuOp_jump_near_NLE, - -/* 0x80 */ x86emuOp_opc80_byte_RM_IMM, -/* 0x81 */ x86emuOp_opc81_word_RM_IMM, -/* 0x82 */ x86emuOp_opc82_byte_RM_IMM, -/* 0x83 */ x86emuOp_opc83_word_RM_IMM, -/* 0x84 */ x86emuOp_test_byte_RM_R, -/* 0x85 */ x86emuOp_test_word_RM_R, -/* 0x86 */ x86emuOp_xchg_byte_RM_R, -/* 0x87 */ x86emuOp_xchg_word_RM_R, - -/* 0x88 */ x86emuOp_mov_byte_RM_R, -/* 0x89 */ x86emuOp_mov_word_RM_R, -/* 0x8a */ x86emuOp_mov_byte_R_RM, -/* 0x8b */ x86emuOp_mov_word_R_RM, -/* 0x8c */ x86emuOp_mov_word_RM_SR, -/* 0x8d */ x86emuOp_lea_word_R_M, -/* 0x8e */ x86emuOp_mov_word_SR_RM, -/* 0x8f */ x86emuOp_pop_RM, - -/* 0x90 */ x86emuOp_nop, -/* 0x91 */ x86emuOp_xchg_word_AX_CX, -/* 0x92 */ x86emuOp_xchg_word_AX_DX, -/* 0x93 */ x86emuOp_xchg_word_AX_BX, -/* 0x94 */ x86emuOp_xchg_word_AX_SP, -/* 0x95 */ x86emuOp_xchg_word_AX_BP, -/* 0x96 */ x86emuOp_xchg_word_AX_SI, -/* 0x97 */ x86emuOp_xchg_word_AX_DI, - -/* 0x98 */ x86emuOp_cbw, -/* 0x99 */ x86emuOp_cwd, -/* 0x9a */ x86emuOp_call_far_IMM, -/* 0x9b */ x86emuOp_wait, -/* 0x9c */ x86emuOp_pushf_word, -/* 0x9d */ x86emuOp_popf_word, -/* 0x9e */ x86emuOp_sahf, -/* 0x9f */ x86emuOp_lahf, - -/* 0xa0 */ x86emuOp_mov_AL_M_IMM, -/* 0xa1 */ x86emuOp_mov_AX_M_IMM, -/* 0xa2 */ x86emuOp_mov_M_AL_IMM, -/* 0xa3 */ x86emuOp_mov_M_AX_IMM, -/* 0xa4 */ x86emuOp_movs_byte, -/* 0xa5 */ x86emuOp_movs_word, -/* 0xa6 */ x86emuOp_cmps_byte, -/* 0xa7 */ x86emuOp_cmps_word, -/* 0xa8 */ x86emuOp_test_AL_IMM, -/* 0xa9 */ x86emuOp_test_AX_IMM, -/* 0xaa */ x86emuOp_stos_byte, -/* 0xab */ x86emuOp_stos_word, -/* 0xac */ x86emuOp_lods_byte, -/* 0xad */ x86emuOp_lods_word, -/* 0xac */ x86emuOp_scas_byte, -/* 0xad */ x86emuOp_scas_word, - - -/* 0xb0 */ x86emuOp_mov_byte_AL_IMM, -/* 0xb1 */ x86emuOp_mov_byte_CL_IMM, -/* 0xb2 */ x86emuOp_mov_byte_DL_IMM, -/* 0xb3 */ x86emuOp_mov_byte_BL_IMM, -/* 0xb4 */ x86emuOp_mov_byte_AH_IMM, -/* 0xb5 */ x86emuOp_mov_byte_CH_IMM, -/* 0xb6 */ x86emuOp_mov_byte_DH_IMM, -/* 0xb7 */ x86emuOp_mov_byte_BH_IMM, - -/* 0xb8 */ x86emuOp_mov_word_AX_IMM, -/* 0xb9 */ x86emuOp_mov_word_CX_IMM, -/* 0xba */ x86emuOp_mov_word_DX_IMM, -/* 0xbb */ x86emuOp_mov_word_BX_IMM, -/* 0xbc */ x86emuOp_mov_word_SP_IMM, -/* 0xbd */ x86emuOp_mov_word_BP_IMM, -/* 0xbe */ x86emuOp_mov_word_SI_IMM, -/* 0xbf */ x86emuOp_mov_word_DI_IMM, - -/* 0xc0 */ x86emuOp_opcC0_byte_RM_MEM, -/* 0xc1 */ x86emuOp_opcC1_word_RM_MEM, -/* 0xc2 */ x86emuOp_ret_near_IMM, -/* 0xc3 */ x86emuOp_ret_near, -/* 0xc4 */ x86emuOp_les_R_IMM, -/* 0xc5 */ x86emuOp_lds_R_IMM, -/* 0xc6 */ x86emuOp_mov_byte_RM_IMM, -/* 0xc7 */ x86emuOp_mov_word_RM_IMM, -/* 0xc8 */ x86emuOp_enter, -/* 0xc9 */ x86emuOp_leave, -/* 0xca */ x86emuOp_ret_far_IMM, -/* 0xcb */ x86emuOp_ret_far, -/* 0xcc */ x86emuOp_int3, -/* 0xcd */ x86emuOp_int_IMM, -/* 0xce */ x86emuOp_into, -/* 0xcf */ x86emuOp_iret, - -/* 0xd0 */ x86emuOp_opcD0_byte_RM_1, -/* 0xd1 */ x86emuOp_opcD1_word_RM_1, -/* 0xd2 */ x86emuOp_opcD2_byte_RM_CL, -/* 0xd3 */ x86emuOp_opcD3_word_RM_CL, -/* 0xd4 */ x86emuOp_aam, -/* 0xd5 */ x86emuOp_aad, -/* 0xd6 */ x86emuOp_illegal_op, /* Undocumented SETALC instruction */ -/* 0xd7 */ x86emuOp_xlat, -/* 0xd8 */ x86emuOp_esc_coprocess_d8, -/* 0xd9 */ x86emuOp_esc_coprocess_d9, -/* 0xda */ x86emuOp_esc_coprocess_da, -/* 0xdb */ x86emuOp_esc_coprocess_db, -/* 0xdc */ x86emuOp_esc_coprocess_dc, -/* 0xdd */ x86emuOp_esc_coprocess_dd, -/* 0xde */ x86emuOp_esc_coprocess_de, -/* 0xdf */ x86emuOp_esc_coprocess_df, - -/* 0xe0 */ x86emuOp_loopne, -/* 0xe1 */ x86emuOp_loope, -/* 0xe2 */ x86emuOp_loop, -/* 0xe3 */ x86emuOp_jcxz, -/* 0xe4 */ x86emuOp_in_byte_AL_IMM, -/* 0xe5 */ x86emuOp_in_word_AX_IMM, -/* 0xe6 */ x86emuOp_out_byte_IMM_AL, -/* 0xe7 */ x86emuOp_out_word_IMM_AX, - -/* 0xe8 */ x86emuOp_call_near_IMM, -/* 0xe9 */ x86emuOp_jump_near_IMM, -/* 0xea */ x86emuOp_jump_far_IMM, -/* 0xeb */ x86emuOp_jump_byte_IMM, -/* 0xec */ x86emuOp_in_byte_AL_DX, -/* 0xed */ x86emuOp_in_word_AX_DX, -/* 0xee */ x86emuOp_out_byte_DX_AL, -/* 0xef */ x86emuOp_out_word_DX_AX, - -/* 0xf0 */ x86emuOp_lock, -/* 0xf1 */ x86emuOp_illegal_op, -/* 0xf2 */ x86emuOp_repne, -/* 0xf3 */ x86emuOp_repe, -/* 0xf4 */ x86emuOp_halt, -/* 0xf5 */ x86emuOp_cmc, -/* 0xf6 */ x86emuOp_opcF6_byte_RM, -/* 0xf7 */ x86emuOp_opcF7_word_RM, - -/* 0xf8 */ x86emuOp_clc, -/* 0xf9 */ x86emuOp_stc, -/* 0xfa */ x86emuOp_cli, -/* 0xfb */ x86emuOp_sti, -/* 0xfc */ x86emuOp_cld, -/* 0xfd */ x86emuOp_std, -/* 0xfe */ x86emuOp_opcFE_byte_RM, -/* 0xff */ x86emuOp_opcFF_word_RM, -}; - -void tables_relocate(unsigned int offset) -{ - int i; - for (i=0; i<8; i++) - { - opc80_byte_operation[i] -= offset; - opc81_word_operation[i] -= offset; - opc81_long_operation[i] -= offset; - - opc82_byte_operation[i] -= offset; - opc83_word_operation[i] -= offset; - opc83_long_operation[i] -= offset; - - opcD0_byte_operation[i] -= offset; - opcD1_word_operation[i] -= offset; - opcD1_long_operation[i] -= offset; - } -} diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/ops2.c b/board/MAI/bios_emulator/scitech/src/x86emu/ops2.c deleted file mode 100644 index d381307fae..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/ops2.c +++ /dev/null @@ -1,2800 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: This file includes subroutines to implement the decoding -* and emulation of all the x86 extended two-byte processor -* instructions. -* -****************************************************************************/ - -#include "x86emu/x86emui.h" - -/*----------------------------- Implementation ----------------------------*/ - -/**************************************************************************** -PARAMETERS: -op1 - Instruction op code - -REMARKS: -Handles illegal opcodes. -****************************************************************************/ -void x86emuOp2_illegal_op( - u8 op2) -{ - START_OF_INSTR(); - DECODE_PRINTF("ILLEGAL EXTENDED X86 OPCODE\n"); - TRACE_REGS(); - printk("%04x:%04x: %02X ILLEGAL EXTENDED X86 OPCODE!\n", - M.x86.R_CS, M.x86.R_IP-2,op2); - HALT_SYS(); - END_OF_INSTR(); -} - -#define xorl(a,b) ((a) && !(b)) || (!(a) && (b)) - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0x80-0x8F -****************************************************************************/ -void x86emuOp2_long_jump(u8 op2) -{ - s32 target; - char *name = 0; - int cond = 0; - - /* conditional jump to word offset. */ - START_OF_INSTR(); - switch (op2) { - case 0x80: - name = "JO\t"; - cond = ACCESS_FLAG(F_OF); - break; - case 0x81: - name = "JNO\t"; - cond = !ACCESS_FLAG(F_OF); - break; - case 0x82: - name = "JB\t"; - cond = ACCESS_FLAG(F_CF); - break; - case 0x83: - name = "JNB\t"; - cond = !ACCESS_FLAG(F_CF); - break; - case 0x84: - name = "JZ\t"; - cond = ACCESS_FLAG(F_ZF); - break; - case 0x85: - name = "JNZ\t"; - cond = !ACCESS_FLAG(F_ZF); - break; - case 0x86: - name = "JBE\t"; - cond = ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF); - break; - case 0x87: - name = "JNBE\t"; - cond = !(ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF)); - break; - case 0x88: - name = "JS\t"; - cond = ACCESS_FLAG(F_SF); - break; - case 0x89: - name = "JNS\t"; - cond = !ACCESS_FLAG(F_SF); - break; - case 0x8a: - name = "JP\t"; - cond = ACCESS_FLAG(F_PF); - break; - case 0x8b: - name = "JNP\t"; - cond = !ACCESS_FLAG(F_PF); - break; - case 0x8c: - name = "JL\t"; - cond = xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)); - break; - case 0x8d: - name = "JNL\t"; - cond = xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)); - break; - case 0x8e: - name = "JLE\t"; - cond = (xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)) || - ACCESS_FLAG(F_ZF)); - break; - case 0x8f: - name = "JNLE\t"; - cond = !(xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)) || - ACCESS_FLAG(F_ZF)); - break; - } - DECODE_PRINTF(name); - target = (s16) fetch_word_imm(); - target += (s16) M.x86.R_IP; - DECODE_PRINTF2("%04x\n", target); - TRACE_AND_STEP(); - if (cond) - M.x86.R_IP = (u16)target; - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0x90-0x9F -****************************************************************************/ -void x86emuOp2_set_byte(u8 op2) -{ - int mod, rl, rh; - uint destoffset; - u8 *destreg; - char *name = 0; - int cond = 0; - - START_OF_INSTR(); - switch (op2) { - case 0x90: - name = "SETO\t"; - cond = ACCESS_FLAG(F_OF); - break; - case 0x91: - name = "SETNO\t"; - cond = !ACCESS_FLAG(F_OF); - break; - case 0x92: - name = "SETB\t"; - cond = ACCESS_FLAG(F_CF); - break; - case 0x93: - name = "SETNB\t"; - cond = !ACCESS_FLAG(F_CF); - break; - case 0x94: - name = "SETZ\t"; - cond = ACCESS_FLAG(F_ZF); - break; - case 0x95: - name = "SETNZ\t"; - cond = !ACCESS_FLAG(F_ZF); - break; - case 0x96: - name = "SETBE\t"; - cond = ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF); - break; - case 0x97: - name = "SETNBE\t"; - cond = !(ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF)); - break; - case 0x98: - name = "SETS\t"; - cond = ACCESS_FLAG(F_SF); - break; - case 0x99: - name = "SETNS\t"; - cond = !ACCESS_FLAG(F_SF); - break; - case 0x9a: - name = "SETP\t"; - cond = ACCESS_FLAG(F_PF); - break; - case 0x9b: - name = "SETNP\t"; - cond = !ACCESS_FLAG(F_PF); - break; - case 0x9c: - name = "SETL\t"; - cond = xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)); - break; - case 0x9d: - name = "SETNL\t"; - cond = xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)); - break; - case 0x9e: - name = "SETLE\t"; - cond = (xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)) || - ACCESS_FLAG(F_ZF)); - break; - case 0x9f: - name = "SETNLE\t"; - cond = !(xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)) || - ACCESS_FLAG(F_ZF)); - break; - } - DECODE_PRINTF(name); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destoffset = decode_rm00_address(rl); - TRACE_AND_STEP(); - store_data_byte(destoffset, cond ? 0x01 : 0x00); - break; - case 1: - destoffset = decode_rm01_address(rl); - TRACE_AND_STEP(); - store_data_byte(destoffset, cond ? 0x01 : 0x00); - break; - case 2: - destoffset = decode_rm10_address(rl); - TRACE_AND_STEP(); - store_data_byte(destoffset, cond ? 0x01 : 0x00); - break; - case 3: /* register to register */ - destreg = DECODE_RM_BYTE_REGISTER(rl); - TRACE_AND_STEP(); - *destreg = cond ? 0x01 : 0x00; - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xa0 -****************************************************************************/ -void x86emuOp2_push_FS(u8 X86EMU_UNUSED(op2)) -{ - START_OF_INSTR(); - DECODE_PRINTF("PUSH\tFS\n"); - TRACE_AND_STEP(); - push_word(M.x86.R_FS); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xa1 -****************************************************************************/ -void x86emuOp2_pop_FS(u8 X86EMU_UNUSED(op2)) -{ - START_OF_INSTR(); - DECODE_PRINTF("POP\tFS\n"); - TRACE_AND_STEP(); - M.x86.R_FS = pop_word(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xa3 -****************************************************************************/ -void x86emuOp2_bt_R(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint srcoffset; - int bit,disp; - - START_OF_INSTR(); - DECODE_PRINTF("BT\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval; - u32 *shiftreg; - - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - disp = (s16)*shiftreg >> 5; - srcval = fetch_data_long(srcoffset+disp); - CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF); - } else { - u16 srcval; - u16 *shiftreg; - - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - disp = (s16)*shiftreg >> 4; - srcval = fetch_data_word(srcoffset+disp); - CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval; - u32 *shiftreg; - - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - disp = (s16)*shiftreg >> 5; - srcval = fetch_data_long(srcoffset+disp); - CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF); - } else { - u16 srcval; - u16 *shiftreg; - - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - disp = (s16)*shiftreg >> 4; - srcval = fetch_data_word(srcoffset+disp); - CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval; - u32 *shiftreg; - - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - disp = (s16)*shiftreg >> 5; - srcval = fetch_data_long(srcoffset+disp); - CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF); - } else { - u16 srcval; - u16 *shiftreg; - - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - disp = (s16)*shiftreg >> 4; - srcval = fetch_data_word(srcoffset+disp); - CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *srcreg,*shiftreg; - - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - CONDITIONAL_SET_FLAG(*srcreg & (0x1 << bit),F_CF); - } else { - u16 *srcreg,*shiftreg; - - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - CONDITIONAL_SET_FLAG(*srcreg & (0x1 << bit),F_CF); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xa4 -****************************************************************************/ -void x86emuOp2_shld_IMM(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint destoffset; - u8 shift; - - START_OF_INSTR(); - DECODE_PRINTF("SHLD\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *shiftreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - destval = fetch_data_long(destoffset); - destval = shld_long(destval,*shiftreg,shift); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *shiftreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - destval = fetch_data_word(destoffset); - destval = shld_word(destval,*shiftreg,shift); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *shiftreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - destval = fetch_data_long(destoffset); - destval = shld_long(destval,*shiftreg,shift); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *shiftreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - destval = fetch_data_word(destoffset); - destval = shld_word(destval,*shiftreg,shift); - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *shiftreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - destval = fetch_data_long(destoffset); - destval = shld_long(destval,*shiftreg,shift); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *shiftreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - destval = fetch_data_word(destoffset); - destval = shld_word(destval,*shiftreg,shift); - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*shiftreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - *destreg = shld_long(*destreg,*shiftreg,shift); - } else { - u16 *destreg,*shiftreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - *destreg = shld_word(*destreg,*shiftreg,shift); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xa5 -****************************************************************************/ -void x86emuOp2_shld_CL(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("SHLD\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *shiftreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - destval = fetch_data_long(destoffset); - destval = shld_long(destval,*shiftreg,M.x86.R_CL); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *shiftreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - destval = fetch_data_word(destoffset); - destval = shld_word(destval,*shiftreg,M.x86.R_CL); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *shiftreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - destval = fetch_data_long(destoffset); - destval = shld_long(destval,*shiftreg,M.x86.R_CL); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *shiftreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - destval = fetch_data_word(destoffset); - destval = shld_word(destval,*shiftreg,M.x86.R_CL); - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *shiftreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - destval = fetch_data_long(destoffset); - destval = shld_long(destval,*shiftreg,M.x86.R_CL); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *shiftreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - destval = fetch_data_word(destoffset); - destval = shld_word(destval,*shiftreg,M.x86.R_CL); - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*shiftreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - *destreg = shld_long(*destreg,*shiftreg,M.x86.R_CL); - } else { - u16 *destreg,*shiftreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - *destreg = shld_word(*destreg,*shiftreg,M.x86.R_CL); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xa8 -****************************************************************************/ -void x86emuOp2_push_GS(u8 X86EMU_UNUSED(op2)) -{ - START_OF_INSTR(); - DECODE_PRINTF("PUSH\tGS\n"); - TRACE_AND_STEP(); - push_word(M.x86.R_GS); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xa9 -****************************************************************************/ -void x86emuOp2_pop_GS(u8 X86EMU_UNUSED(op2)) -{ - START_OF_INSTR(); - DECODE_PRINTF("POP\tGS\n"); - TRACE_AND_STEP(); - M.x86.R_GS = pop_word(); - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xaa -****************************************************************************/ -void x86emuOp2_bts_R(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint srcoffset; - int bit,disp; - - START_OF_INSTR(); - DECODE_PRINTF("BTS\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval,mask; - u32 *shiftreg; - - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - disp = (s16)*shiftreg >> 5; - srcval = fetch_data_long(srcoffset+disp); - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_long(srcoffset+disp, srcval | mask); - } else { - u16 srcval,mask; - u16 *shiftreg; - - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - disp = (s16)*shiftreg >> 4; - srcval = fetch_data_word(srcoffset+disp); - mask = (u16)(0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_word(srcoffset+disp, srcval | mask); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval,mask; - u32 *shiftreg; - - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - disp = (s16)*shiftreg >> 5; - srcval = fetch_data_long(srcoffset+disp); - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_long(srcoffset+disp, srcval | mask); - } else { - u16 srcval,mask; - u16 *shiftreg; - - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - disp = (s16)*shiftreg >> 4; - srcval = fetch_data_word(srcoffset+disp); - mask = (u16)(0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_word(srcoffset+disp, srcval | mask); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval,mask; - u32 *shiftreg; - - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - disp = (s16)*shiftreg >> 5; - srcval = fetch_data_long(srcoffset+disp); - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_long(srcoffset+disp, srcval | mask); - } else { - u16 srcval,mask; - u16 *shiftreg; - - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - disp = (s16)*shiftreg >> 4; - srcval = fetch_data_word(srcoffset+disp); - mask = (u16)(0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_word(srcoffset+disp, srcval | mask); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *srcreg,*shiftreg; - u32 mask; - - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); - *srcreg |= mask; - } else { - u16 *srcreg,*shiftreg; - u16 mask; - - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - mask = (u16)(0x1 << bit); - CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); - *srcreg |= mask; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xac -****************************************************************************/ -void x86emuOp2_shrd_IMM(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint destoffset; - u8 shift; - - START_OF_INSTR(); - DECODE_PRINTF("SHLD\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *shiftreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - destval = fetch_data_long(destoffset); - destval = shrd_long(destval,*shiftreg,shift); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *shiftreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - destval = fetch_data_word(destoffset); - destval = shrd_word(destval,*shiftreg,shift); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *shiftreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - destval = fetch_data_long(destoffset); - destval = shrd_long(destval,*shiftreg,shift); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *shiftreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - destval = fetch_data_word(destoffset); - destval = shrd_word(destval,*shiftreg,shift); - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *shiftreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - destval = fetch_data_long(destoffset); - destval = shrd_long(destval,*shiftreg,shift); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *shiftreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - destval = fetch_data_word(destoffset); - destval = shrd_word(destval,*shiftreg,shift); - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*shiftreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - *destreg = shrd_long(*destreg,*shiftreg,shift); - } else { - u16 *destreg,*shiftreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - DECODE_PRINTF2("%d\n", shift); - TRACE_AND_STEP(); - *destreg = shrd_word(*destreg,*shiftreg,shift); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xad -****************************************************************************/ -void x86emuOp2_shrd_CL(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint destoffset; - - START_OF_INSTR(); - DECODE_PRINTF("SHLD\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *shiftreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - destval = fetch_data_long(destoffset); - destval = shrd_long(destval,*shiftreg,M.x86.R_CL); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *shiftreg; - - destoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - destval = fetch_data_word(destoffset); - destval = shrd_word(destval,*shiftreg,M.x86.R_CL); - store_data_word(destoffset, destval); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *shiftreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - destval = fetch_data_long(destoffset); - destval = shrd_long(destval,*shiftreg,M.x86.R_CL); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *shiftreg; - - destoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - destval = fetch_data_word(destoffset); - destval = shrd_word(destval,*shiftreg,M.x86.R_CL); - store_data_word(destoffset, destval); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 destval; - u32 *shiftreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - destval = fetch_data_long(destoffset); - destval = shrd_long(destval,*shiftreg,M.x86.R_CL); - store_data_long(destoffset, destval); - } else { - u16 destval; - u16 *shiftreg; - - destoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - destval = fetch_data_word(destoffset); - destval = shrd_word(destval,*shiftreg,M.x86.R_CL); - store_data_word(destoffset, destval); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*shiftreg; - - destreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - *destreg = shrd_long(*destreg,*shiftreg,M.x86.R_CL); - } else { - u16 *destreg,*shiftreg; - - destreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(",CL\n"); - TRACE_AND_STEP(); - *destreg = shrd_word(*destreg,*shiftreg,M.x86.R_CL); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xaf -****************************************************************************/ -void x86emuOp2_imul_R_RM(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("IMUL\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - u32 res_lo,res_hi; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_long(srcoffset); - TRACE_AND_STEP(); - imul_long_direct(&res_lo,&res_hi,(s32)*destreg,(s32)srcval); - if (res_hi != 0) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u32)res_lo; - } else { - u16 *destreg; - u16 srcval; - u32 res; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_word(srcoffset); - TRACE_AND_STEP(); - res = (s16)*destreg * (s16)srcval; - if (res > 0xFFFF) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u16)res; - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - u32 res_lo,res_hi; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_long(srcoffset); - TRACE_AND_STEP(); - imul_long_direct(&res_lo,&res_hi,(s32)*destreg,(s32)srcval); - if (res_hi != 0) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u32)res_lo; - } else { - u16 *destreg; - u16 srcval; - u32 res; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_word(srcoffset); - TRACE_AND_STEP(); - res = (s16)*destreg * (s16)srcval; - if (res > 0xFFFF) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u16)res; - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - u32 res_lo,res_hi; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_long(srcoffset); - TRACE_AND_STEP(); - imul_long_direct(&res_lo,&res_hi,(s32)*destreg,(s32)srcval); - if (res_hi != 0) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u32)res_lo; - } else { - u16 *destreg; - u16 srcval; - u32 res; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_word(srcoffset); - TRACE_AND_STEP(); - res = (s16)*destreg * (s16)srcval; - if (res > 0xFFFF) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u16)res; - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg,*srcreg; - u32 res_lo,res_hi; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_LONG_REGISTER(rl); - TRACE_AND_STEP(); - imul_long_direct(&res_lo,&res_hi,(s32)*destreg,(s32)*srcreg); - if (res_hi != 0) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u32)res_lo; - } else { - u16 *destreg,*srcreg; - u32 res; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rl); - res = (s16)*destreg * (s16)*srcreg; - if (res > 0xFFFF) { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } - *destreg = (u16)res; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xb2 -****************************************************************************/ -void x86emuOp2_lss_R_IMM(u8 X86EMU_UNUSED(op2)) -{ - int mod, rh, rl; - u16 *dstreg; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("LSS\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - dstreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *dstreg = fetch_data_word(srcoffset); - M.x86.R_SS = fetch_data_word(srcoffset + 2); - break; - case 1: - dstreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *dstreg = fetch_data_word(srcoffset); - M.x86.R_SS = fetch_data_word(srcoffset + 2); - break; - case 2: - dstreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *dstreg = fetch_data_word(srcoffset); - M.x86.R_SS = fetch_data_word(srcoffset + 2); - break; - case 3: /* register to register */ - /* UNDEFINED! */ - TRACE_AND_STEP(); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xb3 -****************************************************************************/ -void x86emuOp2_btr_R(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint srcoffset; - int bit,disp; - - START_OF_INSTR(); - DECODE_PRINTF("BTR\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval,mask; - u32 *shiftreg; - - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - disp = (s16)*shiftreg >> 5; - srcval = fetch_data_long(srcoffset+disp); - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_long(srcoffset+disp, srcval & ~mask); - } else { - u16 srcval,mask; - u16 *shiftreg; - - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - disp = (s16)*shiftreg >> 4; - srcval = fetch_data_word(srcoffset+disp); - mask = (u16)(0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_word(srcoffset+disp, (u16)(srcval & ~mask)); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval,mask; - u32 *shiftreg; - - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - disp = (s16)*shiftreg >> 5; - srcval = fetch_data_long(srcoffset+disp); - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_long(srcoffset+disp, srcval & ~mask); - } else { - u16 srcval,mask; - u16 *shiftreg; - - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - disp = (s16)*shiftreg >> 4; - srcval = fetch_data_word(srcoffset+disp); - mask = (u16)(0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_word(srcoffset+disp, (u16)(srcval & ~mask)); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval,mask; - u32 *shiftreg; - - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - disp = (s16)*shiftreg >> 5; - srcval = fetch_data_long(srcoffset+disp); - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_long(srcoffset+disp, srcval & ~mask); - } else { - u16 srcval,mask; - u16 *shiftreg; - - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - disp = (s16)*shiftreg >> 4; - srcval = fetch_data_word(srcoffset+disp); - mask = (u16)(0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_word(srcoffset+disp, (u16)(srcval & ~mask)); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *srcreg,*shiftreg; - u32 mask; - - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); - *srcreg &= ~mask; - } else { - u16 *srcreg,*shiftreg; - u16 mask; - - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - mask = (u16)(0x1 << bit); - CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); - *srcreg &= ~mask; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xb4 -****************************************************************************/ -void x86emuOp2_lfs_R_IMM(u8 X86EMU_UNUSED(op2)) -{ - int mod, rh, rl; - u16 *dstreg; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("LFS\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - dstreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *dstreg = fetch_data_word(srcoffset); - M.x86.R_FS = fetch_data_word(srcoffset + 2); - break; - case 1: - dstreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *dstreg = fetch_data_word(srcoffset); - M.x86.R_FS = fetch_data_word(srcoffset + 2); - break; - case 2: - dstreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *dstreg = fetch_data_word(srcoffset); - M.x86.R_FS = fetch_data_word(srcoffset + 2); - break; - case 3: /* register to register */ - /* UNDEFINED! */ - TRACE_AND_STEP(); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xb5 -****************************************************************************/ -void x86emuOp2_lgs_R_IMM(u8 X86EMU_UNUSED(op2)) -{ - int mod, rh, rl; - u16 *dstreg; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("LGS\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - dstreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *dstreg = fetch_data_word(srcoffset); - M.x86.R_GS = fetch_data_word(srcoffset + 2); - break; - case 1: - dstreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *dstreg = fetch_data_word(srcoffset); - M.x86.R_GS = fetch_data_word(srcoffset + 2); - break; - case 2: - dstreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *dstreg = fetch_data_word(srcoffset); - M.x86.R_GS = fetch_data_word(srcoffset + 2); - break; - case 3: /* register to register */ - /* UNDEFINED! */ - TRACE_AND_STEP(); - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xb6 -****************************************************************************/ -void x86emuOp2_movzx_byte_R_RM(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("MOVZX\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_byte(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u8 *srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = *srcreg; - } else { - u16 *destreg; - u8 *srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = *srcreg; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xb7 -****************************************************************************/ -void x86emuOp2_movzx_word_R_RM(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint srcoffset; - u32 *destreg; - u32 srcval; - u16 *srcreg; - - START_OF_INSTR(); - DECODE_PRINTF("MOVZX\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - break; - case 1: - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - break; - case 2: - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = fetch_data_word(srcoffset); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - break; - case 3: /* register to register */ - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = *srcreg; - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xba -****************************************************************************/ -void x86emuOp2_btX_I(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint srcoffset; - int bit; - - START_OF_INSTR(); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (rh) { - case 3: - DECODE_PRINTF("BT\t"); - break; - case 4: - DECODE_PRINTF("BTS\t"); - break; - case 5: - DECODE_PRINTF("BTR\t"); - break; - case 6: - DECODE_PRINTF("BTC\t"); - break; - default: - DECODE_PRINTF("ILLEGAL EXTENDED X86 OPCODE\n"); - TRACE_REGS(); - printk("%04x:%04x: %02X%02X ILLEGAL EXTENDED X86 OPCODE EXTENSION!\n", - M.x86.R_CS, M.x86.R_IP-3,op2, (mod<<6)|(rh<<3)|rl); - HALT_SYS(); - } - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval, mask; - u8 shift; - - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - TRACE_AND_STEP(); - bit = shift & 0x1F; - srcval = fetch_data_long(srcoffset); - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - switch (rh) { - case 4: - store_data_long(srcoffset, srcval | mask); - break; - case 5: - store_data_long(srcoffset, srcval & ~mask); - break; - case 6: - store_data_long(srcoffset, srcval ^ mask); - break; - default: - break; - } - } else { - u16 srcval, mask; - u8 shift; - - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - TRACE_AND_STEP(); - bit = shift & 0xF; - srcval = fetch_data_word(srcoffset); - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - switch (rh) { - case 4: - store_data_word(srcoffset, srcval | mask); - break; - case 5: - store_data_word(srcoffset, srcval & ~mask); - break; - case 6: - store_data_word(srcoffset, srcval ^ mask); - break; - default: - break; - } - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval, mask; - u8 shift; - - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - TRACE_AND_STEP(); - bit = shift & 0x1F; - srcval = fetch_data_long(srcoffset); - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - switch (rh) { - case 4: - store_data_long(srcoffset, srcval | mask); - break; - case 5: - store_data_long(srcoffset, srcval & ~mask); - break; - case 6: - store_data_long(srcoffset, srcval ^ mask); - break; - default: - break; - } - } else { - u16 srcval, mask; - u8 shift; - - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - TRACE_AND_STEP(); - bit = shift & 0xF; - srcval = fetch_data_word(srcoffset); - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - switch (rh) { - case 4: - store_data_word(srcoffset, srcval | mask); - break; - case 5: - store_data_word(srcoffset, srcval & ~mask); - break; - case 6: - store_data_word(srcoffset, srcval ^ mask); - break; - default: - break; - } - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval, mask; - u8 shift; - - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - TRACE_AND_STEP(); - bit = shift & 0x1F; - srcval = fetch_data_long(srcoffset); - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - switch (rh) { - case 4: - store_data_long(srcoffset, srcval | mask); - break; - case 5: - store_data_long(srcoffset, srcval & ~mask); - break; - case 6: - store_data_long(srcoffset, srcval ^ mask); - break; - default: - break; - } - } else { - u16 srcval, mask; - u8 shift; - - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - TRACE_AND_STEP(); - bit = shift & 0xF; - srcval = fetch_data_word(srcoffset); - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - switch (rh) { - case 4: - store_data_word(srcoffset, srcval | mask); - break; - case 5: - store_data_word(srcoffset, srcval & ~mask); - break; - case 6: - store_data_word(srcoffset, srcval ^ mask); - break; - default: - break; - } - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *srcreg; - u32 mask; - u8 shift; - - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - TRACE_AND_STEP(); - bit = shift & 0x1F; - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); - switch (rh) { - case 4: - *srcreg |= mask; - break; - case 5: - *srcreg &= ~mask; - break; - case 6: - *srcreg ^= mask; - break; - default: - break; - } - } else { - u16 *srcreg; - u16 mask; - u8 shift; - - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - shift = fetch_byte_imm(); - TRACE_AND_STEP(); - bit = shift & 0xF; - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); - switch (rh) { - case 4: - *srcreg |= mask; - break; - case 5: - *srcreg &= ~mask; - break; - case 6: - *srcreg ^= mask; - break; - default: - break; - } - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xbb -****************************************************************************/ -void x86emuOp2_btc_R(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint srcoffset; - int bit,disp; - - START_OF_INSTR(); - DECODE_PRINTF("BTC\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval,mask; - u32 *shiftreg; - - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - disp = (s16)*shiftreg >> 5; - srcval = fetch_data_long(srcoffset+disp); - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_long(srcoffset+disp, srcval ^ mask); - } else { - u16 srcval,mask; - u16 *shiftreg; - - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - disp = (s16)*shiftreg >> 4; - srcval = fetch_data_word(srcoffset+disp); - mask = (u16)(0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_word(srcoffset+disp, (u16)(srcval ^ mask)); - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval,mask; - u32 *shiftreg; - - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - disp = (s16)*shiftreg >> 5; - srcval = fetch_data_long(srcoffset+disp); - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_long(srcoffset+disp, srcval ^ mask); - } else { - u16 srcval,mask; - u16 *shiftreg; - - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - disp = (s16)*shiftreg >> 4; - srcval = fetch_data_word(srcoffset+disp); - mask = (u16)(0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_word(srcoffset+disp, (u16)(srcval ^ mask)); - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval,mask; - u32 *shiftreg; - - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - disp = (s16)*shiftreg >> 5; - srcval = fetch_data_long(srcoffset+disp); - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_long(srcoffset+disp, srcval ^ mask); - } else { - u16 srcval,mask; - u16 *shiftreg; - - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - disp = (s16)*shiftreg >> 4; - srcval = fetch_data_word(srcoffset+disp); - mask = (u16)(0x1 << bit); - CONDITIONAL_SET_FLAG(srcval & mask,F_CF); - store_data_word(srcoffset+disp, (u16)(srcval ^ mask)); - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *srcreg,*shiftreg; - u32 mask; - - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0x1F; - mask = (0x1 << bit); - CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); - *srcreg ^= mask; - } else { - u16 *srcreg,*shiftreg; - u16 mask; - - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - shiftreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - bit = *shiftreg & 0xF; - mask = (u16)(0x1 << bit); - CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); - *srcreg ^= mask; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xbc -****************************************************************************/ -void x86emuOp2_bsf(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("BSF\n"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch(mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval, *dstreg; - - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - srcval = fetch_data_long(srcoffset); - CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); - for(*dstreg = 0; *dstreg < 32; (*dstreg)++) - if ((srcval >> *dstreg) & 1) break; - } else { - u16 srcval, *dstreg; - - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - srcval = fetch_data_word(srcoffset); - CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); - for(*dstreg = 0; *dstreg < 16; (*dstreg)++) - if ((srcval >> *dstreg) & 1) break; - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval, *dstreg; - - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - srcval = fetch_data_long(srcoffset); - CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); - for(*dstreg = 0; *dstreg < 32; (*dstreg)++) - if ((srcval >> *dstreg) & 1) break; - } else { - u16 srcval, *dstreg; - - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - srcval = fetch_data_word(srcoffset); - CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); - for(*dstreg = 0; *dstreg < 16; (*dstreg)++) - if ((srcval >> *dstreg) & 1) break; - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval, *dstreg; - - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - srcval = fetch_data_long(srcoffset); - CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); - for(*dstreg = 0; *dstreg < 32; (*dstreg)++) - if ((srcval >> *dstreg) & 1) break; - } else { - u16 srcval, *dstreg; - - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - srcval = fetch_data_word(srcoffset); - CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); - for(*dstreg = 0; *dstreg < 16; (*dstreg)++) - if ((srcval >> *dstreg) & 1) break; - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *srcreg, *dstreg; - - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - CONDITIONAL_SET_FLAG(*srcreg == 0, F_ZF); - for(*dstreg = 0; *dstreg < 32; (*dstreg)++) - if ((*srcreg >> *dstreg) & 1) break; - } else { - u16 *srcreg, *dstreg; - - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - CONDITIONAL_SET_FLAG(*srcreg == 0, F_ZF); - for(*dstreg = 0; *dstreg < 16; (*dstreg)++) - if ((*srcreg >> *dstreg) & 1) break; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xbd -****************************************************************************/ -void x86emuOp2_bsr(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("BSF\n"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch(mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval, *dstreg; - - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - srcval = fetch_data_long(srcoffset); - CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); - for(*dstreg = 31; *dstreg > 0; (*dstreg)--) - if ((srcval >> *dstreg) & 1) break; - } else { - u16 srcval, *dstreg; - - srcoffset = decode_rm00_address(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - srcval = fetch_data_word(srcoffset); - CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); - for(*dstreg = 15; *dstreg > 0; (*dstreg)--) - if ((srcval >> *dstreg) & 1) break; - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval, *dstreg; - - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - srcval = fetch_data_long(srcoffset); - CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); - for(*dstreg = 31; *dstreg > 0; (*dstreg)--) - if ((srcval >> *dstreg) & 1) break; - } else { - u16 srcval, *dstreg; - - srcoffset = decode_rm01_address(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - srcval = fetch_data_word(srcoffset); - CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); - for(*dstreg = 15; *dstreg > 0; (*dstreg)--) - if ((srcval >> *dstreg) & 1) break; - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 srcval, *dstreg; - - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - srcval = fetch_data_long(srcoffset); - CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); - for(*dstreg = 31; *dstreg > 0; (*dstreg)--) - if ((srcval >> *dstreg) & 1) break; - } else { - u16 srcval, *dstreg; - - srcoffset = decode_rm10_address(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - srcval = fetch_data_word(srcoffset); - CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); - for(*dstreg = 15; *dstreg > 0; (*dstreg)--) - if ((srcval >> *dstreg) & 1) break; - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *srcreg, *dstreg; - - srcreg = DECODE_RM_LONG_REGISTER(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_LONG_REGISTER(rh); - TRACE_AND_STEP(); - CONDITIONAL_SET_FLAG(*srcreg == 0, F_ZF); - for(*dstreg = 31; *dstreg > 0; (*dstreg)--) - if ((*srcreg >> *dstreg) & 1) break; - } else { - u16 *srcreg, *dstreg; - - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF(","); - dstreg = DECODE_RM_WORD_REGISTER(rh); - TRACE_AND_STEP(); - CONDITIONAL_SET_FLAG(*srcreg == 0, F_ZF); - for(*dstreg = 15; *dstreg > 0; (*dstreg)--) - if ((*srcreg >> *dstreg) & 1) break; - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xbe -****************************************************************************/ -void x86emuOp2_movsx_byte_R_RM(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint srcoffset; - - START_OF_INSTR(); - DECODE_PRINTF("MOVSX\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = (s32)((s8)fetch_data_byte(srcoffset)); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = (s16)((s8)fetch_data_byte(srcoffset)); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } - break; - case 1: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = (s32)((s8)fetch_data_byte(srcoffset)); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = (s16)((s8)fetch_data_byte(srcoffset)); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } - break; - case 2: - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u32 srcval; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = (s32)((s8)fetch_data_byte(srcoffset)); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } else { - u16 *destreg; - u16 srcval; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = (s16)((s8)fetch_data_byte(srcoffset)); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - } - break; - case 3: /* register to register */ - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *destreg; - u8 *srcreg; - - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = (s32)((s8)*srcreg); - } else { - u16 *destreg; - u8 *srcreg; - - destreg = DECODE_RM_WORD_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_BYTE_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = (s16)((s8)*srcreg); - } - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/**************************************************************************** -REMARKS: -Handles opcode 0x0f,0xbf -****************************************************************************/ -void x86emuOp2_movsx_word_R_RM(u8 X86EMU_UNUSED(op2)) -{ - int mod, rl, rh; - uint srcoffset; - u32 *destreg; - u32 srcval; - u16 *srcreg; - - START_OF_INSTR(); - DECODE_PRINTF("MOVSX\t"); - FETCH_DECODE_MODRM(mod, rh, rl); - switch (mod) { - case 0: - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm00_address(rl); - srcval = (s32)((s16)fetch_data_word(srcoffset)); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - break; - case 1: - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm01_address(rl); - srcval = (s32)((s16)fetch_data_word(srcoffset)); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - break; - case 2: - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcoffset = decode_rm10_address(rl); - srcval = (s32)((s16)fetch_data_word(srcoffset)); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = srcval; - break; - case 3: /* register to register */ - destreg = DECODE_RM_LONG_REGISTER(rh); - DECODE_PRINTF(","); - srcreg = DECODE_RM_WORD_REGISTER(rl); - DECODE_PRINTF("\n"); - TRACE_AND_STEP(); - *destreg = (s32)((s16)*srcreg); - break; - } - DECODE_CLEAR_SEGOVR(); - END_OF_INSTR(); -} - -/*************************************************************************** - * Double byte operation code table: - **************************************************************************/ -void (*x86emu_optab2[256])(u8) = -{ -/* 0x00 */ x86emuOp2_illegal_op, /* Group F (ring 0 PM) */ -/* 0x01 */ x86emuOp2_illegal_op, /* Group G (ring 0 PM) */ -/* 0x02 */ x86emuOp2_illegal_op, /* lar (ring 0 PM) */ -/* 0x03 */ x86emuOp2_illegal_op, /* lsl (ring 0 PM) */ -/* 0x04 */ x86emuOp2_illegal_op, -/* 0x05 */ x86emuOp2_illegal_op, /* loadall (undocumented) */ -/* 0x06 */ x86emuOp2_illegal_op, /* clts (ring 0 PM) */ -/* 0x07 */ x86emuOp2_illegal_op, /* loadall (undocumented) */ -/* 0x08 */ x86emuOp2_illegal_op, /* invd (ring 0 PM) */ -/* 0x09 */ x86emuOp2_illegal_op, /* wbinvd (ring 0 PM) */ -/* 0x0a */ x86emuOp2_illegal_op, -/* 0x0b */ x86emuOp2_illegal_op, -/* 0x0c */ x86emuOp2_illegal_op, -/* 0x0d */ x86emuOp2_illegal_op, -/* 0x0e */ x86emuOp2_illegal_op, -/* 0x0f */ x86emuOp2_illegal_op, - -/* 0x10 */ x86emuOp2_illegal_op, -/* 0x11 */ x86emuOp2_illegal_op, -/* 0x12 */ x86emuOp2_illegal_op, -/* 0x13 */ x86emuOp2_illegal_op, -/* 0x14 */ x86emuOp2_illegal_op, -/* 0x15 */ x86emuOp2_illegal_op, -/* 0x16 */ x86emuOp2_illegal_op, -/* 0x17 */ x86emuOp2_illegal_op, -/* 0x18 */ x86emuOp2_illegal_op, -/* 0x19 */ x86emuOp2_illegal_op, -/* 0x1a */ x86emuOp2_illegal_op, -/* 0x1b */ x86emuOp2_illegal_op, -/* 0x1c */ x86emuOp2_illegal_op, -/* 0x1d */ x86emuOp2_illegal_op, -/* 0x1e */ x86emuOp2_illegal_op, -/* 0x1f */ x86emuOp2_illegal_op, - -/* 0x20 */ x86emuOp2_illegal_op, /* mov reg32,creg (ring 0 PM) */ -/* 0x21 */ x86emuOp2_illegal_op, /* mov reg32,dreg (ring 0 PM) */ -/* 0x22 */ x86emuOp2_illegal_op, /* mov creg,reg32 (ring 0 PM) */ -/* 0x23 */ x86emuOp2_illegal_op, /* mov dreg,reg32 (ring 0 PM) */ -/* 0x24 */ x86emuOp2_illegal_op, /* mov reg32,treg (ring 0 PM) */ -/* 0x25 */ x86emuOp2_illegal_op, -/* 0x26 */ x86emuOp2_illegal_op, /* mov treg,reg32 (ring 0 PM) */ -/* 0x27 */ x86emuOp2_illegal_op, -/* 0x28 */ x86emuOp2_illegal_op, -/* 0x29 */ x86emuOp2_illegal_op, -/* 0x2a */ x86emuOp2_illegal_op, -/* 0x2b */ x86emuOp2_illegal_op, -/* 0x2c */ x86emuOp2_illegal_op, -/* 0x2d */ x86emuOp2_illegal_op, -/* 0x2e */ x86emuOp2_illegal_op, -/* 0x2f */ x86emuOp2_illegal_op, - -/* 0x30 */ x86emuOp2_illegal_op, -/* 0x31 */ x86emuOp2_illegal_op, -/* 0x32 */ x86emuOp2_illegal_op, -/* 0x33 */ x86emuOp2_illegal_op, -/* 0x34 */ x86emuOp2_illegal_op, -/* 0x35 */ x86emuOp2_illegal_op, -/* 0x36 */ x86emuOp2_illegal_op, -/* 0x37 */ x86emuOp2_illegal_op, -/* 0x38 */ x86emuOp2_illegal_op, -/* 0x39 */ x86emuOp2_illegal_op, -/* 0x3a */ x86emuOp2_illegal_op, -/* 0x3b */ x86emuOp2_illegal_op, -/* 0x3c */ x86emuOp2_illegal_op, -/* 0x3d */ x86emuOp2_illegal_op, -/* 0x3e */ x86emuOp2_illegal_op, -/* 0x3f */ x86emuOp2_illegal_op, - -/* 0x40 */ x86emuOp2_illegal_op, -/* 0x41 */ x86emuOp2_illegal_op, -/* 0x42 */ x86emuOp2_illegal_op, -/* 0x43 */ x86emuOp2_illegal_op, -/* 0x44 */ x86emuOp2_illegal_op, -/* 0x45 */ x86emuOp2_illegal_op, -/* 0x46 */ x86emuOp2_illegal_op, -/* 0x47 */ x86emuOp2_illegal_op, -/* 0x48 */ x86emuOp2_illegal_op, -/* 0x49 */ x86emuOp2_illegal_op, -/* 0x4a */ x86emuOp2_illegal_op, -/* 0x4b */ x86emuOp2_illegal_op, -/* 0x4c */ x86emuOp2_illegal_op, -/* 0x4d */ x86emuOp2_illegal_op, -/* 0x4e */ x86emuOp2_illegal_op, -/* 0x4f */ x86emuOp2_illegal_op, - -/* 0x50 */ x86emuOp2_illegal_op, -/* 0x51 */ x86emuOp2_illegal_op, -/* 0x52 */ x86emuOp2_illegal_op, -/* 0x53 */ x86emuOp2_illegal_op, -/* 0x54 */ x86emuOp2_illegal_op, -/* 0x55 */ x86emuOp2_illegal_op, -/* 0x56 */ x86emuOp2_illegal_op, -/* 0x57 */ x86emuOp2_illegal_op, -/* 0x58 */ x86emuOp2_illegal_op, -/* 0x59 */ x86emuOp2_illegal_op, -/* 0x5a */ x86emuOp2_illegal_op, -/* 0x5b */ x86emuOp2_illegal_op, -/* 0x5c */ x86emuOp2_illegal_op, -/* 0x5d */ x86emuOp2_illegal_op, -/* 0x5e */ x86emuOp2_illegal_op, -/* 0x5f */ x86emuOp2_illegal_op, - -/* 0x60 */ x86emuOp2_illegal_op, -/* 0x61 */ x86emuOp2_illegal_op, -/* 0x62 */ x86emuOp2_illegal_op, -/* 0x63 */ x86emuOp2_illegal_op, -/* 0x64 */ x86emuOp2_illegal_op, -/* 0x65 */ x86emuOp2_illegal_op, -/* 0x66 */ x86emuOp2_illegal_op, -/* 0x67 */ x86emuOp2_illegal_op, -/* 0x68 */ x86emuOp2_illegal_op, -/* 0x69 */ x86emuOp2_illegal_op, -/* 0x6a */ x86emuOp2_illegal_op, -/* 0x6b */ x86emuOp2_illegal_op, -/* 0x6c */ x86emuOp2_illegal_op, -/* 0x6d */ x86emuOp2_illegal_op, -/* 0x6e */ x86emuOp2_illegal_op, -/* 0x6f */ x86emuOp2_illegal_op, - -/* 0x70 */ x86emuOp2_illegal_op, -/* 0x71 */ x86emuOp2_illegal_op, -/* 0x72 */ x86emuOp2_illegal_op, -/* 0x73 */ x86emuOp2_illegal_op, -/* 0x74 */ x86emuOp2_illegal_op, -/* 0x75 */ x86emuOp2_illegal_op, -/* 0x76 */ x86emuOp2_illegal_op, -/* 0x77 */ x86emuOp2_illegal_op, -/* 0x78 */ x86emuOp2_illegal_op, -/* 0x79 */ x86emuOp2_illegal_op, -/* 0x7a */ x86emuOp2_illegal_op, -/* 0x7b */ x86emuOp2_illegal_op, -/* 0x7c */ x86emuOp2_illegal_op, -/* 0x7d */ x86emuOp2_illegal_op, -/* 0x7e */ x86emuOp2_illegal_op, -/* 0x7f */ x86emuOp2_illegal_op, - -/* 0x80 */ x86emuOp2_long_jump, -/* 0x81 */ x86emuOp2_long_jump, -/* 0x82 */ x86emuOp2_long_jump, -/* 0x83 */ x86emuOp2_long_jump, -/* 0x84 */ x86emuOp2_long_jump, -/* 0x85 */ x86emuOp2_long_jump, -/* 0x86 */ x86emuOp2_long_jump, -/* 0x87 */ x86emuOp2_long_jump, -/* 0x88 */ x86emuOp2_long_jump, -/* 0x89 */ x86emuOp2_long_jump, -/* 0x8a */ x86emuOp2_long_jump, -/* 0x8b */ x86emuOp2_long_jump, -/* 0x8c */ x86emuOp2_long_jump, -/* 0x8d */ x86emuOp2_long_jump, -/* 0x8e */ x86emuOp2_long_jump, -/* 0x8f */ x86emuOp2_long_jump, - -/* 0x90 */ x86emuOp2_set_byte, -/* 0x91 */ x86emuOp2_set_byte, -/* 0x92 */ x86emuOp2_set_byte, -/* 0x93 */ x86emuOp2_set_byte, -/* 0x94 */ x86emuOp2_set_byte, -/* 0x95 */ x86emuOp2_set_byte, -/* 0x96 */ x86emuOp2_set_byte, -/* 0x97 */ x86emuOp2_set_byte, -/* 0x98 */ x86emuOp2_set_byte, -/* 0x99 */ x86emuOp2_set_byte, -/* 0x9a */ x86emuOp2_set_byte, -/* 0x9b */ x86emuOp2_set_byte, -/* 0x9c */ x86emuOp2_set_byte, -/* 0x9d */ x86emuOp2_set_byte, -/* 0x9e */ x86emuOp2_set_byte, -/* 0x9f */ x86emuOp2_set_byte, - -/* 0xa0 */ x86emuOp2_push_FS, -/* 0xa1 */ x86emuOp2_pop_FS, -/* 0xa2 */ x86emuOp2_illegal_op, -/* 0xa3 */ x86emuOp2_bt_R, -/* 0xa4 */ x86emuOp2_shld_IMM, -/* 0xa5 */ x86emuOp2_shld_CL, -/* 0xa6 */ x86emuOp2_illegal_op, -/* 0xa7 */ x86emuOp2_illegal_op, -/* 0xa8 */ x86emuOp2_push_GS, -/* 0xa9 */ x86emuOp2_pop_GS, -/* 0xaa */ x86emuOp2_illegal_op, -/* 0xab */ x86emuOp2_bt_R, -/* 0xac */ x86emuOp2_shrd_IMM, -/* 0xad */ x86emuOp2_shrd_CL, -/* 0xae */ x86emuOp2_illegal_op, -/* 0xaf */ x86emuOp2_imul_R_RM, - -/* 0xb0 */ x86emuOp2_illegal_op, /* TODO: cmpxchg */ -/* 0xb1 */ x86emuOp2_illegal_op, /* TODO: cmpxchg */ -/* 0xb2 */ x86emuOp2_lss_R_IMM, -/* 0xb3 */ x86emuOp2_btr_R, -/* 0xb4 */ x86emuOp2_lfs_R_IMM, -/* 0xb5 */ x86emuOp2_lgs_R_IMM, -/* 0xb6 */ x86emuOp2_movzx_byte_R_RM, -/* 0xb7 */ x86emuOp2_movzx_word_R_RM, -/* 0xb8 */ x86emuOp2_illegal_op, -/* 0xb9 */ x86emuOp2_illegal_op, -/* 0xba */ x86emuOp2_btX_I, -/* 0xbb */ x86emuOp2_btc_R, -/* 0xbc */ x86emuOp2_bsf, -/* 0xbd */ x86emuOp2_bsr, -/* 0xbe */ x86emuOp2_movsx_byte_R_RM, -/* 0xbf */ x86emuOp2_movsx_word_R_RM, - -/* 0xc0 */ x86emuOp2_illegal_op, /* TODO: xadd */ -/* 0xc1 */ x86emuOp2_illegal_op, /* TODO: xadd */ -/* 0xc2 */ x86emuOp2_illegal_op, -/* 0xc3 */ x86emuOp2_illegal_op, -/* 0xc4 */ x86emuOp2_illegal_op, -/* 0xc5 */ x86emuOp2_illegal_op, -/* 0xc6 */ x86emuOp2_illegal_op, -/* 0xc7 */ x86emuOp2_illegal_op, -/* 0xc8 */ x86emuOp2_illegal_op, /* TODO: bswap */ -/* 0xc9 */ x86emuOp2_illegal_op, /* TODO: bswap */ -/* 0xca */ x86emuOp2_illegal_op, /* TODO: bswap */ -/* 0xcb */ x86emuOp2_illegal_op, /* TODO: bswap */ -/* 0xcc */ x86emuOp2_illegal_op, /* TODO: bswap */ -/* 0xcd */ x86emuOp2_illegal_op, /* TODO: bswap */ -/* 0xce */ x86emuOp2_illegal_op, /* TODO: bswap */ -/* 0xcf */ x86emuOp2_illegal_op, /* TODO: bswap */ - -/* 0xd0 */ x86emuOp2_illegal_op, -/* 0xd1 */ x86emuOp2_illegal_op, -/* 0xd2 */ x86emuOp2_illegal_op, -/* 0xd3 */ x86emuOp2_illegal_op, -/* 0xd4 */ x86emuOp2_illegal_op, -/* 0xd5 */ x86emuOp2_illegal_op, -/* 0xd6 */ x86emuOp2_illegal_op, -/* 0xd7 */ x86emuOp2_illegal_op, -/* 0xd8 */ x86emuOp2_illegal_op, -/* 0xd9 */ x86emuOp2_illegal_op, -/* 0xda */ x86emuOp2_illegal_op, -/* 0xdb */ x86emuOp2_illegal_op, -/* 0xdc */ x86emuOp2_illegal_op, -/* 0xdd */ x86emuOp2_illegal_op, -/* 0xde */ x86emuOp2_illegal_op, -/* 0xdf */ x86emuOp2_illegal_op, - -/* 0xe0 */ x86emuOp2_illegal_op, -/* 0xe1 */ x86emuOp2_illegal_op, -/* 0xe2 */ x86emuOp2_illegal_op, -/* 0xe3 */ x86emuOp2_illegal_op, -/* 0xe4 */ x86emuOp2_illegal_op, -/* 0xe5 */ x86emuOp2_illegal_op, -/* 0xe6 */ x86emuOp2_illegal_op, -/* 0xe7 */ x86emuOp2_illegal_op, -/* 0xe8 */ x86emuOp2_illegal_op, -/* 0xe9 */ x86emuOp2_illegal_op, -/* 0xea */ x86emuOp2_illegal_op, -/* 0xeb */ x86emuOp2_illegal_op, -/* 0xec */ x86emuOp2_illegal_op, -/* 0xed */ x86emuOp2_illegal_op, -/* 0xee */ x86emuOp2_illegal_op, -/* 0xef */ x86emuOp2_illegal_op, - -/* 0xf0 */ x86emuOp2_illegal_op, -/* 0xf1 */ x86emuOp2_illegal_op, -/* 0xf2 */ x86emuOp2_illegal_op, -/* 0xf3 */ x86emuOp2_illegal_op, -/* 0xf4 */ x86emuOp2_illegal_op, -/* 0xf5 */ x86emuOp2_illegal_op, -/* 0xf6 */ x86emuOp2_illegal_op, -/* 0xf7 */ x86emuOp2_illegal_op, -/* 0xf8 */ x86emuOp2_illegal_op, -/* 0xf9 */ x86emuOp2_illegal_op, -/* 0xfa */ x86emuOp2_illegal_op, -/* 0xfb */ x86emuOp2_illegal_op, -/* 0xfc */ x86emuOp2_illegal_op, -/* 0xfd */ x86emuOp2_illegal_op, -/* 0xfe */ x86emuOp2_illegal_op, -/* 0xff */ x86emuOp2_illegal_op, -}; diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/prim_ops.c b/board/MAI/bios_emulator/scitech/src/x86emu/prim_ops.c deleted file mode 100644 index 72b1bf2879..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/prim_ops.c +++ /dev/null @@ -1,2914 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: This file contains the code to implement the primitive -* machine operations used by the emulation code in ops.c -* -* Carry Chain Calculation -* -* This represents a somewhat expensive calculation which is -* apparently required to emulate the setting of the OF and AF flag. -* The latter is not so important, but the former is. The overflow -* flag is the XOR of the top two bits of the carry chain for an -* addition (similar for subtraction). Since we do not want to -* simulate the addition in a bitwise manner, we try to calculate the -* carry chain given the two operands and the result. -* -* So, given the following table, which represents the addition of two -* bits, we can derive a formula for the carry chain. -* -* a b cin r cout -* 0 0 0 0 0 -* 0 0 1 1 0 -* 0 1 0 1 0 -* 0 1 1 0 1 -* 1 0 0 1 0 -* 1 0 1 0 1 -* 1 1 0 0 1 -* 1 1 1 1 1 -* -* Construction of table for cout: -* -* ab -* r \ 00 01 11 10 -* |------------------ -* 0 | 0 1 1 1 -* 1 | 0 0 1 0 -* -* By inspection, one gets: cc = ab + r'(a + b) -* -* That represents alot of operations, but NO CHOICE.... -* -* Borrow Chain Calculation. -* -* The following table represents the subtraction of two bits, from -* which we can derive a formula for the borrow chain. -* -* a b bin r bout -* 0 0 0 0 0 -* 0 0 1 1 1 -* 0 1 0 1 1 -* 0 1 1 0 1 -* 1 0 0 1 0 -* 1 0 1 0 0 -* 1 1 0 0 0 -* 1 1 1 1 1 -* -* Construction of table for cout: -* -* ab -* r \ 00 01 11 10 -* |------------------ -* 0 | 0 1 0 0 -* 1 | 1 1 1 0 -* -* By inspection, one gets: bc = a'b + r(a' + b) -* -****************************************************************************/ - -#define PRIM_OPS_NO_REDEFINE_ASM -#include "x86emu/x86emui.h" - -/*------------------------- Global Variables ------------------------------*/ - -#ifndef __HAVE_INLINE_ASSEMBLER__ - -static u32 x86emu_parity_tab[8] = -{ - 0x96696996, - 0x69969669, - 0x69969669, - 0x96696996, - 0x69969669, - 0x96696996, - 0x96696996, - 0x69969669, -}; - -#endif - -#define PARITY(x) (((x86emu_parity_tab[(x) / 32] >> ((x) % 32)) & 1) == 0) -#define XOR2(x) (((x) ^ ((x)>>1)) & 0x1) - -/*----------------------------- Implementation ----------------------------*/ - -#ifndef __HAVE_INLINE_ASSEMBLER__ - -/**************************************************************************** -REMARKS: -Implements the AAA instruction and side effects. -****************************************************************************/ -u16 aaa_word(u16 d) -{ - u16 res; - if ((d & 0xf) > 0x9 || ACCESS_FLAG(F_AF)) { - d += 0x6; - d += 0x100; - SET_FLAG(F_AF); - SET_FLAG(F_CF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_AF); - } - res = (u16)(d & 0xFF0F); - CLEAR_FLAG(F_SF); - CONDITIONAL_SET_FLAG(res == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the AAA instruction and side effects. -****************************************************************************/ -u16 aas_word(u16 d) -{ - u16 res; - if ((d & 0xf) > 0x9 || ACCESS_FLAG(F_AF)) { - d -= 0x6; - d -= 0x100; - SET_FLAG(F_AF); - SET_FLAG(F_CF); - } else { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_AF); - } - res = (u16)(d & 0xFF0F); - CLEAR_FLAG(F_SF); - CONDITIONAL_SET_FLAG(res == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the AAD instruction and side effects. -****************************************************************************/ -u16 aad_word(u16 d) -{ - u16 l; - u8 hb, lb; - - hb = (u8)((d >> 8) & 0xff); - lb = (u8)((d & 0xff)); - l = (u16)((lb + 10 * hb) & 0xFF); - - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_AF); - CLEAR_FLAG(F_OF); - CONDITIONAL_SET_FLAG(l & 0x80, F_SF); - CONDITIONAL_SET_FLAG(l == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(l & 0xff), F_PF); - return l; -} - -/**************************************************************************** -REMARKS: -Implements the AAM instruction and side effects. -****************************************************************************/ -u16 aam_word(u8 d) -{ - u16 h, l; - - h = (u16)(d / 10); - l = (u16)(d % 10); - l |= (u16)(h << 8); - - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_AF); - CLEAR_FLAG(F_OF); - CONDITIONAL_SET_FLAG(l & 0x80, F_SF); - CONDITIONAL_SET_FLAG(l == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(l & 0xff), F_PF); - return l; -} - -/**************************************************************************** -REMARKS: -Implements the ADC instruction and side effects. -****************************************************************************/ -u8 adc_byte(u8 d, u8 s) -{ - register u32 res; /* all operands in native machine order */ - register u32 cc; - - if (ACCESS_FLAG(F_CF)) - res = 1 + d + s; - else - res = d + s; - - CONDITIONAL_SET_FLAG(res & 0x100, F_CF); - CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the carry chain SEE NOTE AT TOP. */ - cc = (s & d) | ((~res) & (s | d)); - CONDITIONAL_SET_FLAG(XOR2(cc >> 6), F_OF); - CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); - return (u8)res; -} - -/**************************************************************************** -REMARKS: -Implements the ADC instruction and side effects. -****************************************************************************/ -u16 adc_word(u16 d, u16 s) -{ - register u32 res; /* all operands in native machine order */ - register u32 cc; - - if (ACCESS_FLAG(F_CF)) - res = 1 + d + s; - else - res = d + s; - - CONDITIONAL_SET_FLAG(res & 0x10000, F_CF); - CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the carry chain SEE NOTE AT TOP. */ - cc = (s & d) | ((~res) & (s | d)); - CONDITIONAL_SET_FLAG(XOR2(cc >> 14), F_OF); - CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); - return (u16)res; -} - -/**************************************************************************** -REMARKS: -Implements the ADC instruction and side effects. -****************************************************************************/ -u32 adc_long(u32 d, u32 s) -{ - register u32 lo; /* all operands in native machine order */ - register u32 hi; - register u32 res; - register u32 cc; - - if (ACCESS_FLAG(F_CF)) { - lo = 1 + (d & 0xFFFF) + (s & 0xFFFF); - res = 1 + d + s; - } - else { - lo = (d & 0xFFFF) + (s & 0xFFFF); - res = d + s; - } - hi = (lo >> 16) + (d >> 16) + (s >> 16); - - CONDITIONAL_SET_FLAG(hi & 0x10000, F_CF); - CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the carry chain SEE NOTE AT TOP. */ - cc = (s & d) | ((~res) & (s | d)); - CONDITIONAL_SET_FLAG(XOR2(cc >> 30), F_OF); - CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the ADD instruction and side effects. -****************************************************************************/ -u8 add_byte(u8 d, u8 s) -{ - register u32 res; /* all operands in native machine order */ - register u32 cc; - - res = d + s; - CONDITIONAL_SET_FLAG(res & 0x100, F_CF); - CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the carry chain SEE NOTE AT TOP. */ - cc = (s & d) | ((~res) & (s | d)); - CONDITIONAL_SET_FLAG(XOR2(cc >> 6), F_OF); - CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); - return (u8)res; -} - -/**************************************************************************** -REMARKS: -Implements the ADD instruction and side effects. -****************************************************************************/ -u16 add_word(u16 d, u16 s) -{ - register u32 res; /* all operands in native machine order */ - register u32 cc; - - res = d + s; - CONDITIONAL_SET_FLAG(res & 0x10000, F_CF); - CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the carry chain SEE NOTE AT TOP. */ - cc = (s & d) | ((~res) & (s | d)); - CONDITIONAL_SET_FLAG(XOR2(cc >> 14), F_OF); - CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); - return (u16)res; -} - -/**************************************************************************** -REMARKS: -Implements the ADD instruction and side effects. -****************************************************************************/ -u32 add_long(u32 d, u32 s) -{ - register u32 lo; /* all operands in native machine order */ - register u32 hi; - register u32 res; - register u32 cc; - - lo = (d & 0xFFFF) + (s & 0xFFFF); - res = d + s; - hi = (lo >> 16) + (d >> 16) + (s >> 16); - - CONDITIONAL_SET_FLAG(hi & 0x10000, F_CF); - CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the carry chain SEE NOTE AT TOP. */ - cc = (s & d) | ((~res) & (s | d)); - CONDITIONAL_SET_FLAG(XOR2(cc >> 30), F_OF); - CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); - - return res; -} - -/**************************************************************************** -REMARKS: -Implements the AND instruction and side effects. -****************************************************************************/ -u8 and_byte(u8 d, u8 s) -{ - register u8 res; /* all operands in native machine order */ - - res = d & s; - - /* set the flags */ - CLEAR_FLAG(F_OF); - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_AF); - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - CONDITIONAL_SET_FLAG(res == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res), F_PF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the AND instruction and side effects. -****************************************************************************/ -u16 and_word(u16 d, u16 s) -{ - register u16 res; /* all operands in native machine order */ - - res = d & s; - - /* set the flags */ - CLEAR_FLAG(F_OF); - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_AF); - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG(res == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the AND instruction and side effects. -****************************************************************************/ -u32 and_long(u32 d, u32 s) -{ - register u32 res; /* all operands in native machine order */ - - res = d & s; - - /* set the flags */ - CLEAR_FLAG(F_OF); - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_AF); - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG(res == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the CMP instruction and side effects. -****************************************************************************/ -u8 cmp_byte(u8 d, u8 s) -{ - register u32 res; /* all operands in native machine order */ - register u32 bc; - - res = d - s; - CLEAR_FLAG(F_CF); - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the borrow chain. See note at top */ - bc = (res & (~d | s)) | (~d & s); - CONDITIONAL_SET_FLAG(bc & 0x80, F_CF); - CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF); - CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); - return d; -} - -/**************************************************************************** -REMARKS: -Implements the CMP instruction and side effects. -****************************************************************************/ -u16 cmp_word(u16 d, u16 s) -{ - register u32 res; /* all operands in native machine order */ - register u32 bc; - - res = d - s; - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the borrow chain. See note at top */ - bc = (res & (~d | s)) | (~d & s); - CONDITIONAL_SET_FLAG(bc & 0x8000, F_CF); - CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF); - CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); - return d; -} - -/**************************************************************************** -REMARKS: -Implements the CMP instruction and side effects. -****************************************************************************/ -u32 cmp_long(u32 d, u32 s) -{ - register u32 res; /* all operands in native machine order */ - register u32 bc; - - res = d - s; - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the borrow chain. See note at top */ - bc = (res & (~d | s)) | (~d & s); - CONDITIONAL_SET_FLAG(bc & 0x80000000, F_CF); - CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF); - CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); - return d; -} - -/**************************************************************************** -REMARKS: -Implements the DAA instruction and side effects. -****************************************************************************/ -u8 daa_byte(u8 d) -{ - u32 res = d; - if ((d & 0xf) > 9 || ACCESS_FLAG(F_AF)) { - res += 6; - SET_FLAG(F_AF); - } - if (res > 0x9F || ACCESS_FLAG(F_CF)) { - res += 0x60; - SET_FLAG(F_CF); - } - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - CONDITIONAL_SET_FLAG((res & 0xFF) == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - return (u8)res; -} - -/**************************************************************************** -REMARKS: -Implements the DAS instruction and side effects. -****************************************************************************/ -u8 das_byte(u8 d) -{ - if ((d & 0xf) > 9 || ACCESS_FLAG(F_AF)) { - d -= 6; - SET_FLAG(F_AF); - } - if (d > 0x9F || ACCESS_FLAG(F_CF)) { - d -= 0x60; - SET_FLAG(F_CF); - } - CONDITIONAL_SET_FLAG(d & 0x80, F_SF); - CONDITIONAL_SET_FLAG(d == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(d & 0xff), F_PF); - return d; -} - -/**************************************************************************** -REMARKS: -Implements the DEC instruction and side effects. -****************************************************************************/ -u8 dec_byte(u8 d) -{ - register u32 res; /* all operands in native machine order */ - register u32 bc; - - res = d - 1; - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the borrow chain. See note at top */ - /* based on sub_byte, uses s==1. */ - bc = (res & (~d | 1)) | (~d & 1); - /* carry flag unchanged */ - CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF); - CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); - return (u8)res; -} - -/**************************************************************************** -REMARKS: -Implements the DEC instruction and side effects. -****************************************************************************/ -u16 dec_word(u16 d) -{ - register u32 res; /* all operands in native machine order */ - register u32 bc; - - res = d - 1; - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the borrow chain. See note at top */ - /* based on the sub_byte routine, with s==1 */ - bc = (res & (~d | 1)) | (~d & 1); - /* carry flag unchanged */ - CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF); - CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); - return (u16)res; -} - -/**************************************************************************** -REMARKS: -Implements the DEC instruction and side effects. -****************************************************************************/ -u32 dec_long(u32 d) -{ - register u32 res; /* all operands in native machine order */ - register u32 bc; - - res = d - 1; - - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the borrow chain. See note at top */ - bc = (res & (~d | 1)) | (~d & 1); - /* carry flag unchanged */ - CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF); - CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the INC instruction and side effects. -****************************************************************************/ -u8 inc_byte(u8 d) -{ - register u32 res; /* all operands in native machine order */ - register u32 cc; - - res = d + 1; - CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the carry chain SEE NOTE AT TOP. */ - cc = ((1 & d) | (~res)) & (1 | d); - CONDITIONAL_SET_FLAG(XOR2(cc >> 6), F_OF); - CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); - return (u8)res; -} - -/**************************************************************************** -REMARKS: -Implements the INC instruction and side effects. -****************************************************************************/ -u16 inc_word(u16 d) -{ - register u32 res; /* all operands in native machine order */ - register u32 cc; - - res = d + 1; - CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the carry chain SEE NOTE AT TOP. */ - cc = (1 & d) | ((~res) & (1 | d)); - CONDITIONAL_SET_FLAG(XOR2(cc >> 14), F_OF); - CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); - return (u16)res; -} - -/**************************************************************************** -REMARKS: -Implements the INC instruction and side effects. -****************************************************************************/ -u32 inc_long(u32 d) -{ - register u32 res; /* all operands in native machine order */ - register u32 cc; - - res = d + 1; - CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the carry chain SEE NOTE AT TOP. */ - cc = (1 & d) | ((~res) & (1 | d)); - CONDITIONAL_SET_FLAG(XOR2(cc >> 30), F_OF); - CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the OR instruction and side effects. -****************************************************************************/ -u8 or_byte(u8 d, u8 s) -{ - register u8 res; /* all operands in native machine order */ - - res = d | s; - CLEAR_FLAG(F_OF); - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_AF); - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - CONDITIONAL_SET_FLAG(res == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res), F_PF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the OR instruction and side effects. -****************************************************************************/ -u16 or_word(u16 d, u16 s) -{ - register u16 res; /* all operands in native machine order */ - - res = d | s; - /* set the carry flag to be bit 8 */ - CLEAR_FLAG(F_OF); - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_AF); - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG(res == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the OR instruction and side effects. -****************************************************************************/ -u32 or_long(u32 d, u32 s) -{ - register u32 res; /* all operands in native machine order */ - - res = d | s; - - /* set the carry flag to be bit 8 */ - CLEAR_FLAG(F_OF); - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_AF); - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG(res == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the OR instruction and side effects. -****************************************************************************/ -u8 neg_byte(u8 s) -{ - register u8 res; - register u8 bc; - - CONDITIONAL_SET_FLAG(s != 0, F_CF); - res = (u8)-s; - CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res), F_PF); - /* calculate the borrow chain --- modified such that d=0. - substitutiing d=0 into bc= res&(~d|s)|(~d&s); - (the one used for sub) and simplifying, since ~d=0xff..., - ~d|s == 0xffff..., and res&0xfff... == res. Similarly - ~d&s == s. So the simplified result is: */ - bc = res | s; - CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF); - CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the OR instruction and side effects. -****************************************************************************/ -u16 neg_word(u16 s) -{ - register u16 res; - register u16 bc; - - CONDITIONAL_SET_FLAG(s != 0, F_CF); - res = (u16)-s; - CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the borrow chain --- modified such that d=0. - substitutiing d=0 into bc= res&(~d|s)|(~d&s); - (the one used for sub) and simplifying, since ~d=0xff..., - ~d|s == 0xffff..., and res&0xfff... == res. Similarly - ~d&s == s. So the simplified result is: */ - bc = res | s; - CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF); - CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the OR instruction and side effects. -****************************************************************************/ -u32 neg_long(u32 s) -{ - register u32 res; - register u32 bc; - - CONDITIONAL_SET_FLAG(s != 0, F_CF); - res = (u32)-s; - CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the borrow chain --- modified such that d=0. - substitutiing d=0 into bc= res&(~d|s)|(~d&s); - (the one used for sub) and simplifying, since ~d=0xff..., - ~d|s == 0xffff..., and res&0xfff... == res. Similarly - ~d&s == s. So the simplified result is: */ - bc = res | s; - CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF); - CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the NOT instruction and side effects. -****************************************************************************/ -u8 not_byte(u8 s) -{ - return ~s; -} - -/**************************************************************************** -REMARKS: -Implements the NOT instruction and side effects. -****************************************************************************/ -u16 not_word(u16 s) -{ - return ~s; -} - -/**************************************************************************** -REMARKS: -Implements the NOT instruction and side effects. -****************************************************************************/ -u32 not_long(u32 s) -{ - return ~s; -} - -/**************************************************************************** -REMARKS: -Implements the RCL instruction and side effects. -****************************************************************************/ -u8 rcl_byte(u8 d, u8 s) -{ - register unsigned int res, cnt, mask, cf; - - /* s is the rotate distance. It varies from 0 - 8. */ - /* have - - CF B_7 B_6 B_5 B_4 B_3 B_2 B_1 B_0 - - want to rotate through the carry by "s" bits. We could - loop, but that's inefficient. So the width is 9, - and we split into three parts: - - The new carry flag (was B_n) - the stuff in B_n-1 .. B_0 - the stuff in B_7 .. B_n+1 - - The new rotate is done mod 9, and given this, - for a rotation of n bits (mod 9) the new carry flag is - then located n bits from the MSB. The low part is - then shifted up cnt bits, and the high part is or'd - in. Using CAPS for new values, and lowercase for the - original values, this can be expressed as: - - IF n > 0 - 1) CF <- b_(8-n) - 2) B_(7) .. B_(n) <- b_(8-(n+1)) .. b_0 - 3) B_(n-1) <- cf - 4) B_(n-2) .. B_0 <- b_7 .. b_(8-(n-1)) - */ - res = d; - if ((cnt = s % 9) != 0) { - /* extract the new CARRY FLAG. */ - /* CF <- b_(8-n) */ - cf = (d >> (8 - cnt)) & 0x1; - - /* get the low stuff which rotated - into the range B_7 .. B_cnt */ - /* B_(7) .. B_(n) <- b_(8-(n+1)) .. b_0 */ - /* note that the right hand side done by the mask */ - res = (d << cnt) & 0xff; - - /* now the high stuff which rotated around - into the positions B_cnt-2 .. B_0 */ - /* B_(n-2) .. B_0 <- b_7 .. b_(8-(n-1)) */ - /* shift it downward, 7-(n-2) = 9-n positions. - and mask off the result before or'ing in. - */ - mask = (1 << (cnt - 1)) - 1; - res |= (d >> (9 - cnt)) & mask; - - /* if the carry flag was set, or it in. */ - if (ACCESS_FLAG(F_CF)) { /* carry flag is set */ - /* B_(n-1) <- cf */ - res |= 1 << (cnt - 1); - } - /* set the new carry flag, based on the variable "cf" */ - CONDITIONAL_SET_FLAG(cf, F_CF); - /* OVERFLOW is set *IFF* cnt==1, then it is the - xor of CF and the most significant bit. Blecck. */ - /* parenthesized this expression since it appears to - be causing OF to be misset */ - CONDITIONAL_SET_FLAG(cnt == 1 && XOR2(cf + ((res >> 6) & 0x2)), - F_OF); - - } - return (u8)res; -} - -/**************************************************************************** -REMARKS: -Implements the RCL instruction and side effects. -****************************************************************************/ -u16 rcl_word(u16 d, u8 s) -{ - register unsigned int res, cnt, mask, cf; - - res = d; - if ((cnt = s % 17) != 0) { - cf = (d >> (16 - cnt)) & 0x1; - res = (d << cnt) & 0xffff; - mask = (1 << (cnt - 1)) - 1; - res |= (d >> (17 - cnt)) & mask; - if (ACCESS_FLAG(F_CF)) { - res |= 1 << (cnt - 1); - } - CONDITIONAL_SET_FLAG(cf, F_CF); - CONDITIONAL_SET_FLAG(cnt == 1 && XOR2(cf + ((res >> 14) & 0x2)), - F_OF); - } - return (u16)res; -} - -/**************************************************************************** -REMARKS: -Implements the RCL instruction and side effects. -****************************************************************************/ -u32 rcl_long(u32 d, u8 s) -{ - register u32 res, cnt, mask, cf; - - res = d; - if ((cnt = s % 33) != 0) { - cf = (d >> (32 - cnt)) & 0x1; - res = (d << cnt) & 0xffffffff; - mask = (1 << (cnt - 1)) - 1; - res |= (d >> (33 - cnt)) & mask; - if (ACCESS_FLAG(F_CF)) { /* carry flag is set */ - res |= 1 << (cnt - 1); - } - CONDITIONAL_SET_FLAG(cf, F_CF); - CONDITIONAL_SET_FLAG(cnt == 1 && XOR2(cf + ((res >> 30) & 0x2)), - F_OF); - } - return res; -} - -/**************************************************************************** -REMARKS: -Implements the RCR instruction and side effects. -****************************************************************************/ -u8 rcr_byte(u8 d, u8 s) -{ - u32 res, cnt; - u32 mask, cf, ocf = 0; - - /* rotate right through carry */ - /* - s is the rotate distance. It varies from 0 - 8. - d is the byte object rotated. - - have - - CF B_7 B_6 B_5 B_4 B_3 B_2 B_1 B_0 - - The new rotate is done mod 9, and given this, - for a rotation of n bits (mod 9) the new carry flag is - then located n bits from the LSB. The low part is - then shifted up cnt bits, and the high part is or'd - in. Using CAPS for new values, and lowercase for the - original values, this can be expressed as: - - IF n > 0 - 1) CF <- b_(n-1) - 2) B_(8-(n+1)) .. B_(0) <- b_(7) .. b_(n) - 3) B_(8-n) <- cf - 4) B_(7) .. B_(8-(n-1)) <- b_(n-2) .. b_(0) - */ - res = d; - if ((cnt = s % 9) != 0) { - /* extract the new CARRY FLAG. */ - /* CF <- b_(n-1) */ - if (cnt == 1) { - cf = d & 0x1; - /* note hackery here. Access_flag(..) evaluates to either - 0 if flag not set - non-zero if flag is set. - doing access_flag(..) != 0 casts that into either - 0..1 in any representation of the flags register - (i.e. packed bit array or unpacked.) - */ - ocf = ACCESS_FLAG(F_CF) != 0; - } else - cf = (d >> (cnt - 1)) & 0x1; - - /* B_(8-(n+1)) .. B_(0) <- b_(7) .. b_n */ - /* note that the right hand side done by the mask - This is effectively done by shifting the - object to the right. The result must be masked, - in case the object came in and was treated - as a negative number. Needed??? */ - - mask = (1 << (8 - cnt)) - 1; - res = (d >> cnt) & mask; - - /* now the high stuff which rotated around - into the positions B_cnt-2 .. B_0 */ - /* B_(7) .. B_(8-(n-1)) <- b_(n-2) .. b_(0) */ - /* shift it downward, 7-(n-2) = 9-n positions. - and mask off the result before or'ing in. - */ - res |= (d << (9 - cnt)); - - /* if the carry flag was set, or it in. */ - if (ACCESS_FLAG(F_CF)) { /* carry flag is set */ - /* B_(8-n) <- cf */ - res |= 1 << (8 - cnt); - } - /* set the new carry flag, based on the variable "cf" */ - CONDITIONAL_SET_FLAG(cf, F_CF); - /* OVERFLOW is set *IFF* cnt==1, then it is the - xor of CF and the most significant bit. Blecck. */ - /* parenthesized... */ - if (cnt == 1) { - CONDITIONAL_SET_FLAG(XOR2(ocf + ((d >> 6) & 0x2)), - F_OF); - } - } - return (u8)res; -} - -/**************************************************************************** -REMARKS: -Implements the RCR instruction and side effects. -****************************************************************************/ -u16 rcr_word(u16 d, u8 s) -{ - u32 res, cnt; - u32 mask, cf, ocf = 0; - - /* rotate right through carry */ - res = d; - if ((cnt = s % 17) != 0) { - if (cnt == 1) { - cf = d & 0x1; - ocf = ACCESS_FLAG(F_CF) != 0; - } else - cf = (d >> (cnt - 1)) & 0x1; - mask = (1 << (16 - cnt)) - 1; - res = (d >> cnt) & mask; - res |= (d << (17 - cnt)); - if (ACCESS_FLAG(F_CF)) { - res |= 1 << (16 - cnt); - } - CONDITIONAL_SET_FLAG(cf, F_CF); - if (cnt == 1) { - CONDITIONAL_SET_FLAG(XOR2(ocf + ((d >> 14) & 0x2)), - F_OF); - } - } - return (u16)res; -} - -/**************************************************************************** -REMARKS: -Implements the RCR instruction and side effects. -****************************************************************************/ -u32 rcr_long(u32 d, u8 s) -{ - u32 res, cnt; - u32 mask, cf, ocf = 0; - - /* rotate right through carry */ - res = d; - if ((cnt = s % 33) != 0) { - if (cnt == 1) { - cf = d & 0x1; - ocf = ACCESS_FLAG(F_CF) != 0; - } else - cf = (d >> (cnt - 1)) & 0x1; - mask = (1 << (32 - cnt)) - 1; - res = (d >> cnt) & mask; - if (cnt != 1) - res |= (d << (33 - cnt)); - if (ACCESS_FLAG(F_CF)) { /* carry flag is set */ - res |= 1 << (32 - cnt); - } - CONDITIONAL_SET_FLAG(cf, F_CF); - if (cnt == 1) { - CONDITIONAL_SET_FLAG(XOR2(ocf + ((d >> 30) & 0x2)), - F_OF); - } - } - return res; -} - -/**************************************************************************** -REMARKS: -Implements the ROL instruction and side effects. -****************************************************************************/ -u8 rol_byte(u8 d, u8 s) -{ - register unsigned int res, cnt, mask; - - /* rotate left */ - /* - s is the rotate distance. It varies from 0 - 8. - d is the byte object rotated. - - have - - CF B_7 ... B_0 - - The new rotate is done mod 8. - Much simpler than the "rcl" or "rcr" operations. - - IF n > 0 - 1) B_(7) .. B_(n) <- b_(8-(n+1)) .. b_(0) - 2) B_(n-1) .. B_(0) <- b_(7) .. b_(8-n) - */ - res = d; - if ((cnt = s % 8) != 0) { - /* B_(7) .. B_(n) <- b_(8-(n+1)) .. b_(0) */ - res = (d << cnt); - - /* B_(n-1) .. B_(0) <- b_(7) .. b_(8-n) */ - mask = (1 << cnt) - 1; - res |= (d >> (8 - cnt)) & mask; - - /* set the new carry flag, Note that it is the low order - bit of the result!!! */ - CONDITIONAL_SET_FLAG(res & 0x1, F_CF); - /* OVERFLOW is set *IFF* s==1, then it is the - xor of CF and the most significant bit. Blecck. */ - CONDITIONAL_SET_FLAG(s == 1 && - XOR2((res & 0x1) + ((res >> 6) & 0x2)), - F_OF); - } if (s != 0) { - /* set the new carry flag, Note that it is the low order - bit of the result!!! */ - CONDITIONAL_SET_FLAG(res & 0x1, F_CF); - } - return (u8)res; -} - -/**************************************************************************** -REMARKS: -Implements the ROL instruction and side effects. -****************************************************************************/ -u16 rol_word(u16 d, u8 s) -{ - register unsigned int res, cnt, mask; - - res = d; - if ((cnt = s % 16) != 0) { - res = (d << cnt); - mask = (1 << cnt) - 1; - res |= (d >> (16 - cnt)) & mask; - CONDITIONAL_SET_FLAG(res & 0x1, F_CF); - CONDITIONAL_SET_FLAG(s == 1 && - XOR2((res & 0x1) + ((res >> 14) & 0x2)), - F_OF); - } if (s != 0) { - /* set the new carry flag, Note that it is the low order - bit of the result!!! */ - CONDITIONAL_SET_FLAG(res & 0x1, F_CF); - } - return (u16)res; -} - -/**************************************************************************** -REMARKS: -Implements the ROL instruction and side effects. -****************************************************************************/ -u32 rol_long(u32 d, u8 s) -{ - register u32 res, cnt, mask; - - res = d; - if ((cnt = s % 32) != 0) { - res = (d << cnt); - mask = (1 << cnt) - 1; - res |= (d >> (32 - cnt)) & mask; - CONDITIONAL_SET_FLAG(res & 0x1, F_CF); - CONDITIONAL_SET_FLAG(s == 1 && - XOR2((res & 0x1) + ((res >> 30) & 0x2)), - F_OF); - } if (s != 0) { - /* set the new carry flag, Note that it is the low order - bit of the result!!! */ - CONDITIONAL_SET_FLAG(res & 0x1, F_CF); - } - return res; -} - -/**************************************************************************** -REMARKS: -Implements the ROR instruction and side effects. -****************************************************************************/ -u8 ror_byte(u8 d, u8 s) -{ - register unsigned int res, cnt, mask; - - /* rotate right */ - /* - s is the rotate distance. It varies from 0 - 8. - d is the byte object rotated. - - have - - B_7 ... B_0 - - The rotate is done mod 8. - - IF n > 0 - 1) B_(8-(n+1)) .. B_(0) <- b_(7) .. b_(n) - 2) B_(7) .. B_(8-n) <- b_(n-1) .. b_(0) - */ - res = d; - if ((cnt = s % 8) != 0) { /* not a typo, do nada if cnt==0 */ - /* B_(7) .. B_(8-n) <- b_(n-1) .. b_(0) */ - res = (d << (8 - cnt)); - - /* B_(8-(n+1)) .. B_(0) <- b_(7) .. b_(n) */ - mask = (1 << (8 - cnt)) - 1; - res |= (d >> (cnt)) & mask; - - /* set the new carry flag, Note that it is the low order - bit of the result!!! */ - CONDITIONAL_SET_FLAG(res & 0x80, F_CF); - /* OVERFLOW is set *IFF* s==1, then it is the - xor of the two most significant bits. Blecck. */ - CONDITIONAL_SET_FLAG(s == 1 && XOR2(res >> 6), F_OF); - } else if (s != 0) { - /* set the new carry flag, Note that it is the low order - bit of the result!!! */ - CONDITIONAL_SET_FLAG(res & 0x80, F_CF); - } - return (u8)res; -} - -/**************************************************************************** -REMARKS: -Implements the ROR instruction and side effects. -****************************************************************************/ -u16 ror_word(u16 d, u8 s) -{ - register unsigned int res, cnt, mask; - - res = d; - if ((cnt = s % 16) != 0) { - res = (d << (16 - cnt)); - mask = (1 << (16 - cnt)) - 1; - res |= (d >> (cnt)) & mask; - CONDITIONAL_SET_FLAG(res & 0x8000, F_CF); - CONDITIONAL_SET_FLAG(s == 1 && XOR2(res >> 14), F_OF); - } else if (s != 0) { - /* set the new carry flag, Note that it is the low order - bit of the result!!! */ - CONDITIONAL_SET_FLAG(res & 0x8000, F_CF); - } - return (u16)res; -} - -/**************************************************************************** -REMARKS: -Implements the ROR instruction and side effects. -****************************************************************************/ -u32 ror_long(u32 d, u8 s) -{ - register u32 res, cnt, mask; - - res = d; - if ((cnt = s % 32) != 0) { - res = (d << (32 - cnt)); - mask = (1 << (32 - cnt)) - 1; - res |= (d >> (cnt)) & mask; - CONDITIONAL_SET_FLAG(res & 0x80000000, F_CF); - CONDITIONAL_SET_FLAG(s == 1 && XOR2(res >> 30), F_OF); - } else if (s != 0) { - /* set the new carry flag, Note that it is the low order - bit of the result!!! */ - CONDITIONAL_SET_FLAG(res & 0x80000000, F_CF); - } - return res; -} - -/**************************************************************************** -REMARKS: -Implements the SHL instruction and side effects. -****************************************************************************/ -u8 shl_byte(u8 d, u8 s) -{ - unsigned int cnt, res, cf; - - if (s < 8) { - cnt = s % 8; - - /* last bit shifted out goes into carry flag */ - if (cnt > 0) { - res = d << cnt; - cf = d & (1 << (8 - cnt)); - CONDITIONAL_SET_FLAG(cf, F_CF); - CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - } else { - res = (u8) d; - } - - if (cnt == 1) { - /* Needs simplification. */ - CONDITIONAL_SET_FLAG( - (((res & 0x80) == 0x80) ^ - (ACCESS_FLAG(F_CF) != 0)), - /* was (M.x86.R_FLG&F_CF)==F_CF)), */ - F_OF); - } else { - CLEAR_FLAG(F_OF); - } - } else { - res = 0; - CONDITIONAL_SET_FLAG((d << (s-1)) & 0x80, F_CF); - CLEAR_FLAG(F_OF); - CLEAR_FLAG(F_SF); - SET_FLAG(F_PF); - SET_FLAG(F_ZF); - } - return (u8)res; -} - -/**************************************************************************** -REMARKS: -Implements the SHL instruction and side effects. -****************************************************************************/ -u16 shl_word(u16 d, u8 s) -{ - unsigned int cnt, res, cf; - - if (s < 16) { - cnt = s % 16; - if (cnt > 0) { - res = d << cnt; - cf = d & (1 << (16 - cnt)); - CONDITIONAL_SET_FLAG(cf, F_CF); - CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - } else { - res = (u16) d; - } - - if (cnt == 1) { - CONDITIONAL_SET_FLAG( - (((res & 0x8000) == 0x8000) ^ - (ACCESS_FLAG(F_CF) != 0)), - F_OF); - } else { - CLEAR_FLAG(F_OF); - } - } else { - res = 0; - CONDITIONAL_SET_FLAG((d << (s-1)) & 0x8000, F_CF); - CLEAR_FLAG(F_OF); - CLEAR_FLAG(F_SF); - SET_FLAG(F_PF); - SET_FLAG(F_ZF); - } - return (u16)res; -} - -/**************************************************************************** -REMARKS: -Implements the SHL instruction and side effects. -****************************************************************************/ -u32 shl_long(u32 d, u8 s) -{ - unsigned int cnt, res, cf; - - if (s < 32) { - cnt = s % 32; - if (cnt > 0) { - res = d << cnt; - cf = d & (1 << (32 - cnt)); - CONDITIONAL_SET_FLAG(cf, F_CF); - CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - } else { - res = d; - } - if (cnt == 1) { - CONDITIONAL_SET_FLAG((((res & 0x80000000) == 0x80000000) ^ - (ACCESS_FLAG(F_CF) != 0)), F_OF); - } else { - CLEAR_FLAG(F_OF); - } - } else { - res = 0; - CONDITIONAL_SET_FLAG((d << (s-1)) & 0x80000000, F_CF); - CLEAR_FLAG(F_OF); - CLEAR_FLAG(F_SF); - SET_FLAG(F_PF); - SET_FLAG(F_ZF); - } - return res; -} - -/**************************************************************************** -REMARKS: -Implements the SHR instruction and side effects. -****************************************************************************/ -u8 shr_byte(u8 d, u8 s) -{ - unsigned int cnt, res, cf; - - if (s < 8) { - cnt = s % 8; - if (cnt > 0) { - cf = d & (1 << (cnt - 1)); - res = d >> cnt; - CONDITIONAL_SET_FLAG(cf, F_CF); - CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - } else { - res = (u8) d; - } - - if (cnt == 1) { - CONDITIONAL_SET_FLAG(XOR2(res >> 6), F_OF); - } else { - CLEAR_FLAG(F_OF); - } - } else { - res = 0; - CONDITIONAL_SET_FLAG((d >> (s-1)) & 0x1, F_CF); - CLEAR_FLAG(F_OF); - CLEAR_FLAG(F_SF); - SET_FLAG(F_PF); - SET_FLAG(F_ZF); - } - return (u8)res; -} - -/**************************************************************************** -REMARKS: -Implements the SHR instruction and side effects. -****************************************************************************/ -u16 shr_word(u16 d, u8 s) -{ - unsigned int cnt, res, cf; - - if (s < 16) { - cnt = s % 16; - if (cnt > 0) { - cf = d & (1 << (cnt - 1)); - res = d >> cnt; - CONDITIONAL_SET_FLAG(cf, F_CF); - CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - } else { - res = d; - } - - if (cnt == 1) { - CONDITIONAL_SET_FLAG(XOR2(res >> 14), F_OF); - } else { - CLEAR_FLAG(F_OF); - } - } else { - res = 0; - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - SET_FLAG(F_ZF); - CLEAR_FLAG(F_SF); - CLEAR_FLAG(F_PF); - } - return (u16)res; -} - -/**************************************************************************** -REMARKS: -Implements the SHR instruction and side effects. -****************************************************************************/ -u32 shr_long(u32 d, u8 s) -{ - unsigned int cnt, res, cf; - - if (s < 32) { - cnt = s % 32; - if (cnt > 0) { - cf = d & (1 << (cnt - 1)); - res = d >> cnt; - CONDITIONAL_SET_FLAG(cf, F_CF); - CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - } else { - res = d; - } - if (cnt == 1) { - CONDITIONAL_SET_FLAG(XOR2(res >> 30), F_OF); - } else { - CLEAR_FLAG(F_OF); - } - } else { - res = 0; - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - SET_FLAG(F_ZF); - CLEAR_FLAG(F_SF); - CLEAR_FLAG(F_PF); - } - return res; -} - -/**************************************************************************** -REMARKS: -Implements the SAR instruction and side effects. -****************************************************************************/ -u8 sar_byte(u8 d, u8 s) -{ - unsigned int cnt, res, cf, mask, sf; - - res = d; - sf = d & 0x80; - cnt = s % 8; - if (cnt > 0 && cnt < 8) { - mask = (1 << (8 - cnt)) - 1; - cf = d & (1 << (cnt - 1)); - res = (d >> cnt) & mask; - CONDITIONAL_SET_FLAG(cf, F_CF); - if (sf) { - res |= ~mask; - } - CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - } else if (cnt >= 8) { - if (sf) { - res = 0xff; - SET_FLAG(F_CF); - CLEAR_FLAG(F_ZF); - SET_FLAG(F_SF); - SET_FLAG(F_PF); - } else { - res = 0; - CLEAR_FLAG(F_CF); - SET_FLAG(F_ZF); - CLEAR_FLAG(F_SF); - CLEAR_FLAG(F_PF); - } - } - return (u8)res; -} - -/**************************************************************************** -REMARKS: -Implements the SAR instruction and side effects. -****************************************************************************/ -u16 sar_word(u16 d, u8 s) -{ - unsigned int cnt, res, cf, mask, sf; - - sf = d & 0x8000; - cnt = s % 16; - res = d; - if (cnt > 0 && cnt < 16) { - mask = (1 << (16 - cnt)) - 1; - cf = d & (1 << (cnt - 1)); - res = (d >> cnt) & mask; - CONDITIONAL_SET_FLAG(cf, F_CF); - if (sf) { - res |= ~mask; - } - CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - } else if (cnt >= 16) { - if (sf) { - res = 0xffff; - SET_FLAG(F_CF); - CLEAR_FLAG(F_ZF); - SET_FLAG(F_SF); - SET_FLAG(F_PF); - } else { - res = 0; - CLEAR_FLAG(F_CF); - SET_FLAG(F_ZF); - CLEAR_FLAG(F_SF); - CLEAR_FLAG(F_PF); - } - } - return (u16)res; -} - -/**************************************************************************** -REMARKS: -Implements the SAR instruction and side effects. -****************************************************************************/ -u32 sar_long(u32 d, u8 s) -{ - u32 cnt, res, cf, mask, sf; - - sf = d & 0x80000000; - cnt = s % 32; - res = d; - if (cnt > 0 && cnt < 32) { - mask = (1 << (32 - cnt)) - 1; - cf = d & (1 << (cnt - 1)); - res = (d >> cnt) & mask; - CONDITIONAL_SET_FLAG(cf, F_CF); - if (sf) { - res |= ~mask; - } - CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - } else if (cnt >= 32) { - if (sf) { - res = 0xffffffff; - SET_FLAG(F_CF); - CLEAR_FLAG(F_ZF); - SET_FLAG(F_SF); - SET_FLAG(F_PF); - } else { - res = 0; - CLEAR_FLAG(F_CF); - SET_FLAG(F_ZF); - CLEAR_FLAG(F_SF); - CLEAR_FLAG(F_PF); - } - } - return res; -} - -/**************************************************************************** -REMARKS: -Implements the SHLD instruction and side effects. -****************************************************************************/ -u16 shld_word (u16 d, u16 fill, u8 s) -{ - unsigned int cnt, res, cf; - - if (s < 16) { - cnt = s % 16; - if (cnt > 0) { - res = (d << cnt) | (fill >> (16-cnt)); - cf = d & (1 << (16 - cnt)); - CONDITIONAL_SET_FLAG(cf, F_CF); - CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - } else { - res = d; - } - if (cnt == 1) { - CONDITIONAL_SET_FLAG((((res & 0x8000) == 0x8000) ^ - (ACCESS_FLAG(F_CF) != 0)), F_OF); - } else { - CLEAR_FLAG(F_OF); - } - } else { - res = 0; - CONDITIONAL_SET_FLAG((d << (s-1)) & 0x8000, F_CF); - CLEAR_FLAG(F_OF); - CLEAR_FLAG(F_SF); - SET_FLAG(F_PF); - SET_FLAG(F_ZF); - } - return (u16)res; -} - -/**************************************************************************** -REMARKS: -Implements the SHLD instruction and side effects. -****************************************************************************/ -u32 shld_long (u32 d, u32 fill, u8 s) -{ - unsigned int cnt, res, cf; - - if (s < 32) { - cnt = s % 32; - if (cnt > 0) { - res = (d << cnt) | (fill >> (32-cnt)); - cf = d & (1 << (32 - cnt)); - CONDITIONAL_SET_FLAG(cf, F_CF); - CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - } else { - res = d; - } - if (cnt == 1) { - CONDITIONAL_SET_FLAG((((res & 0x80000000) == 0x80000000) ^ - (ACCESS_FLAG(F_CF) != 0)), F_OF); - } else { - CLEAR_FLAG(F_OF); - } - } else { - res = 0; - CONDITIONAL_SET_FLAG((d << (s-1)) & 0x80000000, F_CF); - CLEAR_FLAG(F_OF); - CLEAR_FLAG(F_SF); - SET_FLAG(F_PF); - SET_FLAG(F_ZF); - } - return res; -} - -/**************************************************************************** -REMARKS: -Implements the SHRD instruction and side effects. -****************************************************************************/ -u16 shrd_word (u16 d, u16 fill, u8 s) -{ - unsigned int cnt, res, cf; - - if (s < 16) { - cnt = s % 16; - if (cnt > 0) { - cf = d & (1 << (cnt - 1)); - res = (d >> cnt) | (fill << (16 - cnt)); - CONDITIONAL_SET_FLAG(cf, F_CF); - CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - } else { - res = d; - } - - if (cnt == 1) { - CONDITIONAL_SET_FLAG(XOR2(res >> 14), F_OF); - } else { - CLEAR_FLAG(F_OF); - } - } else { - res = 0; - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - SET_FLAG(F_ZF); - CLEAR_FLAG(F_SF); - CLEAR_FLAG(F_PF); - } - return (u16)res; -} - -/**************************************************************************** -REMARKS: -Implements the SHRD instruction and side effects. -****************************************************************************/ -u32 shrd_long (u32 d, u32 fill, u8 s) -{ - unsigned int cnt, res, cf; - - if (s < 32) { - cnt = s % 32; - if (cnt > 0) { - cf = d & (1 << (cnt - 1)); - res = (d >> cnt) | (fill << (32 - cnt)); - CONDITIONAL_SET_FLAG(cf, F_CF); - CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - } else { - res = d; - } - if (cnt == 1) { - CONDITIONAL_SET_FLAG(XOR2(res >> 30), F_OF); - } else { - CLEAR_FLAG(F_OF); - } - } else { - res = 0; - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - SET_FLAG(F_ZF); - CLEAR_FLAG(F_SF); - CLEAR_FLAG(F_PF); - } - return res; -} - -/**************************************************************************** -REMARKS: -Implements the SBB instruction and side effects. -****************************************************************************/ -u8 sbb_byte(u8 d, u8 s) -{ - register u32 res; /* all operands in native machine order */ - register u32 bc; - - if (ACCESS_FLAG(F_CF)) - res = d - s - 1; - else - res = d - s; - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the borrow chain. See note at top */ - bc = (res & (~d | s)) | (~d & s); - CONDITIONAL_SET_FLAG(bc & 0x80, F_CF); - CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF); - CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); - return (u8)res; -} - -/**************************************************************************** -REMARKS: -Implements the SBB instruction and side effects. -****************************************************************************/ -u16 sbb_word(u16 d, u16 s) -{ - register u32 res; /* all operands in native machine order */ - register u32 bc; - - if (ACCESS_FLAG(F_CF)) - res = d - s - 1; - else - res = d - s; - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the borrow chain. See note at top */ - bc = (res & (~d | s)) | (~d & s); - CONDITIONAL_SET_FLAG(bc & 0x8000, F_CF); - CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF); - CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); - return (u16)res; -} - -/**************************************************************************** -REMARKS: -Implements the SBB instruction and side effects. -****************************************************************************/ -u32 sbb_long(u32 d, u32 s) -{ - register u32 res; /* all operands in native machine order */ - register u32 bc; - - if (ACCESS_FLAG(F_CF)) - res = d - s - 1; - else - res = d - s; - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the borrow chain. See note at top */ - bc = (res & (~d | s)) | (~d & s); - CONDITIONAL_SET_FLAG(bc & 0x80000000, F_CF); - CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF); - CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the SUB instruction and side effects. -****************************************************************************/ -u8 sub_byte(u8 d, u8 s) -{ - register u32 res; /* all operands in native machine order */ - register u32 bc; - - res = d - s; - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the borrow chain. See note at top */ - bc = (res & (~d | s)) | (~d & s); - CONDITIONAL_SET_FLAG(bc & 0x80, F_CF); - CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF); - CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); - return (u8)res; -} - -/**************************************************************************** -REMARKS: -Implements the SUB instruction and side effects. -****************************************************************************/ -u16 sub_word(u16 d, u16 s) -{ - register u32 res; /* all operands in native machine order */ - register u32 bc; - - res = d - s; - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the borrow chain. See note at top */ - bc = (res & (~d | s)) | (~d & s); - CONDITIONAL_SET_FLAG(bc & 0x8000, F_CF); - CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF); - CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); - return (u16)res; -} - -/**************************************************************************** -REMARKS: -Implements the SUB instruction and side effects. -****************************************************************************/ -u32 sub_long(u32 d, u32 s) -{ - register u32 res; /* all operands in native machine order */ - register u32 bc; - - res = d - s; - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - - /* calculate the borrow chain. See note at top */ - bc = (res & (~d | s)) | (~d & s); - CONDITIONAL_SET_FLAG(bc & 0x80000000, F_CF); - CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF); - CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the TEST instruction and side effects. -****************************************************************************/ -void test_byte(u8 d, u8 s) -{ - register u32 res; /* all operands in native machine order */ - - res = d & s; - - CLEAR_FLAG(F_OF); - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - CONDITIONAL_SET_FLAG(res == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - /* AF == dont care */ - CLEAR_FLAG(F_CF); -} - -/**************************************************************************** -REMARKS: -Implements the TEST instruction and side effects. -****************************************************************************/ -void test_word(u16 d, u16 s) -{ - register u32 res; /* all operands in native machine order */ - - res = d & s; - - CLEAR_FLAG(F_OF); - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG(res == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - /* AF == dont care */ - CLEAR_FLAG(F_CF); -} - -/**************************************************************************** -REMARKS: -Implements the TEST instruction and side effects. -****************************************************************************/ -void test_long(u32 d, u32 s) -{ - register u32 res; /* all operands in native machine order */ - - res = d & s; - - CLEAR_FLAG(F_OF); - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG(res == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - /* AF == dont care */ - CLEAR_FLAG(F_CF); -} - -/**************************************************************************** -REMARKS: -Implements the XOR instruction and side effects. -****************************************************************************/ -u8 xor_byte(u8 d, u8 s) -{ - register u8 res; /* all operands in native machine order */ - - res = d ^ s; - CLEAR_FLAG(F_OF); - CONDITIONAL_SET_FLAG(res & 0x80, F_SF); - CONDITIONAL_SET_FLAG(res == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res), F_PF); - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_AF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the XOR instruction and side effects. -****************************************************************************/ -u16 xor_word(u16 d, u16 s) -{ - register u16 res; /* all operands in native machine order */ - - res = d ^ s; - CLEAR_FLAG(F_OF); - CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); - CONDITIONAL_SET_FLAG(res == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_AF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the XOR instruction and side effects. -****************************************************************************/ -u32 xor_long(u32 d, u32 s) -{ - register u32 res; /* all operands in native machine order */ - - res = d ^ s; - CLEAR_FLAG(F_OF); - CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); - CONDITIONAL_SET_FLAG(res == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_AF); - return res; -} - -/**************************************************************************** -REMARKS: -Implements the IMUL instruction and side effects. -****************************************************************************/ -void imul_byte(u8 s) -{ - s16 res = (s16)((s8)M.x86.R_AL * (s8)s); - - M.x86.R_AX = res; - if (((M.x86.R_AL & 0x80) == 0 && M.x86.R_AH == 0x00) || - ((M.x86.R_AL & 0x80) != 0 && M.x86.R_AH == 0xFF)) { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } else { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } -} - -/**************************************************************************** -REMARKS: -Implements the IMUL instruction and side effects. -****************************************************************************/ -void imul_word(u16 s) -{ - s32 res = (s16)M.x86.R_AX * (s16)s; - - M.x86.R_AX = (u16)res; - M.x86.R_DX = (u16)(res >> 16); - if (((M.x86.R_AX & 0x8000) == 0 && M.x86.R_DX == 0x00) || - ((M.x86.R_AX & 0x8000) != 0 && M.x86.R_DX == 0xFF)) { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } else { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } -} - -/**************************************************************************** -REMARKS: -Implements the IMUL instruction and side effects. -****************************************************************************/ -void imul_long_direct(u32 *res_lo, u32* res_hi,u32 d, u32 s) -{ -#ifdef __HAS_LONG_LONG__ - s64 res = (s32)d * (s32)s; - - *res_lo = (u32)res; - *res_hi = (u32)(res >> 32); -#else - u32 d_lo,d_hi,d_sign; - u32 s_lo,s_hi,s_sign; - u32 rlo_lo,rlo_hi,rhi_lo; - - if ((d_sign = d & 0x80000000) != 0) - d = -d; - d_lo = d & 0xFFFF; - d_hi = d >> 16; - if ((s_sign = s & 0x80000000) != 0) - s = -s; - s_lo = s & 0xFFFF; - s_hi = s >> 16; - rlo_lo = d_lo * s_lo; - rlo_hi = (d_hi * s_lo + d_lo * s_hi) + (rlo_lo >> 16); - rhi_lo = d_hi * s_hi + (rlo_hi >> 16); - *res_lo = (rlo_hi << 16) | (rlo_lo & 0xFFFF); - *res_hi = rhi_lo; - if (d_sign != s_sign) { - d = ~*res_lo; - s = (((d & 0xFFFF) + 1) >> 16) + (d >> 16); - *res_lo = ~*res_lo+1; - *res_hi = ~*res_hi+(s >> 16); - } -#endif -} - -/**************************************************************************** -REMARKS: -Implements the IMUL instruction and side effects. -****************************************************************************/ -void imul_long(u32 s) -{ - imul_long_direct(&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s); - if (((M.x86.R_EAX & 0x80000000) == 0 && M.x86.R_EDX == 0x00) || - ((M.x86.R_EAX & 0x80000000) != 0 && M.x86.R_EDX == 0xFF)) { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } else { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } -} - -/**************************************************************************** -REMARKS: -Implements the MUL instruction and side effects. -****************************************************************************/ -void mul_byte(u8 s) -{ - u16 res = (u16)(M.x86.R_AL * s); - - M.x86.R_AX = res; - if (M.x86.R_AH == 0) { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } else { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } -} - -/**************************************************************************** -REMARKS: -Implements the MUL instruction and side effects. -****************************************************************************/ -void mul_word(u16 s) -{ - u32 res = M.x86.R_AX * s; - - M.x86.R_AX = (u16)res; - M.x86.R_DX = (u16)(res >> 16); - if (M.x86.R_DX == 0) { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } else { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } -} - -/**************************************************************************** -REMARKS: -Implements the MUL instruction and side effects. -****************************************************************************/ -void mul_long(u32 s) -{ -#ifdef __HAS_LONG_LONG__ - u64 res = (u32)M.x86.R_EAX * (u32)s; - - M.x86.R_EAX = (u32)res; - M.x86.R_EDX = (u32)(res >> 32); -#else - u32 a,a_lo,a_hi; - u32 s_lo,s_hi; - u32 rlo_lo,rlo_hi,rhi_lo; - - a = M.x86.R_EAX; - a_lo = a & 0xFFFF; - a_hi = a >> 16; - s_lo = s & 0xFFFF; - s_hi = s >> 16; - rlo_lo = a_lo * s_lo; - rlo_hi = (a_hi * s_lo + a_lo * s_hi) + (rlo_lo >> 16); - rhi_lo = a_hi * s_hi + (rlo_hi >> 16); - M.x86.R_EAX = (rlo_hi << 16) | (rlo_lo & 0xFFFF); - M.x86.R_EDX = rhi_lo; -#endif - - if (M.x86.R_EDX == 0) { - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_OF); - } else { - SET_FLAG(F_CF); - SET_FLAG(F_OF); - } -} - -/**************************************************************************** -REMARKS: -Implements the IDIV instruction and side effects. -****************************************************************************/ -void idiv_byte(u8 s) -{ - s32 dvd, div, mod; - - dvd = (s16)M.x86.R_AX; - if (s == 0) { - x86emu_intr_raise(0); - return; - } - div = dvd / (s8)s; - mod = dvd % (s8)s; - if (abs(div) > 0x7f) { - x86emu_intr_raise(0); - return; - } - M.x86.R_AL = (s8) div; - M.x86.R_AH = (s8) mod; -} - -/**************************************************************************** -REMARKS: -Implements the IDIV instruction and side effects. -****************************************************************************/ -void idiv_word(u16 s) -{ - s32 dvd, div, mod; - - dvd = (((s32)M.x86.R_DX) << 16) | M.x86.R_AX; - if (s == 0) { - x86emu_intr_raise(0); - return; - } - div = dvd / (s16)s; - mod = dvd % (s16)s; - if (abs(div) > 0x7fff) { - x86emu_intr_raise(0); - return; - } - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_SF); - CONDITIONAL_SET_FLAG(div == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF); - - M.x86.R_AX = (u16)div; - M.x86.R_DX = (u16)mod; -} - -/**************************************************************************** -REMARKS: -Implements the IDIV instruction and side effects. -****************************************************************************/ -void idiv_long(u32 s) -{ -#ifdef __HAS_LONG_LONG__ - s64 dvd, div, mod; - - dvd = (((s64)M.x86.R_EDX) << 32) | M.x86.R_EAX; - if (s == 0) { - x86emu_intr_raise(0); - return; - } - div = dvd / (s32)s; - mod = dvd % (s32)s; - if (abs(div) > 0x7fffffff) { - x86emu_intr_raise(0); - return; - } -#else - s32 div = 0, mod; - s32 h_dvd = M.x86.R_EDX; - u32 l_dvd = M.x86.R_EAX; - u32 abs_s = s & 0x7FFFFFFF; - u32 abs_h_dvd = h_dvd & 0x7FFFFFFF; - u32 h_s = abs_s >> 1; - u32 l_s = abs_s << 31; - int counter = 31; - int carry; - - if (s == 0) { - x86emu_intr_raise(0); - return; - } - do { - div <<= 1; - carry = (l_dvd >= l_s) ? 0 : 1; - - if (abs_h_dvd < (h_s + carry)) { - h_s >>= 1; - l_s = abs_s << (--counter); - continue; - } else { - abs_h_dvd -= (h_s + carry); - l_dvd = carry ? ((0xFFFFFFFF - l_s) + l_dvd + 1) - : (l_dvd - l_s); - h_s >>= 1; - l_s = abs_s << (--counter); - div |= 1; - continue; - } - - } while (counter > -1); - /* overflow */ - if (abs_h_dvd || (l_dvd > abs_s)) { - x86emu_intr_raise(0); - return; - } - /* sign */ - div |= ((h_dvd & 0x10000000) ^ (s & 0x10000000)); - mod = l_dvd; - -#endif - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_AF); - CLEAR_FLAG(F_SF); - SET_FLAG(F_ZF); - CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF); - - M.x86.R_EAX = (u32)div; - M.x86.R_EDX = (u32)mod; -} - -/**************************************************************************** -REMARKS: -Implements the DIV instruction and side effects. -****************************************************************************/ -void div_byte(u8 s) -{ - u32 dvd, div, mod; - - dvd = M.x86.R_AX; - if (s == 0) { - x86emu_intr_raise(0); - return; - } - div = dvd / (u8)s; - mod = dvd % (u8)s; - if (abs(div) > 0xff) { - x86emu_intr_raise(0); - return; - } - M.x86.R_AL = (u8)div; - M.x86.R_AH = (u8)mod; -} - -/**************************************************************************** -REMARKS: -Implements the DIV instruction and side effects. -****************************************************************************/ -void div_word(u16 s) -{ - u32 dvd, div, mod; - - dvd = (((u32)M.x86.R_DX) << 16) | M.x86.R_AX; - if (s == 0) { - x86emu_intr_raise(0); - return; - } - div = dvd / (u16)s; - mod = dvd % (u16)s; - if (abs(div) > 0xffff) { - x86emu_intr_raise(0); - return; - } - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_SF); - CONDITIONAL_SET_FLAG(div == 0, F_ZF); - CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF); - - M.x86.R_AX = (u16)div; - M.x86.R_DX = (u16)mod; -} - -/**************************************************************************** -REMARKS: -Implements the DIV instruction and side effects. -****************************************************************************/ -void div_long(u32 s) -{ -#ifdef __HAS_LONG_LONG__ - u64 dvd, div, mod; - - dvd = (((u64)M.x86.R_EDX) << 32) | M.x86.R_EAX; - if (s == 0) { - x86emu_intr_raise(0); - return; - } - div = dvd / (u32)s; - mod = dvd % (u32)s; - if (abs(div) > 0xffffffff) { - x86emu_intr_raise(0); - return; - } -#else - s32 div = 0, mod; - s32 h_dvd = M.x86.R_EDX; - u32 l_dvd = M.x86.R_EAX; - - u32 h_s = s; - u32 l_s = 0; - int counter = 32; - int carry; - - if (s == 0) { - x86emu_intr_raise(0); - return; - } - do { - div <<= 1; - carry = (l_dvd >= l_s) ? 0 : 1; - - if (h_dvd < (h_s + carry)) { - h_s >>= 1; - l_s = s << (--counter); - continue; - } else { - h_dvd -= (h_s + carry); - l_dvd = carry ? ((0xFFFFFFFF - l_s) + l_dvd + 1) - : (l_dvd - l_s); - h_s >>= 1; - l_s = s << (--counter); - div |= 1; - continue; - } - - } while (counter > -1); - /* overflow */ - if (h_dvd || (l_dvd > s)) { - x86emu_intr_raise(0); - return; - } - mod = l_dvd; -#endif - CLEAR_FLAG(F_CF); - CLEAR_FLAG(F_AF); - CLEAR_FLAG(F_SF); - SET_FLAG(F_ZF); - CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF); - - M.x86.R_EAX = (u32)div; - M.x86.R_EDX = (u32)mod; -} - -#endif /* __HAVE_INLINE_ASSEMBLER__ */ - -/**************************************************************************** -REMARKS: -Implements the IN string instruction and side effects. -****************************************************************************/ -void ins(int size) -{ - int inc = size; - - if (ACCESS_FLAG(F_DF)) { - inc = -size; - } - if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { - /* dont care whether REPE or REPNE */ - /* in until CX is ZERO. */ - u32 count = ((M.x86.mode & SYSMODE_PREFIX_DATA) ? - M.x86.R_ECX : M.x86.R_CX); - switch (size) { - case 1: - while (count--) { - store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, - (*sys_inb)(M.x86.R_DX)); - M.x86.R_DI += inc; - } - break; - - case 2: - while (count--) { - store_data_word_abs(M.x86.R_ES, M.x86.R_DI, - (*sys_inw)(M.x86.R_DX)); - M.x86.R_DI += inc; - } - break; - case 4: - while (count--) { - store_data_long_abs(M.x86.R_ES, M.x86.R_DI, - (*sys_inl)(M.x86.R_DX)); - M.x86.R_DI += inc; - break; - } - } - M.x86.R_CX = 0; - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_ECX = 0; - } - M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); - } else { - switch (size) { - case 1: - store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, - (*sys_inb)(M.x86.R_DX)); - break; - case 2: - store_data_word_abs(M.x86.R_ES, M.x86.R_DI, - (*sys_inw)(M.x86.R_DX)); - break; - case 4: - store_data_long_abs(M.x86.R_ES, M.x86.R_DI, - (*sys_inl)(M.x86.R_DX)); - break; - } - M.x86.R_DI += inc; - } -} - -/**************************************************************************** -REMARKS: -Implements the OUT string instruction and side effects. -****************************************************************************/ -void outs(int size) -{ - int inc = size; - - if (ACCESS_FLAG(F_DF)) { - inc = -size; - } - if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { - /* dont care whether REPE or REPNE */ - /* out until CX is ZERO. */ - u32 count = ((M.x86.mode & SYSMODE_PREFIX_DATA) ? - M.x86.R_ECX : M.x86.R_CX); - switch (size) { - case 1: - while (count--) { - (*sys_outb)(M.x86.R_DX, - fetch_data_byte_abs(M.x86.R_ES, M.x86.R_SI)); - M.x86.R_SI += inc; - } - break; - - case 2: - while (count--) { - (*sys_outw)(M.x86.R_DX, - fetch_data_word_abs(M.x86.R_ES, M.x86.R_SI)); - M.x86.R_SI += inc; - } - break; - case 4: - while (count--) { - (*sys_outl)(M.x86.R_DX, - fetch_data_long_abs(M.x86.R_ES, M.x86.R_SI)); - M.x86.R_SI += inc; - break; - } - } - M.x86.R_CX = 0; - if (M.x86.mode & SYSMODE_PREFIX_DATA) { - M.x86.R_ECX = 0; - } - M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); - } else { - switch (size) { - case 1: - (*sys_outb)(M.x86.R_DX, - fetch_data_byte_abs(M.x86.R_ES, M.x86.R_SI)); - break; - case 2: - (*sys_outw)(M.x86.R_DX, - fetch_data_word_abs(M.x86.R_ES, M.x86.R_SI)); - break; - case 4: - (*sys_outl)(M.x86.R_DX, - fetch_data_long_abs(M.x86.R_ES, M.x86.R_SI)); - break; - } - M.x86.R_SI += inc; - } -} - -/**************************************************************************** -PARAMETERS: -addr - Address to fetch word from - -REMARKS: -Fetches a word from emulator memory using an absolute address. -****************************************************************************/ -u16 mem_access_word(int addr) -{ -DB( if (CHECK_MEM_ACCESS()) - x86emu_check_mem_access(addr);) - return (*sys_rdw)(addr); -} - -/**************************************************************************** -REMARKS: -Pushes a word onto the stack. - -NOTE: Do not inline this, as (*sys_wrX) is already inline! -****************************************************************************/ -void push_word(u16 w) -{ -DB( if (CHECK_SP_ACCESS()) - x86emu_check_sp_access();) - M.x86.R_SP -= 2; - (*sys_wrw)(((u32)M.x86.R_SS << 4) + M.x86.R_SP, w); -} - -/**************************************************************************** -REMARKS: -Pushes a long onto the stack. - -NOTE: Do not inline this, as (*sys_wrX) is already inline! -****************************************************************************/ -void push_long(u32 w) -{ -DB( if (CHECK_SP_ACCESS()) - x86emu_check_sp_access();) - M.x86.R_SP -= 4; - (*sys_wrl)(((u32)M.x86.R_SS << 4) + M.x86.R_SP, w); -} - -/**************************************************************************** -REMARKS: -Pops a word from the stack. - -NOTE: Do not inline this, as (*sys_rdX) is already inline! -****************************************************************************/ -u16 pop_word(void) -{ - register u16 res; - -DB( if (CHECK_SP_ACCESS()) - x86emu_check_sp_access();) - res = (*sys_rdw)(((u32)M.x86.R_SS << 4) + M.x86.R_SP); - M.x86.R_SP += 2; - return res; -} - -/**************************************************************************** -REMARKS: -Pops a long from the stack. - -NOTE: Do not inline this, as (*sys_rdX) is already inline! -****************************************************************************/ -u32 pop_long(void) -{ - register u32 res; - -DB( if (CHECK_SP_ACCESS()) - x86emu_check_sp_access();) - res = (*sys_rdl)(((u32)M.x86.R_SS << 4) + M.x86.R_SP); - M.x86.R_SP += 4; - return res; -} - -#ifdef __HAVE_INLINE_ASSEMBLER__ - -u16 aaa_word (u16 d) -{ return aaa_word_asm(&M.x86.R_EFLG,d); } - -u16 aas_word (u16 d) -{ return aas_word_asm(&M.x86.R_EFLG,d); } - -u16 aad_word (u16 d) -{ return aad_word_asm(&M.x86.R_EFLG,d); } - -u16 aam_word (u8 d) -{ return aam_word_asm(&M.x86.R_EFLG,d); } - -u8 adc_byte (u8 d, u8 s) -{ return adc_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 adc_word (u16 d, u16 s) -{ return adc_word_asm(&M.x86.R_EFLG,d,s); } - -u32 adc_long (u32 d, u32 s) -{ return adc_long_asm(&M.x86.R_EFLG,d,s); } - -u8 add_byte (u8 d, u8 s) -{ return add_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 add_word (u16 d, u16 s) -{ return add_word_asm(&M.x86.R_EFLG,d,s); } - -u32 add_long (u32 d, u32 s) -{ return add_long_asm(&M.x86.R_EFLG,d,s); } - -u8 and_byte (u8 d, u8 s) -{ return and_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 and_word (u16 d, u16 s) -{ return and_word_asm(&M.x86.R_EFLG,d,s); } - -u32 and_long (u32 d, u32 s) -{ return and_long_asm(&M.x86.R_EFLG,d,s); } - -u8 cmp_byte (u8 d, u8 s) -{ return cmp_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 cmp_word (u16 d, u16 s) -{ return cmp_word_asm(&M.x86.R_EFLG,d,s); } - -u32 cmp_long (u32 d, u32 s) -{ return cmp_long_asm(&M.x86.R_EFLG,d,s); } - -u8 daa_byte (u8 d) -{ return daa_byte_asm(&M.x86.R_EFLG,d); } - -u8 das_byte (u8 d) -{ return das_byte_asm(&M.x86.R_EFLG,d); } - -u8 dec_byte (u8 d) -{ return dec_byte_asm(&M.x86.R_EFLG,d); } - -u16 dec_word (u16 d) -{ return dec_word_asm(&M.x86.R_EFLG,d); } - -u32 dec_long (u32 d) -{ return dec_long_asm(&M.x86.R_EFLG,d); } - -u8 inc_byte (u8 d) -{ return inc_byte_asm(&M.x86.R_EFLG,d); } - -u16 inc_word (u16 d) -{ return inc_word_asm(&M.x86.R_EFLG,d); } - -u32 inc_long (u32 d) -{ return inc_long_asm(&M.x86.R_EFLG,d); } - -u8 or_byte (u8 d, u8 s) -{ return or_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 or_word (u16 d, u16 s) -{ return or_word_asm(&M.x86.R_EFLG,d,s); } - -u32 or_long (u32 d, u32 s) -{ return or_long_asm(&M.x86.R_EFLG,d,s); } - -u8 neg_byte (u8 s) -{ return neg_byte_asm(&M.x86.R_EFLG,s); } - -u16 neg_word (u16 s) -{ return neg_word_asm(&M.x86.R_EFLG,s); } - -u32 neg_long (u32 s) -{ return neg_long_asm(&M.x86.R_EFLG,s); } - -u8 not_byte (u8 s) -{ return not_byte_asm(&M.x86.R_EFLG,s); } - -u16 not_word (u16 s) -{ return not_word_asm(&M.x86.R_EFLG,s); } - -u32 not_long (u32 s) -{ return not_long_asm(&M.x86.R_EFLG,s); } - -u8 rcl_byte (u8 d, u8 s) -{ return rcl_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 rcl_word (u16 d, u8 s) -{ return rcl_word_asm(&M.x86.R_EFLG,d,s); } - -u32 rcl_long (u32 d, u8 s) -{ return rcl_long_asm(&M.x86.R_EFLG,d,s); } - -u8 rcr_byte (u8 d, u8 s) -{ return rcr_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 rcr_word (u16 d, u8 s) -{ return rcr_word_asm(&M.x86.R_EFLG,d,s); } - -u32 rcr_long (u32 d, u8 s) -{ return rcr_long_asm(&M.x86.R_EFLG,d,s); } - -u8 rol_byte (u8 d, u8 s) -{ return rol_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 rol_word (u16 d, u8 s) -{ return rol_word_asm(&M.x86.R_EFLG,d,s); } - -u32 rol_long (u32 d, u8 s) -{ return rol_long_asm(&M.x86.R_EFLG,d,s); } - -u8 ror_byte (u8 d, u8 s) -{ return ror_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 ror_word (u16 d, u8 s) -{ return ror_word_asm(&M.x86.R_EFLG,d,s); } - -u32 ror_long (u32 d, u8 s) -{ return ror_long_asm(&M.x86.R_EFLG,d,s); } - -u8 shl_byte (u8 d, u8 s) -{ return shl_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 shl_word (u16 d, u8 s) -{ return shl_word_asm(&M.x86.R_EFLG,d,s); } - -u32 shl_long (u32 d, u8 s) -{ return shl_long_asm(&M.x86.R_EFLG,d,s); } - -u8 shr_byte (u8 d, u8 s) -{ return shr_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 shr_word (u16 d, u8 s) -{ return shr_word_asm(&M.x86.R_EFLG,d,s); } - -u32 shr_long (u32 d, u8 s) -{ return shr_long_asm(&M.x86.R_EFLG,d,s); } - -u8 sar_byte (u8 d, u8 s) -{ return sar_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 sar_word (u16 d, u8 s) -{ return sar_word_asm(&M.x86.R_EFLG,d,s); } - -u32 sar_long (u32 d, u8 s) -{ return sar_long_asm(&M.x86.R_EFLG,d,s); } - -u16 shld_word (u16 d, u16 fill, u8 s) -{ return shld_word_asm(&M.x86.R_EFLG,d,fill,s); } - -u32 shld_long (u32 d, u32 fill, u8 s) -{ return shld_long_asm(&M.x86.R_EFLG,d,fill,s); } - -u16 shrd_word (u16 d, u16 fill, u8 s) -{ return shrd_word_asm(&M.x86.R_EFLG,d,fill,s); } - -u32 shrd_long (u32 d, u32 fill, u8 s) -{ return shrd_long_asm(&M.x86.R_EFLG,d,fill,s); } - -u8 sbb_byte (u8 d, u8 s) -{ return sbb_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 sbb_word (u16 d, u16 s) -{ return sbb_word_asm(&M.x86.R_EFLG,d,s); } - -u32 sbb_long (u32 d, u32 s) -{ return sbb_long_asm(&M.x86.R_EFLG,d,s); } - -u8 sub_byte (u8 d, u8 s) -{ return sub_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 sub_word (u16 d, u16 s) -{ return sub_word_asm(&M.x86.R_EFLG,d,s); } - -u32 sub_long (u32 d, u32 s) -{ return sub_long_asm(&M.x86.R_EFLG,d,s); } - -void test_byte (u8 d, u8 s) -{ test_byte_asm(&M.x86.R_EFLG,d,s); } - -void test_word (u16 d, u16 s) -{ test_word_asm(&M.x86.R_EFLG,d,s); } - -void test_long (u32 d, u32 s) -{ test_long_asm(&M.x86.R_EFLG,d,s); } - -u8 xor_byte (u8 d, u8 s) -{ return xor_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 xor_word (u16 d, u16 s) -{ return xor_word_asm(&M.x86.R_EFLG,d,s); } - -u32 xor_long (u32 d, u32 s) -{ return xor_long_asm(&M.x86.R_EFLG,d,s); } - -void imul_byte (u8 s) -{ imul_byte_asm(&M.x86.R_EFLG,&M.x86.R_AX,M.x86.R_AL,s); } - -void imul_word (u16 s) -{ imul_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,s); } - -void imul_long (u32 s) -{ imul_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s); } - -void imul_long_direct(u32 *res_lo, u32* res_hi,u32 d, u32 s) -{ imul_long_asm(&M.x86.R_EFLG,res_lo,res_hi,d,s); } - -void mul_byte (u8 s) -{ mul_byte_asm(&M.x86.R_EFLG,&M.x86.R_AX,M.x86.R_AL,s); } - -void mul_word (u16 s) -{ mul_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,s); } - -void mul_long (u32 s) -{ mul_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s); } - -void idiv_byte (u8 s) -{ idiv_byte_asm(&M.x86.R_EFLG,&M.x86.R_AL,&M.x86.R_AH,M.x86.R_AX,s); } - -void idiv_word (u16 s) -{ idiv_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,M.x86.R_DX,s); } - -void idiv_long (u32 s) -{ idiv_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,M.x86.R_EDX,s); } - -void div_byte (u8 s) -{ div_byte_asm(&M.x86.R_EFLG,&M.x86.R_AL,&M.x86.R_AH,M.x86.R_AX,s); } - -void div_word (u16 s) -{ div_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,M.x86.R_DX,s); } - -void div_long (u32 s) -{ div_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,M.x86.R_EDX,s); } - -#endif diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/sys.c b/board/MAI/bios_emulator/scitech/src/x86emu/sys.c deleted file mode 100644 index afe58f8647..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/sys.c +++ /dev/null @@ -1,658 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: This file includes subroutines which are related to -* programmed I/O and memory access. Included in this module -* are default functions with limited usefulness. For real -* uses these functions will most likely be overriden by the -* user library. -* -****************************************************************************/ - -#include "x86emu.h" -#include "x86emu/regs.h" -#include "x86emu/debug.h" -#include "x86emu/prim_ops.h" -#include - -/*------------------------- Global Variables ------------------------------*/ - -X86EMU_sysEnv _X86EMU_env; /* Global emulator machine state */ -X86EMU_intrFuncs _X86EMU_intrTab[256]; - -/*----------------------------- Implementation ----------------------------*/ -#ifdef __alpha__ -/* to cope with broken egcs-1.1.2 :-(((( */ - -/* - * inline functions to do unaligned accesses - * from linux/include/asm-alpha/unaligned.h - */ - -/* - * EGCS 1.1 knows about arbitrary unaligned loads. Define some - * packed structures to talk about such things with. - */ - -#if __GNUC__ > 2 || __GNUC_MINOR__ >= 91 -struct __una_u64 { unsigned long x __attribute__((packed)); }; -struct __una_u32 { unsigned int x __attribute__((packed)); }; -struct __una_u16 { unsigned short x __attribute__((packed)); }; -#endif - -static __inline__ unsigned long ldq_u(unsigned long * r11) -{ -#if __GNUC__ > 2 || __GNUC_MINOR__ >= 91 - const struct __una_u64 *ptr = (const struct __una_u64 *) r11; - return ptr->x; -#else - unsigned long r1,r2; - __asm__("ldq_u %0,%3\n\t" - "ldq_u %1,%4\n\t" - "extql %0,%2,%0\n\t" - "extqh %1,%2,%1" - :"=&r" (r1), "=&r" (r2) - :"r" (r11), - "m" (*r11), - "m" (*(const unsigned long *)(7+(char *) r11))); - return r1 | r2; -#endif -} - -static __inline__ unsigned long ldl_u(unsigned int * r11) -{ -#if __GNUC__ > 2 || __GNUC_MINOR__ >= 91 - const struct __una_u32 *ptr = (const struct __una_u32 *) r11; - return ptr->x; -#else - unsigned long r1,r2; - __asm__("ldq_u %0,%3\n\t" - "ldq_u %1,%4\n\t" - "extll %0,%2,%0\n\t" - "extlh %1,%2,%1" - :"=&r" (r1), "=&r" (r2) - :"r" (r11), - "m" (*r11), - "m" (*(const unsigned long *)(3+(char *) r11))); - return r1 | r2; -#endif -} - -static __inline__ unsigned long ldw_u(unsigned short * r11) -{ -#if __GNUC__ > 2 || __GNUC_MINOR__ >= 91 - const struct __una_u16 *ptr = (const struct __una_u16 *) r11; - return ptr->x; -#else - unsigned long r1,r2; - __asm__("ldq_u %0,%3\n\t" - "ldq_u %1,%4\n\t" - "extwl %0,%2,%0\n\t" - "extwh %1,%2,%1" - :"=&r" (r1), "=&r" (r2) - :"r" (r11), - "m" (*r11), - "m" (*(const unsigned long *)(1+(char *) r11))); - return r1 | r2; -#endif -} - -/* - * Elemental unaligned stores - */ - -static __inline__ void stq_u(unsigned long r5, unsigned long * r11) -{ -#if __GNUC__ > 2 || __GNUC_MINOR__ >= 91 - struct __una_u64 *ptr = (struct __una_u64 *) r11; - ptr->x = r5; -#else - unsigned long r1,r2,r3,r4; - - __asm__("ldq_u %3,%1\n\t" - "ldq_u %2,%0\n\t" - "insqh %6,%7,%5\n\t" - "insql %6,%7,%4\n\t" - "mskqh %3,%7,%3\n\t" - "mskql %2,%7,%2\n\t" - "bis %3,%5,%3\n\t" - "bis %2,%4,%2\n\t" - "stq_u %3,%1\n\t" - "stq_u %2,%0" - :"=m" (*r11), - "=m" (*(unsigned long *)(7+(char *) r11)), - "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4) - :"r" (r5), "r" (r11)); -#endif -} - -static __inline__ void stl_u(unsigned long r5, unsigned int * r11) -{ -#if __GNUC__ > 2 || __GNUC_MINOR__ >= 91 - struct __una_u32 *ptr = (struct __una_u32 *) r11; - ptr->x = r5; -#else - unsigned long r1,r2,r3,r4; - - __asm__("ldq_u %3,%1\n\t" - "ldq_u %2,%0\n\t" - "inslh %6,%7,%5\n\t" - "insll %6,%7,%4\n\t" - "msklh %3,%7,%3\n\t" - "mskll %2,%7,%2\n\t" - "bis %3,%5,%3\n\t" - "bis %2,%4,%2\n\t" - "stq_u %3,%1\n\t" - "stq_u %2,%0" - :"=m" (*r11), - "=m" (*(unsigned long *)(3+(char *) r11)), - "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4) - :"r" (r5), "r" (r11)); -#endif -} - -static __inline__ void stw_u(unsigned long r5, unsigned short * r11) -{ -#if __GNUC__ > 2 || __GNUC_MINOR__ >= 91 - struct __una_u16 *ptr = (struct __una_u16 *) r11; - ptr->x = r5; -#else - unsigned long r1,r2,r3,r4; - - __asm__("ldq_u %3,%1\n\t" - "ldq_u %2,%0\n\t" - "inswh %6,%7,%5\n\t" - "inswl %6,%7,%4\n\t" - "mskwh %3,%7,%3\n\t" - "mskwl %2,%7,%2\n\t" - "bis %3,%5,%3\n\t" - "bis %2,%4,%2\n\t" - "stq_u %3,%1\n\t" - "stq_u %2,%0" - :"=m" (*r11), - "=m" (*(unsigned long *)(1+(char *) r11)), - "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4) - :"r" (r5), "r" (r11)); -#endif -} - -#elif defined (__ia64__) -/* - * EGCS 1.1 knows about arbitrary unaligned loads. Define some - * packed structures to talk about such things with. - */ -struct __una_u64 { unsigned long x __attribute__((packed)); }; -struct __una_u32 { unsigned int x __attribute__((packed)); }; -struct __una_u16 { unsigned short x __attribute__((packed)); }; - -static __inline__ unsigned long -__uldq (const unsigned long * r11) -{ - const struct __una_u64 *ptr = (const struct __una_u64 *) r11; - return ptr->x; -} - -static __inline__ unsigned long -uldl (const unsigned int * r11) -{ - const struct __una_u32 *ptr = (const struct __una_u32 *) r11; - return ptr->x; -} - -static __inline__ unsigned long -uldw (const unsigned short * r11) -{ - const struct __una_u16 *ptr = (const struct __una_u16 *) r11; - return ptr->x; -} - -static __inline__ void -ustq (unsigned long r5, unsigned long * r11) -{ - struct __una_u64 *ptr = (struct __una_u64 *) r11; - ptr->x = r5; -} - -static __inline__ void -ustl (unsigned long r5, unsigned int * r11) -{ - struct __una_u32 *ptr = (struct __una_u32 *) r11; - ptr->x = r5; -} - -static __inline__ void -ustw (unsigned long r5, unsigned short * r11) -{ - struct __una_u16 *ptr = (struct __una_u16 *) r11; - ptr->x = r5; -} - -#endif - -/**************************************************************************** -PARAMETERS: -addr - Emulator memory address to read - -RETURNS: -Byte value read from emulator memory. - -REMARKS: -Reads a byte value from the emulator memory. -****************************************************************************/ -u8 X86API rdb( - u32 addr) -{ - u8 val; - - if (addr > M.mem_size - 1) { - DB(printk("mem_read: address %#lx out of range!\n", addr);) - HALT_SYS(); - } - val = *(u8*)(M.mem_base + addr); -DB( if (DEBUG_MEM_TRACE()) - printk("%#08x 1 -> %#x\n", addr, val);) - return val; -} - -/**************************************************************************** -PARAMETERS: -addr - Emulator memory address to read - -RETURNS: -Word value read from emulator memory. - -REMARKS: -Reads a word value from the emulator memory. -****************************************************************************/ -u16 X86API rdw( - u32 addr) -{ - u16 val = 0; - - if (addr > M.mem_size - 2) { - DB(printk("mem_read: address %#lx out of range!\n", addr);) - HALT_SYS(); - } -#ifdef __BIG_ENDIAN__ - if (addr & 0x1) { - val = (*(u8*)(M.mem_base + addr) | - (*(u8*)(M.mem_base + addr + 1) << 8)); - } - else -#endif -#ifdef __alpha__ - val = ldw_u((u16*)(M.mem_base + addr)); -#elif defined (__ia64__) - val = uldw((u16*)(M.mem_base + addr)); -#else - val = *(u16*)(M.mem_base + addr); -#endif - DB( if (DEBUG_MEM_TRACE()) - printk("%#08x 2 -> %#x\n", addr, val);) - return val; -} - -/**************************************************************************** -PARAMETERS: -addr - Emulator memory address to read - -RETURNS: -Long value read from emulator memory. -REMARKS: -Reads a long value from the emulator memory. -****************************************************************************/ -u32 X86API rdl( - u32 addr) -{ - u32 val = 0; - - if (addr > M.mem_size - 4) { - DB(printk("mem_read: address %#lx out of range!\n", addr);) - HALT_SYS(); - } -#ifdef __BIG_ENDIAN__ - if (addr & 0x3) { - val = (*(u8*)(M.mem_base + addr + 0) | - (*(u8*)(M.mem_base + addr + 1) << 8) | - (*(u8*)(M.mem_base + addr + 2) << 16) | - (*(u8*)(M.mem_base + addr + 3) << 24)); - } - else -#endif -#ifdef __alpha__ - val = ldl_u((u32*)(M.mem_base + addr)); -#elif defined (__ia64__) - val = uldl((u32*)(M.mem_base + addr)); -#else - val = *(u32*)(M.mem_base + addr); -#endif -DB( if (DEBUG_MEM_TRACE()) - printk("%#08x 4 -> %#x\n", addr, val);) - return val; -} - -/**************************************************************************** -PARAMETERS: -addr - Emulator memory address to read -val - Value to store - -REMARKS: -Writes a byte value to emulator memory. -****************************************************************************/ -void X86API wrb( - u32 addr, - u8 val) -{ -DB( if (DEBUG_MEM_TRACE()) - printk("%#08x 1 <- %#x\n", addr, val);) - if (addr > M.mem_size - 1) { - DB(printk("mem_write: address %#lx out of range!\n", addr);) - HALT_SYS(); - } - *(u8*)(M.mem_base + addr) = val; -} - -/**************************************************************************** -PARAMETERS: -addr - Emulator memory address to read -val - Value to store - -REMARKS: -Writes a word value to emulator memory. -****************************************************************************/ -void X86API wrw( - u32 addr, - u16 val) -{ -DB( if (DEBUG_MEM_TRACE()) - printk("%#08x 2 <- %#x\n", addr, val);) - if (addr > M.mem_size - 2) { - DB(printk("mem_write: address %#lx out of range!\n", addr);) - HALT_SYS(); - } -#ifdef __BIG_ENDIAN__ - if (addr & 0x1) { - *(u8*)(M.mem_base + addr + 0) = (val >> 0) & 0xff; - *(u8*)(M.mem_base + addr + 1) = (val >> 8) & 0xff; - } - else -#endif -#ifdef __alpha__ - stw_u(val,(u16*)(M.mem_base + addr)); -#elif defined (__ia64__) - ustw(val,(u16*)(M.mem_base + addr)); -#else - *(u16*)(M.mem_base + addr) = val; -#endif -} - -/**************************************************************************** -PARAMETERS: -addr - Emulator memory address to read -val - Value to store - -REMARKS: -Writes a long value to emulator memory. -****************************************************************************/ -void X86API wrl( - u32 addr, - u32 val) -{ -DB( if (DEBUG_MEM_TRACE()) - printk("%#08x 4 <- %#x\n", addr, val);) - if (addr > M.mem_size - 4) { - DB(printk("mem_write: address %#lx out of range!\n", addr);) - HALT_SYS(); - } -#ifdef __BIG_ENDIAN__ - if (addr & 0x1) { - *(u8*)(M.mem_base + addr + 0) = (val >> 0) & 0xff; - *(u8*)(M.mem_base + addr + 1) = (val >> 8) & 0xff; - *(u8*)(M.mem_base + addr + 2) = (val >> 16) & 0xff; - *(u8*)(M.mem_base + addr + 3) = (val >> 24) & 0xff; - } - else -#endif -#ifdef __alpha__ - stl_u(val,(u32*)(M.mem_base + addr)); -#elif defined (__ia64__) - ustl(val,(u32*)(M.mem_base + addr)); -#else - *(u32*)(M.mem_base + addr) = val; -#endif -} - -/**************************************************************************** -PARAMETERS: -addr - PIO address to read -RETURN: -0 -REMARKS: -Default PIO byte read function. Doesn't perform real inb. -****************************************************************************/ -static u8 X86API p_inb( - X86EMU_pioAddr addr) -{ -DB( if (DEBUG_IO_TRACE()) - printk("inb %#04x \n", addr);) - return 0; -} - -/**************************************************************************** -PARAMETERS: -addr - PIO address to read -RETURN: -0 -REMARKS: -Default PIO word read function. Doesn't perform real inw. -****************************************************************************/ -static u16 X86API p_inw( - X86EMU_pioAddr addr) -{ -DB( if (DEBUG_IO_TRACE()) - printk("inw %#04x \n", addr);) - return 0; -} - -/**************************************************************************** -PARAMETERS: -addr - PIO address to read -RETURN: -0 -REMARKS: -Default PIO long read function. Doesn't perform real inl. -****************************************************************************/ -static u32 X86API p_inl( - X86EMU_pioAddr addr) -{ -DB( if (DEBUG_IO_TRACE()) - printk("inl %#04x \n", addr);) - return 0; -} - -/**************************************************************************** -PARAMETERS: -addr - PIO address to write -val - Value to store -REMARKS: -Default PIO byte write function. Doesn't perform real outb. -****************************************************************************/ -static void X86API p_outb( - X86EMU_pioAddr addr, - u8 val) -{ -DB( if (DEBUG_IO_TRACE()) - printk("outb %#02x -> %#04x \n", val, addr);) - return; -} - -/**************************************************************************** -PARAMETERS: -addr - PIO address to write -val - Value to store -REMARKS: -Default PIO word write function. Doesn't perform real outw. -****************************************************************************/ -static void X86API p_outw( - X86EMU_pioAddr addr, - u16 val) -{ -DB( if (DEBUG_IO_TRACE()) - printk("outw %#04x -> %#04x \n", val, addr);) - return; -} - -/**************************************************************************** -PARAMETERS: -addr - PIO address to write -val - Value to store -REMARKS: -Default PIO ;ong write function. Doesn't perform real outl. -****************************************************************************/ -static void X86API p_outl( - X86EMU_pioAddr addr, - u32 val) -{ -DB( if (DEBUG_IO_TRACE()) - printk("outl %#08x -> %#04x \n", val, addr);) - return; -} - -/*------------------------- Global Variables ------------------------------*/ - -u8 (X86APIP sys_rdb)(u32 addr) = rdb; -u16 (X86APIP sys_rdw)(u32 addr) = rdw; -u32 (X86APIP sys_rdl)(u32 addr) = rdl; -void (X86APIP sys_wrb)(u32 addr,u8 val) = wrb; -void (X86APIP sys_wrw)(u32 addr,u16 val) = wrw; -void (X86APIP sys_wrl)(u32 addr,u32 val) = wrl; -u8 (X86APIP sys_inb)(X86EMU_pioAddr addr) = p_inb; -u16 (X86APIP sys_inw)(X86EMU_pioAddr addr) = p_inw; -u32 (X86APIP sys_inl)(X86EMU_pioAddr addr) = p_inl; -void (X86APIP sys_outb)(X86EMU_pioAddr addr, u8 val) = p_outb; -void (X86APIP sys_outw)(X86EMU_pioAddr addr, u16 val) = p_outw; -void (X86APIP sys_outl)(X86EMU_pioAddr addr, u32 val) = p_outl; - -/*----------------------------- Setup -------------------------------------*/ - -/**************************************************************************** -PARAMETERS: -funcs - New memory function pointers to make active - -REMARKS: -This function is used to set the pointers to functions which access -memory space, allowing the user application to override these functions -and hook them out as necessary for their application. -****************************************************************************/ -void X86EMU_setupMemFuncs( - X86EMU_memFuncs *funcs) -{ - sys_rdb = funcs->rdb; - sys_rdw = funcs->rdw; - sys_rdl = funcs->rdl; - sys_wrb = funcs->wrb; - sys_wrw = funcs->wrw; - sys_wrl = funcs->wrl; -} - -/**************************************************************************** -PARAMETERS: -funcs - New programmed I/O function pointers to make active - -REMARKS: -This function is used to set the pointers to functions which access -I/O space, allowing the user application to override these functions -and hook them out as necessary for their application. -****************************************************************************/ -void X86EMU_setupPioFuncs( - X86EMU_pioFuncs *funcs) -{ - sys_inb = funcs->inb; - sys_inw = funcs->inw; - sys_inl = funcs->inl; - sys_outb = funcs->outb; - sys_outw = funcs->outw; - sys_outl = funcs->outl; -} - -/**************************************************************************** -PARAMETERS: -funcs - New interrupt vector table to make active - -REMARKS: -This function is used to set the pointers to functions which handle -interrupt processing in the emulator, allowing the user application to -hook interrupts as necessary for their application. Any interrupts that -are not hooked by the user application, and reflected and handled internally -in the emulator via the interrupt vector table. This allows the application -to get control when the code being emulated executes specific software -interrupts. -****************************************************************************/ -void X86EMU_setupIntrFuncs( - X86EMU_intrFuncs funcs[]) -{ - int i; - - for (i=0; i < 256; i++) - _X86EMU_intrTab[i] = NULL; - if (funcs) { - for (i = 0; i < 256; i++) - _X86EMU_intrTab[i] = funcs[i]; - } -} - -/**************************************************************************** -PARAMETERS: -int - New software interrupt to prepare for - -REMARKS: -This function is used to set up the emulator state to exceute a software -interrupt. This can be used by the user application code to allow an -interrupt to be hooked, examined and then reflected back to the emulator -so that the code in the emulator will continue processing the software -interrupt as per normal. This essentially allows system code to actively -hook and handle certain software interrupts as necessary. -****************************************************************************/ -void X86EMU_prepareForInt( - int num) -{ - push_word((u16)M.x86.R_FLG); - CLEAR_FLAG(F_IF); - CLEAR_FLAG(F_TF); - push_word(M.x86.R_CS); - M.x86.R_CS = mem_access_word(num * 4 + 2); - push_word(M.x86.R_IP); - M.x86.R_IP = mem_access_word(num * 4); - M.x86.intr = 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/validate.c b/board/MAI/bios_emulator/scitech/src/x86emu/validate.c deleted file mode 100644 index c951301f96..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/validate.c +++ /dev/null @@ -1,765 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: Watcom C 10.6 or later -* Environment: 32-bit DOS -* Developer: Kendall Bennett -* -* Description: Program to validate the x86 emulator library for -* correctness. We run the emulator primitive operations -* functions against the real x86 CPU, and compare the result -* and flags to ensure correctness. -* -* We use inline assembler to compile and build this program. -* -****************************************************************************/ - -#include -#include -#include -#include -#include "x86emu.h" -#include "x86emu/prim_asm.h" - -/*-------------------------- Implementation -------------------------------*/ - -#define true 1 -#define false 0 - -#define ALL_FLAGS (F_CF | F_PF | F_AF | F_ZF | F_SF | F_OF) - -#define VAL_START_BINARY(parm_type,res_type,dmax,smax,dincr,sincr) \ -{ \ - parm_type d,s; \ - res_type r,r_asm; \ - ulong flags,inflags; \ - int f,failed = false; \ - char buf1[80],buf2[80]; \ - for (d = 0; d < dmax; d += dincr) { \ - for (s = 0; s < smax; s += sincr) { \ - M.x86.R_EFLG = inflags = flags = def_flags; \ - for (f = 0; f < 2; f++) { - -#define VAL_TEST_BINARY(name) \ - r_asm = name##_asm(&flags,d,s); \ - r = name(d,s); \ - if (r != r_asm || M.x86.R_EFLG != flags) \ - failed = true; \ - if (failed || trace) { - -#define VAL_TEST_BINARY_VOID(name) \ - name##_asm(&flags,d,s); \ - name(d,s); \ - r = r_asm = 0; \ - if (M.x86.R_EFLG != flags) \ - failed = true; \ - if (failed || trace) { - -#define VAL_FAIL_BYTE_BYTE_BINARY(name) \ - if (failed) \ - printk("fail\n"); \ - printk("0x%02X = %-15s(0x%02X,0x%02X), flags = %s -> %s\n", \ - r, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ - printk("0x%02X = %-15s(0x%02X,0x%02X), flags = %s -> %s\n", \ - r_asm, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); - -#define VAL_FAIL_WORD_WORD_BINARY(name) \ - if (failed) \ - printk("fail\n"); \ - printk("0x%04X = %-15s(0x%04X,0x%04X), flags = %s -> %s\n", \ - r, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ - printk("0x%04X = %-15s(0x%04X,0x%04X), flags = %s -> %s\n", \ - r_asm, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); - -#define VAL_FAIL_LONG_LONG_BINARY(name) \ - if (failed) \ - printk("fail\n"); \ - printk("0x%08X = %-15s(0x%08X,0x%08X), flags = %s -> %s\n", \ - r, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ - printk("0x%08X = %-15s(0x%08X,0x%08X), flags = %s -> %s\n", \ - r_asm, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); - -#define VAL_END_BINARY() \ - } \ - M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (!failed) \ - printk("passed\n"); \ -} - -#define VAL_BYTE_BYTE_BINARY(name) \ - printk("Validating %s ... ", #name); \ - VAL_START_BINARY(u8,u8,0xFF,0xFF,1,1) \ - VAL_TEST_BINARY(name) \ - VAL_FAIL_BYTE_BYTE_BINARY(name) \ - VAL_END_BINARY() - -#define VAL_WORD_WORD_BINARY(name) \ - printk("Validating %s ... ", #name); \ - VAL_START_BINARY(u16,u16,0xFF00,0xFF00,0x100,0x100) \ - VAL_TEST_BINARY(name) \ - VAL_FAIL_WORD_WORD_BINARY(name) \ - VAL_END_BINARY() - -#define VAL_LONG_LONG_BINARY(name) \ - printk("Validating %s ... ", #name); \ - VAL_START_BINARY(u32,u32,0xFF000000,0xFF000000,0x1000000,0x1000000) \ - VAL_TEST_BINARY(name) \ - VAL_FAIL_LONG_LONG_BINARY(name) \ - VAL_END_BINARY() - -#define VAL_VOID_BYTE_BINARY(name) \ - printk("Validating %s ... ", #name); \ - VAL_START_BINARY(u8,u8,0xFF,0xFF,1,1) \ - VAL_TEST_BINARY_VOID(name) \ - VAL_FAIL_BYTE_BYTE_BINARY(name) \ - VAL_END_BINARY() - -#define VAL_VOID_WORD_BINARY(name) \ - printk("Validating %s ... ", #name); \ - VAL_START_BINARY(u16,u16,0xFF00,0xFF00,0x100,0x100) \ - VAL_TEST_BINARY_VOID(name) \ - VAL_FAIL_WORD_WORD_BINARY(name) \ - VAL_END_BINARY() - -#define VAL_VOID_LONG_BINARY(name) \ - printk("Validating %s ... ", #name); \ - VAL_START_BINARY(u32,u32,0xFF000000,0xFF000000,0x1000000,0x1000000) \ - VAL_TEST_BINARY_VOID(name) \ - VAL_FAIL_LONG_LONG_BINARY(name) \ - VAL_END_BINARY() - -#define VAL_BYTE_ROTATE(name) \ - printk("Validating %s ... ", #name); \ - VAL_START_BINARY(u8,u8,0xFF,8,1,1) \ - VAL_TEST_BINARY(name) \ - VAL_FAIL_BYTE_BYTE_BINARY(name) \ - VAL_END_BINARY() - -#define VAL_WORD_ROTATE(name) \ - printk("Validating %s ... ", #name); \ - VAL_START_BINARY(u16,u16,0xFF00,16,0x100,1) \ - VAL_TEST_BINARY(name) \ - VAL_FAIL_WORD_WORD_BINARY(name) \ - VAL_END_BINARY() - -#define VAL_LONG_ROTATE(name) \ - printk("Validating %s ... ", #name); \ - VAL_START_BINARY(u32,u32,0xFF000000,32,0x1000000,1) \ - VAL_TEST_BINARY(name) \ - VAL_FAIL_LONG_LONG_BINARY(name) \ - VAL_END_BINARY() - -#define VAL_START_TERNARY(parm_type,res_type,dmax,smax,dincr,sincr,maxshift)\ -{ \ - parm_type d,s; \ - res_type r,r_asm; \ - u8 shift; \ - u32 flags,inflags; \ - int f,failed = false; \ - char buf1[80],buf2[80]; \ - for (d = 0; d < dmax; d += dincr) { \ - for (s = 0; s < smax; s += sincr) { \ - for (shift = 0; shift < maxshift; shift += 1) { \ - M.x86.R_EFLG = inflags = flags = def_flags; \ - for (f = 0; f < 2; f++) { - -#define VAL_TEST_TERNARY(name) \ - r_asm = name##_asm(&flags,d,s,shift); \ - r = name(d,s,shift); \ - if (r != r_asm || M.x86.R_EFLG != flags) \ - failed = true; \ - if (failed || trace) { - -#define VAL_FAIL_WORD_WORD_TERNARY(name) \ - if (failed) \ - printk("fail\n"); \ - printk("0x%04X = %-15s(0x%04X,0x%04X,%d), flags = %s -> %s\n", \ - r, #name, d, s, shift, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ - printk("0x%04X = %-15s(0x%04X,0x%04X,%d), flags = %s -> %s\n", \ - r_asm, #name"_asm", d, s, shift, print_flags(buf1,inflags), print_flags(buf2,flags)); - -#define VAL_FAIL_LONG_LONG_TERNARY(name) \ - if (failed) \ - printk("fail\n"); \ - printk("0x%08X = %-15s(0x%08X,0x%08X,%d), flags = %s -> %s\n", \ - r, #name, d, s, shift, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ - printk("0x%08X = %-15s(0x%08X,0x%08X,%d), flags = %s -> %s\n", \ - r_asm, #name"_asm", d, s, shift, print_flags(buf1,inflags), print_flags(buf2,flags)); - -#define VAL_END_TERNARY() \ - } \ - M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (!failed) \ - printk("passed\n"); \ -} - -#define VAL_WORD_ROTATE_DBL(name) \ - printk("Validating %s ... ", #name); \ - VAL_START_TERNARY(u16,u16,0xFF00,0xFF00,0x100,0x100,16) \ - VAL_TEST_TERNARY(name) \ - VAL_FAIL_WORD_WORD_TERNARY(name) \ - VAL_END_TERNARY() - -#define VAL_LONG_ROTATE_DBL(name) \ - printk("Validating %s ... ", #name); \ - VAL_START_TERNARY(u32,u32,0xFF000000,0xFF000000,0x1000000,0x1000000,32) \ - VAL_TEST_TERNARY(name) \ - VAL_FAIL_LONG_LONG_TERNARY(name) \ - VAL_END_TERNARY() - -#define VAL_START_UNARY(parm_type,max,incr) \ -{ \ - parm_type d,r,r_asm; \ - u32 flags,inflags; \ - int f,failed = false; \ - char buf1[80],buf2[80]; \ - for (d = 0; d < max; d += incr) { \ - M.x86.R_EFLG = inflags = flags = def_flags; \ - for (f = 0; f < 2; f++) { - -#define VAL_TEST_UNARY(name) \ - r_asm = name##_asm(&flags,d); \ - r = name(d); \ - if (r != r_asm || M.x86.R_EFLG != flags) { \ - failed = true; - -#define VAL_FAIL_BYTE_UNARY(name) \ - printk("fail\n"); \ - printk("0x%02X = %-15s(0x%02X), flags = %s -> %s\n", \ - r, #name, d, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ - printk("0x%02X = %-15s(0x%02X), flags = %s -> %s\n", \ - r_asm, #name"_asm", d, print_flags(buf1,inflags), print_flags(buf2,flags)); - -#define VAL_FAIL_WORD_UNARY(name) \ - printk("fail\n"); \ - printk("0x%04X = %-15s(0x%04X), flags = %s -> %s\n", \ - r, #name, d, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ - printk("0x%04X = %-15s(0x%04X), flags = %s -> %s\n", \ - r_asm, #name"_asm", d, print_flags(buf1,inflags), print_flags(buf2,flags)); - -#define VAL_FAIL_LONG_UNARY(name) \ - printk("fail\n"); \ - printk("0x%08X = %-15s(0x%08X), flags = %s -> %s\n", \ - r, #name, d, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ - printk("0x%08X = %-15s(0x%08X), flags = %s -> %s\n", \ - r_asm, #name"_asm", d, print_flags(buf1,inflags), print_flags(buf2,flags)); - -#define VAL_END_UNARY() \ - } \ - M.x86.R_EFLG = inflags = flags = def_flags | ALL_FLAGS; \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (!failed) \ - printk("passed\n"); \ -} - -#define VAL_BYTE_UNARY(name) \ - printk("Validating %s ... ", #name); \ - VAL_START_UNARY(u8,0xFF,0x1) \ - VAL_TEST_UNARY(name) \ - VAL_FAIL_BYTE_UNARY(name) \ - VAL_END_UNARY() - -#define VAL_WORD_UNARY(name) \ - printk("Validating %s ... ", #name); \ - VAL_START_UNARY(u16,0xFF00,0x100) \ - VAL_TEST_UNARY(name) \ - VAL_FAIL_WORD_UNARY(name) \ - VAL_END_UNARY() - -#define VAL_WORD_BYTE_UNARY(name) \ - printk("Validating %s ... ", #name); \ - VAL_START_UNARY(u16,0xFF,0x1) \ - VAL_TEST_UNARY(name) \ - VAL_FAIL_WORD_UNARY(name) \ - VAL_END_UNARY() - -#define VAL_LONG_UNARY(name) \ - printk("Validating %s ... ", #name); \ - VAL_START_UNARY(u32,0xFF000000,0x1000000) \ - VAL_TEST_UNARY(name) \ - VAL_FAIL_LONG_UNARY(name) \ - VAL_END_UNARY() - -#define VAL_BYTE_MUL(name) \ - printk("Validating %s ... ", #name); \ -{ \ - u8 d,s; \ - u16 r,r_asm; \ - u32 flags,inflags; \ - int f,failed = false; \ - char buf1[80],buf2[80]; \ - for (d = 0; d < 0xFF; d += 1) { \ - for (s = 0; s < 0xFF; s += 1) { \ - M.x86.R_EFLG = inflags = flags = def_flags; \ - for (f = 0; f < 2; f++) { \ - name##_asm(&flags,&r_asm,d,s); \ - M.x86.R_AL = d; \ - name(s); \ - r = M.x86.R_AX; \ - if (r != r_asm || M.x86.R_EFLG != flags) \ - failed = true; \ - if (failed || trace) { \ - if (failed) \ - printk("fail\n"); \ - printk("0x%04X = %-15s(0x%02X,0x%02X), flags = %s -> %s\n", \ - r, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ - printk("0x%04X = %-15s(0x%02X,0x%02X), flags = %s -> %s\n", \ - r_asm, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); \ - } \ - M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (!failed) \ - printk("passed\n"); \ -} - -#define VAL_WORD_MUL(name) \ - printk("Validating %s ... ", #name); \ -{ \ - u16 d,s; \ - u16 r_lo,r_asm_lo; \ - u16 r_hi,r_asm_hi; \ - u32 flags,inflags; \ - int f,failed = false; \ - char buf1[80],buf2[80]; \ - for (d = 0; d < 0xFF00; d += 0x100) { \ - for (s = 0; s < 0xFF00; s += 0x100) { \ - M.x86.R_EFLG = inflags = flags = def_flags; \ - for (f = 0; f < 2; f++) { \ - name##_asm(&flags,&r_asm_lo,&r_asm_hi,d,s); \ - M.x86.R_AX = d; \ - name(s); \ - r_lo = M.x86.R_AX; \ - r_hi = M.x86.R_DX; \ - if (r_lo != r_asm_lo || r_hi != r_asm_hi || M.x86.R_EFLG != flags)\ - failed = true; \ - if (failed || trace) { \ - if (failed) \ - printk("fail\n"); \ - printk("0x%04X:0x%04X = %-15s(0x%04X,0x%04X), flags = %s -> %s\n", \ - r_hi,r_lo, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ - printk("0x%04X:0x%04X = %-15s(0x%04X,0x%04X), flags = %s -> %s\n", \ - r_asm_hi,r_asm_lo, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); \ - } \ - M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (!failed) \ - printk("passed\n"); \ -} - -#define VAL_LONG_MUL(name) \ - printk("Validating %s ... ", #name); \ -{ \ - u32 d,s; \ - u32 r_lo,r_asm_lo; \ - u32 r_hi,r_asm_hi; \ - u32 flags,inflags; \ - int f,failed = false; \ - char buf1[80],buf2[80]; \ - for (d = 0; d < 0xFF000000; d += 0x1000000) { \ - for (s = 0; s < 0xFF000000; s += 0x1000000) { \ - M.x86.R_EFLG = inflags = flags = def_flags; \ - for (f = 0; f < 2; f++) { \ - name##_asm(&flags,&r_asm_lo,&r_asm_hi,d,s); \ - M.x86.R_EAX = d; \ - name(s); \ - r_lo = M.x86.R_EAX; \ - r_hi = M.x86.R_EDX; \ - if (r_lo != r_asm_lo || r_hi != r_asm_hi || M.x86.R_EFLG != flags)\ - failed = true; \ - if (failed || trace) { \ - if (failed) \ - printk("fail\n"); \ - printk("0x%08X:0x%08X = %-15s(0x%08X,0x%08X), flags = %s -> %s\n", \ - r_hi,r_lo, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ - printk("0x%08X:0x%08X = %-15s(0x%08X,0x%08X), flags = %s -> %s\n", \ - r_asm_hi,r_asm_lo, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); \ - } \ - M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (!failed) \ - printk("passed\n"); \ -} - -#define VAL_BYTE_DIV(name) \ - printk("Validating %s ... ", #name); \ -{ \ - u16 d,s; \ - u8 r_quot,r_rem,r_asm_quot,r_asm_rem; \ - u32 flags,inflags; \ - int f,failed = false; \ - char buf1[80],buf2[80]; \ - for (d = 0; d < 0xFF00; d += 0x100) { \ - for (s = 1; s < 0xFF; s += 1) { \ - M.x86.R_EFLG = inflags = flags = def_flags; \ - for (f = 0; f < 2; f++) { \ - M.x86.intr = 0; \ - M.x86.R_AX = d; \ - name(s); \ - r_quot = M.x86.R_AL; \ - r_rem = M.x86.R_AH; \ - if (M.x86.intr & INTR_SYNCH) \ - continue; \ - name##_asm(&flags,&r_asm_quot,&r_asm_rem,d,s); \ - if (r_quot != r_asm_quot || r_rem != r_asm_rem || M.x86.R_EFLG != flags) \ - failed = true; \ - if (failed || trace) { \ - if (failed) \ - printk("fail\n"); \ - printk("0x%02X:0x%02X = %-15s(0x%04X,0x%02X), flags = %s -> %s\n", \ - r_quot, r_rem, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ - printk("0x%02X:0x%02X = %-15s(0x%04X,0x%02X), flags = %s -> %s\n", \ - r_asm_quot, r_asm_rem, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); \ - } \ - M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (!failed) \ - printk("passed\n"); \ -} - -#define VAL_WORD_DIV(name) \ - printk("Validating %s ... ", #name); \ -{ \ - u32 d,s; \ - u16 r_quot,r_rem,r_asm_quot,r_asm_rem; \ - u32 flags,inflags; \ - int f,failed = false; \ - char buf1[80],buf2[80]; \ - for (d = 0; d < 0xFF000000; d += 0x1000000) { \ - for (s = 0x100; s < 0xFF00; s += 0x100) { \ - M.x86.R_EFLG = inflags = flags = def_flags; \ - for (f = 0; f < 2; f++) { \ - M.x86.intr = 0; \ - M.x86.R_AX = d & 0xFFFF; \ - M.x86.R_DX = d >> 16; \ - name(s); \ - r_quot = M.x86.R_AX; \ - r_rem = M.x86.R_DX; \ - if (M.x86.intr & INTR_SYNCH) \ - continue; \ - name##_asm(&flags,&r_asm_quot,&r_asm_rem,d & 0xFFFF,d >> 16,s);\ - if (r_quot != r_asm_quot || r_rem != r_asm_rem || M.x86.R_EFLG != flags) \ - failed = true; \ - if (failed || trace) { \ - if (failed) \ - printk("fail\n"); \ - printk("0x%04X:0x%04X = %-15s(0x%08X,0x%04X), flags = %s -> %s\n", \ - r_quot, r_rem, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ - printk("0x%04X:0x%04X = %-15s(0x%08X,0x%04X), flags = %s -> %s\n", \ - r_asm_quot, r_asm_rem, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); \ - } \ - M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (!failed) \ - printk("passed\n"); \ -} - -#define VAL_LONG_DIV(name) \ - printk("Validating %s ... ", #name); \ -{ \ - u32 d,s; \ - u32 r_quot,r_rem,r_asm_quot,r_asm_rem; \ - u32 flags,inflags; \ - int f,failed = false; \ - char buf1[80],buf2[80]; \ - for (d = 0; d < 0xFF000000; d += 0x1000000) { \ - for (s = 0x100; s < 0xFF00; s += 0x100) { \ - M.x86.R_EFLG = inflags = flags = def_flags; \ - for (f = 0; f < 2; f++) { \ - M.x86.intr = 0; \ - M.x86.R_EAX = d; \ - M.x86.R_EDX = 0; \ - name(s); \ - r_quot = M.x86.R_EAX; \ - r_rem = M.x86.R_EDX; \ - if (M.x86.intr & INTR_SYNCH) \ - continue; \ - name##_asm(&flags,&r_asm_quot,&r_asm_rem,d,0,s); \ - if (r_quot != r_asm_quot || r_rem != r_asm_rem || M.x86.R_EFLG != flags) \ - failed = true; \ - if (failed || trace) { \ - if (failed) \ - printk("fail\n"); \ - printk("0x%08X:0x%08X = %-15s(0x%08X:0x%08X,0x%08X), flags = %s -> %s\n", \ - r_quot, r_rem, #name, 0, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ - printk("0x%08X:0x%08X = %-15s(0x%08X:0x%08X,0x%08X), flags = %s -> %s\n", \ - r_asm_quot, r_asm_rem, #name"_asm", 0, d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); \ - } \ - M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (failed) \ - break; \ - } \ - if (!failed) \ - printk("passed\n"); \ -} - -void printk(const char *fmt, ...) -{ - va_list argptr; - va_start(argptr, fmt); - vfprintf(stdout, fmt, argptr); - fflush(stdout); - va_end(argptr); -} - -char * print_flags(char *buf,ulong flags) -{ - char *separator = ""; - - buf[0] = 0; - if (flags & F_CF) { - strcat(buf,separator); - strcat(buf,"CF"); - separator = ","; - } - if (flags & F_PF) { - strcat(buf,separator); - strcat(buf,"PF"); - separator = ","; - } - if (flags & F_AF) { - strcat(buf,separator); - strcat(buf,"AF"); - separator = ","; - } - if (flags & F_ZF) { - strcat(buf,separator); - strcat(buf,"ZF"); - separator = ","; - } - if (flags & F_SF) { - strcat(buf,separator); - strcat(buf,"SF"); - separator = ","; - } - if (flags & F_OF) { - strcat(buf,separator); - strcat(buf,"OF"); - separator = ","; - } - if (separator[0] == 0) - strcpy(buf,"None"); - return buf; -} - -int main(int argc) -{ - ulong def_flags; - int trace = false; - - if (argc > 1) - trace = true; - memset(&M, 0, sizeof(M)); - def_flags = get_flags_asm() & ~ALL_FLAGS; - - VAL_WORD_UNARY(aaa_word); - VAL_WORD_UNARY(aas_word); - - VAL_WORD_UNARY(aad_word); - VAL_WORD_UNARY(aam_word); - - VAL_BYTE_BYTE_BINARY(adc_byte); - VAL_WORD_WORD_BINARY(adc_word); - VAL_LONG_LONG_BINARY(adc_long); - - VAL_BYTE_BYTE_BINARY(add_byte); - VAL_WORD_WORD_BINARY(add_word); - VAL_LONG_LONG_BINARY(add_long); - - VAL_BYTE_BYTE_BINARY(and_byte); - VAL_WORD_WORD_BINARY(and_word); - VAL_LONG_LONG_BINARY(and_long); - - VAL_BYTE_BYTE_BINARY(cmp_byte); - VAL_WORD_WORD_BINARY(cmp_word); - VAL_LONG_LONG_BINARY(cmp_long); - - VAL_BYTE_UNARY(daa_byte); - VAL_BYTE_UNARY(das_byte); /* Fails for 0x9A (out of range anyway) */ - - VAL_BYTE_UNARY(dec_byte); - VAL_WORD_UNARY(dec_word); - VAL_LONG_UNARY(dec_long); - - VAL_BYTE_UNARY(inc_byte); - VAL_WORD_UNARY(inc_word); - VAL_LONG_UNARY(inc_long); - - VAL_BYTE_BYTE_BINARY(or_byte); - VAL_WORD_WORD_BINARY(or_word); - VAL_LONG_LONG_BINARY(or_long); - - VAL_BYTE_UNARY(neg_byte); - VAL_WORD_UNARY(neg_word); - VAL_LONG_UNARY(neg_long); - - VAL_BYTE_UNARY(not_byte); - VAL_WORD_UNARY(not_word); - VAL_LONG_UNARY(not_long); - - VAL_BYTE_ROTATE(rcl_byte); - VAL_WORD_ROTATE(rcl_word); - VAL_LONG_ROTATE(rcl_long); - - VAL_BYTE_ROTATE(rcr_byte); - VAL_WORD_ROTATE(rcr_word); - VAL_LONG_ROTATE(rcr_long); - - VAL_BYTE_ROTATE(rol_byte); - VAL_WORD_ROTATE(rol_word); - VAL_LONG_ROTATE(rol_long); - - VAL_BYTE_ROTATE(ror_byte); - VAL_WORD_ROTATE(ror_word); - VAL_LONG_ROTATE(ror_long); - - VAL_BYTE_ROTATE(shl_byte); - VAL_WORD_ROTATE(shl_word); - VAL_LONG_ROTATE(shl_long); - - VAL_BYTE_ROTATE(shr_byte); - VAL_WORD_ROTATE(shr_word); - VAL_LONG_ROTATE(shr_long); - - VAL_BYTE_ROTATE(sar_byte); - VAL_WORD_ROTATE(sar_word); - VAL_LONG_ROTATE(sar_long); - - VAL_WORD_ROTATE_DBL(shld_word); - VAL_LONG_ROTATE_DBL(shld_long); - - VAL_WORD_ROTATE_DBL(shrd_word); - VAL_LONG_ROTATE_DBL(shrd_long); - - VAL_BYTE_BYTE_BINARY(sbb_byte); - VAL_WORD_WORD_BINARY(sbb_word); - VAL_LONG_LONG_BINARY(sbb_long); - - VAL_BYTE_BYTE_BINARY(sub_byte); - VAL_WORD_WORD_BINARY(sub_word); - VAL_LONG_LONG_BINARY(sub_long); - - VAL_BYTE_BYTE_BINARY(xor_byte); - VAL_WORD_WORD_BINARY(xor_word); - VAL_LONG_LONG_BINARY(xor_long); - - VAL_VOID_BYTE_BINARY(test_byte); - VAL_VOID_WORD_BINARY(test_word); - VAL_VOID_LONG_BINARY(test_long); - - VAL_BYTE_MUL(imul_byte); - VAL_WORD_MUL(imul_word); - VAL_LONG_MUL(imul_long); - - VAL_BYTE_MUL(mul_byte); - VAL_WORD_MUL(mul_word); - VAL_LONG_MUL(mul_long); - - VAL_BYTE_DIV(idiv_byte); - VAL_WORD_DIV(idiv_word); - VAL_LONG_DIV(idiv_long); - - VAL_BYTE_DIV(div_byte); - VAL_WORD_DIV(div_word); - VAL_LONG_DIV(div_long); - - return 0; -} diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/debug.h b/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/debug.h deleted file mode 100644 index 9a4a096c65..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/debug.h +++ /dev/null @@ -1,210 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Header file for debug definitions. -* -****************************************************************************/ - -#ifndef __X86EMU_DEBUG_H -#define __X86EMU_DEBUG_H - -/*---------------------- Macros and type definitions ----------------------*/ - -/* checks to be enabled for "runtime" */ - -#define CHECK_IP_FETCH_F 0x1 -#define CHECK_SP_ACCESS_F 0x2 -#define CHECK_MEM_ACCESS_F 0x4 /*using regular linear pointer */ -#define CHECK_DATA_ACCESS_F 0x8 /*using segment:offset*/ - -#ifdef DEBUG -# define CHECK_IP_FETCH() (M.x86.check & CHECK_IP_FETCH_F) -# define CHECK_SP_ACCESS() (M.x86.check & CHECK_SP_ACCESS_F) -# define CHECK_MEM_ACCESS() (M.x86.check & CHECK_MEM_ACCESS_F) -# define CHECK_DATA_ACCESS() (M.x86.check & CHECK_DATA_ACCESS_F) -#else -# define CHECK_IP_FETCH() -# define CHECK_SP_ACCESS() -# define CHECK_MEM_ACCESS() -# define CHECK_DATA_ACCESS() -#endif - -#ifdef DEBUG -# define DEBUG_INSTRUMENT() (M.x86.debug & DEBUG_INSTRUMENT_F) -# define DEBUG_DECODE() (M.x86.debug & DEBUG_DECODE_F) -# define DEBUG_TRACE() (M.x86.debug & DEBUG_TRACE_F) -# define DEBUG_STEP() (M.x86.debug & DEBUG_STEP_F) -# define DEBUG_DISASSEMBLE() (M.x86.debug & DEBUG_DISASSEMBLE_F) -# define DEBUG_BREAK() (M.x86.debug & DEBUG_BREAK_F) -# define DEBUG_SVC() (M.x86.debug & DEBUG_SVC_F) -# define DEBUG_SAVE_IP_CS() (M.x86.debug & DEBUG_SAVE_CS_IP) - -# define DEBUG_FS() (M.x86.debug & DEBUG_FS_F) -# define DEBUG_PROC() (M.x86.debug & DEBUG_PROC_F) -# define DEBUG_SYSINT() (M.x86.debug & DEBUG_SYSINT_F) -# define DEBUG_TRACECALL() (M.x86.debug & DEBUG_TRACECALL_F) -# define DEBUG_TRACECALLREGS() (M.x86.debug & DEBUG_TRACECALL_REGS_F) -# define DEBUG_SYS() (M.x86.debug & DEBUG_SYS_F) -# define DEBUG_MEM_TRACE() (M.x86.debug & DEBUG_MEM_TRACE_F) -# define DEBUG_IO_TRACE() (M.x86.debug & DEBUG_IO_TRACE_F) -# define DEBUG_DECODE_NOPRINT() (M.x86.debug & DEBUG_DECODE_NOPRINT_F) -#else -# define DEBUG_INSTRUMENT() 0 -# define DEBUG_DECODE() 0 -# define DEBUG_TRACE() 0 -# define DEBUG_STEP() 0 -# define DEBUG_DISASSEMBLE() 0 -# define DEBUG_BREAK() 0 -# define DEBUG_SVC() 0 -# define DEBUG_SAVE_IP_CS() 0 -# define DEBUG_FS() 0 -# define DEBUG_PROC() 0 -# define DEBUG_SYSINT() 0 -# define DEBUG_TRACECALL() 0 -# define DEBUG_TRACECALLREGS() 0 -# define DEBUG_SYS() 0 -# define DEBUG_MEM_TRACE() 0 -# define DEBUG_IO_TRACE() 0 -# define DEBUG_DECODE_NOPRINT() 0 -#endif - -#ifdef DEBUG - -# define DECODE_PRINTF(x) if (DEBUG_DECODE()) \ - x86emu_decode_printf(x) -# define DECODE_PRINTF2(x,y) if (DEBUG_DECODE()) \ - x86emu_decode_printf2(x,y) - -/* - * The following allow us to look at the bytes of an instruction. The - * first INCR_INSTRN_LEN, is called everytime bytes are consumed in - * the decoding process. The SAVE_IP_CS is called initially when the - * major opcode of the instruction is accessed. - */ -#define INC_DECODED_INST_LEN(x) \ - if (DEBUG_DECODE()) \ - x86emu_inc_decoded_inst_len(x) - -#define SAVE_IP_CS(x,y) \ - if (DEBUG_DECODE() | DEBUG_TRACECALL() | DEBUG_BREAK() \ - | DEBUG_IO_TRACE() | DEBUG_SAVE_IP_CS()) { \ - M.x86.saved_cs = x; \ - M.x86.saved_ip = y; \ - } -#else -# define INC_DECODED_INST_LEN(x) -# define DECODE_PRINTF(x) -# define DECODE_PRINTF2(x,y) -# define SAVE_IP_CS(x,y) -#endif - -#ifdef DEBUG -#define TRACE_REGS() \ - if (DEBUG_DISASSEMBLE()) { \ - x86emu_just_disassemble(); \ - goto EndOfTheInstructionProcedure; \ - } \ - if (DEBUG_TRACE() || DEBUG_DECODE()) X86EMU_trace_regs() -#else -# define TRACE_REGS() -#endif - -#ifdef DEBUG -# define SINGLE_STEP() if (DEBUG_STEP()) x86emu_single_step() -#else -# define SINGLE_STEP() -#endif - -#define TRACE_AND_STEP() \ - TRACE_REGS(); \ - SINGLE_STEP() - -#ifdef DEBUG -# define START_OF_INSTR() -# define END_OF_INSTR() EndOfTheInstructionProcedure: x86emu_end_instr(); -# define END_OF_INSTR_NO_TRACE() x86emu_end_instr(); -#else -# define START_OF_INSTR() -# define END_OF_INSTR() -# define END_OF_INSTR_NO_TRACE() -#endif - -#ifdef DEBUG -# define CALL_TRACE(u,v,w,x,s) \ - if (DEBUG_TRACECALLREGS()) \ - x86emu_dump_regs(); \ - if (DEBUG_TRACECALL()) \ - printk("%04x:%04x: CALL %s%04x:%04x\n", u , v, s, w, x); -# define RETURN_TRACE(n,u,v) \ - if (DEBUG_TRACECALLREGS()) \ - x86emu_dump_regs(); \ - if (DEBUG_TRACECALL()) \ - printk("%04x:%04x: %s\n",u,v,n); -#else -# define CALL_TRACE(u,v,w,x,s) -# define RETURN_TRACE(n,u,v) -#endif - -#ifdef DEBUG -#define DB(x) x -#else -#define DB(x) -#endif - -/*-------------------------- Function Prototypes --------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -extern void x86emu_inc_decoded_inst_len (int x); -extern void x86emu_decode_printf (char *x); -extern void x86emu_decode_printf2 (char *x, int y); -extern void x86emu_just_disassemble (void); -extern void x86emu_single_step (void); -extern void x86emu_end_instr (void); -extern void x86emu_dump_regs (void); -extern void x86emu_dump_xregs (void); -extern void x86emu_print_int_vect (u16 iv); -extern void x86emu_instrument_instruction (void); -extern void x86emu_check_ip_access (void); -extern void x86emu_check_sp_access (void); -extern void x86emu_check_mem_access (u32 p); -extern void x86emu_check_data_access (uint s, uint o); - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif - -#endif /* __X86EMU_DEBUG_H */ diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/decode.h b/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/decode.h deleted file mode 100644 index 321a345399..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/decode.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Header file for instruction decoding logic. -* -****************************************************************************/ - -#ifndef __X86EMU_DECODE_H -#define __X86EMU_DECODE_H - -/*---------------------- Macros and type definitions ----------------------*/ - -/* Instruction Decoding Stuff */ - -#define FETCH_DECODE_MODRM(mod,rh,rl) fetch_decode_modrm(&mod,&rh,&rl) -#define DECODE_RM_BYTE_REGISTER(r) decode_rm_byte_register(r) -#define DECODE_RM_WORD_REGISTER(r) decode_rm_word_register(r) -#define DECODE_RM_LONG_REGISTER(r) decode_rm_long_register(r) -#define DECODE_CLEAR_SEGOVR() M.x86.mode &= ~SYSMODE_CLRMASK - -/*-------------------------- Function Prototypes --------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -void x86emu_intr_raise (u8 type); -void fetch_decode_modrm (int *mod,int *regh,int *regl); -u8 fetch_byte_imm (void); -u16 fetch_word_imm (void); -u32 fetch_long_imm (void); -u8 fetch_data_byte (uint offset); -u8 fetch_data_byte_abs (uint segment, uint offset); -u16 fetch_data_word (uint offset); -u16 fetch_data_word_abs (uint segment, uint offset); -u32 fetch_data_long (uint offset); -u32 fetch_data_long_abs (uint segment, uint offset); -void store_data_byte (uint offset, u8 val); -void store_data_byte_abs (uint segment, uint offset, u8 val); -void store_data_word (uint offset, u16 val); -void store_data_word_abs (uint segment, uint offset, u16 val); -void store_data_long (uint offset, u32 val); -void store_data_long_abs (uint segment, uint offset, u32 val); -u8* decode_rm_byte_register(int reg); -u16* decode_rm_word_register(int reg); -u32* decode_rm_long_register(int reg); -u16* decode_rm_seg_register(int reg); -unsigned decode_rm00_address(int rm); -unsigned decode_rm01_address(int rm); -unsigned decode_rm10_address(int rm); - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif - -#endif /* __X86EMU_DECODE_H */ diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/fpu.h b/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/fpu.h deleted file mode 100644 index 5fb271463b..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/fpu.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Header file for FPU instruction decoding. -* -****************************************************************************/ - -#ifndef __X86EMU_FPU_H -#define __X86EMU_FPU_H - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -/* these have to be defined, whether 8087 support compiled in or not. */ - -extern void x86emuOp_esc_coprocess_d8 (u8 op1); -extern void x86emuOp_esc_coprocess_d9 (u8 op1); -extern void x86emuOp_esc_coprocess_da (u8 op1); -extern void x86emuOp_esc_coprocess_db (u8 op1); -extern void x86emuOp_esc_coprocess_dc (u8 op1); -extern void x86emuOp_esc_coprocess_dd (u8 op1); -extern void x86emuOp_esc_coprocess_de (u8 op1); -extern void x86emuOp_esc_coprocess_df (u8 op1); - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif - -#endif /* __X86EMU_FPU_H */ diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/ops.h b/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/ops.h deleted file mode 100644 index 65ea676543..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/ops.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Header file for operand decoding functions. -* -****************************************************************************/ - -#ifndef __X86EMU_OPS_H -#define __X86EMU_OPS_H - -extern void (*x86emu_optab[0x100])(u8 op1); -extern void (*x86emu_optab2[0x100])(u8 op2); - -#endif /* __X86EMU_OPS_H */ diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/prim_asm.h b/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/prim_asm.h deleted file mode 100644 index e023cf88da..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/prim_asm.h +++ /dev/null @@ -1,970 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: Watcom C++ 10.6 or later -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Inline assembler versions of the primitive operand -* functions for faster performance. At the moment this is -* x86 inline assembler, but these functions could be replaced -* with native inline assembler for each supported processor -* platform. -* -****************************************************************************/ - -#ifndef __X86EMU_PRIM_ASM_H -#define __X86EMU_PRIM_ASM_H - -#ifdef __WATCOMC__ - -#ifndef VALIDATE -#define __HAVE_INLINE_ASSEMBLER__ -#endif - -u32 get_flags_asm(void); -#pragma aux get_flags_asm = \ - "pushf" \ - "pop eax" \ - value [eax] \ - modify exact [eax]; - -u16 aaa_word_asm(u32 *flags,u16 d); -#pragma aux aaa_word_asm = \ - "push [edi]" \ - "popf" \ - "aaa" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] \ - value [ax] \ - modify exact [ax]; - -u16 aas_word_asm(u32 *flags,u16 d); -#pragma aux aas_word_asm = \ - "push [edi]" \ - "popf" \ - "aas" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] \ - value [ax] \ - modify exact [ax]; - -u16 aad_word_asm(u32 *flags,u16 d); -#pragma aux aad_word_asm = \ - "push [edi]" \ - "popf" \ - "aad" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] \ - value [ax] \ - modify exact [ax]; - -u16 aam_word_asm(u32 *flags,u8 d); -#pragma aux aam_word_asm = \ - "push [edi]" \ - "popf" \ - "aam" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] \ - value [ax] \ - modify exact [ax]; - -u8 adc_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux adc_byte_asm = \ - "push [edi]" \ - "popf" \ - "adc al,bl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [bl] \ - value [al] \ - modify exact [al bl]; - -u16 adc_word_asm(u32 *flags,u16 d, u16 s); -#pragma aux adc_word_asm = \ - "push [edi]" \ - "popf" \ - "adc ax,bx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [bx] \ - value [ax] \ - modify exact [ax bx]; - -u32 adc_long_asm(u32 *flags,u32 d, u32 s); -#pragma aux adc_long_asm = \ - "push [edi]" \ - "popf" \ - "adc eax,ebx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [ebx] \ - value [eax] \ - modify exact [eax ebx]; - -u8 add_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux add_byte_asm = \ - "push [edi]" \ - "popf" \ - "add al,bl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [bl] \ - value [al] \ - modify exact [al bl]; - -u16 add_word_asm(u32 *flags,u16 d, u16 s); -#pragma aux add_word_asm = \ - "push [edi]" \ - "popf" \ - "add ax,bx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [bx] \ - value [ax] \ - modify exact [ax bx]; - -u32 add_long_asm(u32 *flags,u32 d, u32 s); -#pragma aux add_long_asm = \ - "push [edi]" \ - "popf" \ - "add eax,ebx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [ebx] \ - value [eax] \ - modify exact [eax ebx]; - -u8 and_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux and_byte_asm = \ - "push [edi]" \ - "popf" \ - "and al,bl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [bl] \ - value [al] \ - modify exact [al bl]; - -u16 and_word_asm(u32 *flags,u16 d, u16 s); -#pragma aux and_word_asm = \ - "push [edi]" \ - "popf" \ - "and ax,bx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [bx] \ - value [ax] \ - modify exact [ax bx]; - -u32 and_long_asm(u32 *flags,u32 d, u32 s); -#pragma aux and_long_asm = \ - "push [edi]" \ - "popf" \ - "and eax,ebx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [ebx] \ - value [eax] \ - modify exact [eax ebx]; - -u8 cmp_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux cmp_byte_asm = \ - "push [edi]" \ - "popf" \ - "cmp al,bl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [bl] \ - value [al] \ - modify exact [al bl]; - -u16 cmp_word_asm(u32 *flags,u16 d, u16 s); -#pragma aux cmp_word_asm = \ - "push [edi]" \ - "popf" \ - "cmp ax,bx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [bx] \ - value [ax] \ - modify exact [ax bx]; - -u32 cmp_long_asm(u32 *flags,u32 d, u32 s); -#pragma aux cmp_long_asm = \ - "push [edi]" \ - "popf" \ - "cmp eax,ebx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [ebx] \ - value [eax] \ - modify exact [eax ebx]; - -u8 daa_byte_asm(u32 *flags,u8 d); -#pragma aux daa_byte_asm = \ - "push [edi]" \ - "popf" \ - "daa" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] \ - value [al] \ - modify exact [al]; - -u8 das_byte_asm(u32 *flags,u8 d); -#pragma aux das_byte_asm = \ - "push [edi]" \ - "popf" \ - "das" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] \ - value [al] \ - modify exact [al]; - -u8 dec_byte_asm(u32 *flags,u8 d); -#pragma aux dec_byte_asm = \ - "push [edi]" \ - "popf" \ - "dec al" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] \ - value [al] \ - modify exact [al]; - -u16 dec_word_asm(u32 *flags,u16 d); -#pragma aux dec_word_asm = \ - "push [edi]" \ - "popf" \ - "dec ax" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] \ - value [ax] \ - modify exact [ax]; - -u32 dec_long_asm(u32 *flags,u32 d); -#pragma aux dec_long_asm = \ - "push [edi]" \ - "popf" \ - "dec eax" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] \ - value [eax] \ - modify exact [eax]; - -u8 inc_byte_asm(u32 *flags,u8 d); -#pragma aux inc_byte_asm = \ - "push [edi]" \ - "popf" \ - "inc al" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] \ - value [al] \ - modify exact [al]; - -u16 inc_word_asm(u32 *flags,u16 d); -#pragma aux inc_word_asm = \ - "push [edi]" \ - "popf" \ - "inc ax" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] \ - value [ax] \ - modify exact [ax]; - -u32 inc_long_asm(u32 *flags,u32 d); -#pragma aux inc_long_asm = \ - "push [edi]" \ - "popf" \ - "inc eax" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] \ - value [eax] \ - modify exact [eax]; - -u8 or_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux or_byte_asm = \ - "push [edi]" \ - "popf" \ - "or al,bl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [bl] \ - value [al] \ - modify exact [al bl]; - -u16 or_word_asm(u32 *flags,u16 d, u16 s); -#pragma aux or_word_asm = \ - "push [edi]" \ - "popf" \ - "or ax,bx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [bx] \ - value [ax] \ - modify exact [ax bx]; - -u32 or_long_asm(u32 *flags,u32 d, u32 s); -#pragma aux or_long_asm = \ - "push [edi]" \ - "popf" \ - "or eax,ebx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [ebx] \ - value [eax] \ - modify exact [eax ebx]; - -u8 neg_byte_asm(u32 *flags,u8 d); -#pragma aux neg_byte_asm = \ - "push [edi]" \ - "popf" \ - "neg al" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] \ - value [al] \ - modify exact [al]; - -u16 neg_word_asm(u32 *flags,u16 d); -#pragma aux neg_word_asm = \ - "push [edi]" \ - "popf" \ - "neg ax" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] \ - value [ax] \ - modify exact [ax]; - -u32 neg_long_asm(u32 *flags,u32 d); -#pragma aux neg_long_asm = \ - "push [edi]" \ - "popf" \ - "neg eax" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] \ - value [eax] \ - modify exact [eax]; - -u8 not_byte_asm(u32 *flags,u8 d); -#pragma aux not_byte_asm = \ - "push [edi]" \ - "popf" \ - "not al" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] \ - value [al] \ - modify exact [al]; - -u16 not_word_asm(u32 *flags,u16 d); -#pragma aux not_word_asm = \ - "push [edi]" \ - "popf" \ - "not ax" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] \ - value [ax] \ - modify exact [ax]; - -u32 not_long_asm(u32 *flags,u32 d); -#pragma aux not_long_asm = \ - "push [edi]" \ - "popf" \ - "not eax" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] \ - value [eax] \ - modify exact [eax]; - -u8 rcl_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux rcl_byte_asm = \ - "push [edi]" \ - "popf" \ - "rcl al,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [cl] \ - value [al] \ - modify exact [al cl]; - -u16 rcl_word_asm(u32 *flags,u16 d, u8 s); -#pragma aux rcl_word_asm = \ - "push [edi]" \ - "popf" \ - "rcl ax,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [cl] \ - value [ax] \ - modify exact [ax cl]; - -u32 rcl_long_asm(u32 *flags,u32 d, u8 s); -#pragma aux rcl_long_asm = \ - "push [edi]" \ - "popf" \ - "rcl eax,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [cl] \ - value [eax] \ - modify exact [eax cl]; - -u8 rcr_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux rcr_byte_asm = \ - "push [edi]" \ - "popf" \ - "rcr al,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [cl] \ - value [al] \ - modify exact [al cl]; - -u16 rcr_word_asm(u32 *flags,u16 d, u8 s); -#pragma aux rcr_word_asm = \ - "push [edi]" \ - "popf" \ - "rcr ax,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [cl] \ - value [ax] \ - modify exact [ax cl]; - -u32 rcr_long_asm(u32 *flags,u32 d, u8 s); -#pragma aux rcr_long_asm = \ - "push [edi]" \ - "popf" \ - "rcr eax,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [cl] \ - value [eax] \ - modify exact [eax cl]; - -u8 rol_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux rol_byte_asm = \ - "push [edi]" \ - "popf" \ - "rol al,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [cl] \ - value [al] \ - modify exact [al cl]; - -u16 rol_word_asm(u32 *flags,u16 d, u8 s); -#pragma aux rol_word_asm = \ - "push [edi]" \ - "popf" \ - "rol ax,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [cl] \ - value [ax] \ - modify exact [ax cl]; - -u32 rol_long_asm(u32 *flags,u32 d, u8 s); -#pragma aux rol_long_asm = \ - "push [edi]" \ - "popf" \ - "rol eax,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [cl] \ - value [eax] \ - modify exact [eax cl]; - -u8 ror_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux ror_byte_asm = \ - "push [edi]" \ - "popf" \ - "ror al,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [cl] \ - value [al] \ - modify exact [al cl]; - -u16 ror_word_asm(u32 *flags,u16 d, u8 s); -#pragma aux ror_word_asm = \ - "push [edi]" \ - "popf" \ - "ror ax,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [cl] \ - value [ax] \ - modify exact [ax cl]; - -u32 ror_long_asm(u32 *flags,u32 d, u8 s); -#pragma aux ror_long_asm = \ - "push [edi]" \ - "popf" \ - "ror eax,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [cl] \ - value [eax] \ - modify exact [eax cl]; - -u8 shl_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux shl_byte_asm = \ - "push [edi]" \ - "popf" \ - "shl al,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [cl] \ - value [al] \ - modify exact [al cl]; - -u16 shl_word_asm(u32 *flags,u16 d, u8 s); -#pragma aux shl_word_asm = \ - "push [edi]" \ - "popf" \ - "shl ax,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [cl] \ - value [ax] \ - modify exact [ax cl]; - -u32 shl_long_asm(u32 *flags,u32 d, u8 s); -#pragma aux shl_long_asm = \ - "push [edi]" \ - "popf" \ - "shl eax,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [cl] \ - value [eax] \ - modify exact [eax cl]; - -u8 shr_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux shr_byte_asm = \ - "push [edi]" \ - "popf" \ - "shr al,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [cl] \ - value [al] \ - modify exact [al cl]; - -u16 shr_word_asm(u32 *flags,u16 d, u8 s); -#pragma aux shr_word_asm = \ - "push [edi]" \ - "popf" \ - "shr ax,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [cl] \ - value [ax] \ - modify exact [ax cl]; - -u32 shr_long_asm(u32 *flags,u32 d, u8 s); -#pragma aux shr_long_asm = \ - "push [edi]" \ - "popf" \ - "shr eax,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [cl] \ - value [eax] \ - modify exact [eax cl]; - -u8 sar_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux sar_byte_asm = \ - "push [edi]" \ - "popf" \ - "sar al,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [cl] \ - value [al] \ - modify exact [al cl]; - -u16 sar_word_asm(u32 *flags,u16 d, u8 s); -#pragma aux sar_word_asm = \ - "push [edi]" \ - "popf" \ - "sar ax,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [cl] \ - value [ax] \ - modify exact [ax cl]; - -u32 sar_long_asm(u32 *flags,u32 d, u8 s); -#pragma aux sar_long_asm = \ - "push [edi]" \ - "popf" \ - "sar eax,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [cl] \ - value [eax] \ - modify exact [eax cl]; - -u16 shld_word_asm(u32 *flags,u16 d, u16 fill, u8 s); -#pragma aux shld_word_asm = \ - "push [edi]" \ - "popf" \ - "shld ax,dx,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [dx] [cl] \ - value [ax] \ - modify exact [ax dx cl]; - -u32 shld_long_asm(u32 *flags,u32 d, u32 fill, u8 s); -#pragma aux shld_long_asm = \ - "push [edi]" \ - "popf" \ - "shld eax,edx,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [edx] [cl] \ - value [eax] \ - modify exact [eax edx cl]; - -u16 shrd_word_asm(u32 *flags,u16 d, u16 fill, u8 s); -#pragma aux shrd_word_asm = \ - "push [edi]" \ - "popf" \ - "shrd ax,dx,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [dx] [cl] \ - value [ax] \ - modify exact [ax dx cl]; - -u32 shrd_long_asm(u32 *flags,u32 d, u32 fill, u8 s); -#pragma aux shrd_long_asm = \ - "push [edi]" \ - "popf" \ - "shrd eax,edx,cl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [edx] [cl] \ - value [eax] \ - modify exact [eax edx cl]; - -u8 sbb_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux sbb_byte_asm = \ - "push [edi]" \ - "popf" \ - "sbb al,bl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [bl] \ - value [al] \ - modify exact [al bl]; - -u16 sbb_word_asm(u32 *flags,u16 d, u16 s); -#pragma aux sbb_word_asm = \ - "push [edi]" \ - "popf" \ - "sbb ax,bx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [bx] \ - value [ax] \ - modify exact [ax bx]; - -u32 sbb_long_asm(u32 *flags,u32 d, u32 s); -#pragma aux sbb_long_asm = \ - "push [edi]" \ - "popf" \ - "sbb eax,ebx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [ebx] \ - value [eax] \ - modify exact [eax ebx]; - -u8 sub_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux sub_byte_asm = \ - "push [edi]" \ - "popf" \ - "sub al,bl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [bl] \ - value [al] \ - modify exact [al bl]; - -u16 sub_word_asm(u32 *flags,u16 d, u16 s); -#pragma aux sub_word_asm = \ - "push [edi]" \ - "popf" \ - "sub ax,bx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [bx] \ - value [ax] \ - modify exact [ax bx]; - -u32 sub_long_asm(u32 *flags,u32 d, u32 s); -#pragma aux sub_long_asm = \ - "push [edi]" \ - "popf" \ - "sub eax,ebx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [ebx] \ - value [eax] \ - modify exact [eax ebx]; - -void test_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux test_byte_asm = \ - "push [edi]" \ - "popf" \ - "test al,bl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [bl] \ - modify exact [al bl]; - -void test_word_asm(u32 *flags,u16 d, u16 s); -#pragma aux test_word_asm = \ - "push [edi]" \ - "popf" \ - "test ax,bx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [bx] \ - modify exact [ax bx]; - -void test_long_asm(u32 *flags,u32 d, u32 s); -#pragma aux test_long_asm = \ - "push [edi]" \ - "popf" \ - "test eax,ebx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [ebx] \ - modify exact [eax ebx]; - -u8 xor_byte_asm(u32 *flags,u8 d, u8 s); -#pragma aux xor_byte_asm = \ - "push [edi]" \ - "popf" \ - "xor al,bl" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [al] [bl] \ - value [al] \ - modify exact [al bl]; - -u16 xor_word_asm(u32 *flags,u16 d, u16 s); -#pragma aux xor_word_asm = \ - "push [edi]" \ - "popf" \ - "xor ax,bx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [ax] [bx] \ - value [ax] \ - modify exact [ax bx]; - -u32 xor_long_asm(u32 *flags,u32 d, u32 s); -#pragma aux xor_long_asm = \ - "push [edi]" \ - "popf" \ - "xor eax,ebx" \ - "pushf" \ - "pop [edi]" \ - parm [edi] [eax] [ebx] \ - value [eax] \ - modify exact [eax ebx]; - -void imul_byte_asm(u32 *flags,u16 *ax,u8 d,u8 s); -#pragma aux imul_byte_asm = \ - "push [edi]" \ - "popf" \ - "imul bl" \ - "pushf" \ - "pop [edi]" \ - "mov [esi],ax" \ - parm [edi] [esi] [al] [bl] \ - modify exact [esi ax bl]; - -void imul_word_asm(u32 *flags,u16 *ax,u16 *dx,u16 d,u16 s); -#pragma aux imul_word_asm = \ - "push [edi]" \ - "popf" \ - "imul bx" \ - "pushf" \ - "pop [edi]" \ - "mov [esi],ax" \ - "mov [ecx],dx" \ - parm [edi] [esi] [ecx] [ax] [bx]\ - modify exact [esi edi ax bx dx]; - -void imul_long_asm(u32 *flags,u32 *eax,u32 *edx,u32 d,u32 s); -#pragma aux imul_long_asm = \ - "push [edi]" \ - "popf" \ - "imul ebx" \ - "pushf" \ - "pop [edi]" \ - "mov [esi],eax" \ - "mov [ecx],edx" \ - parm [edi] [esi] [ecx] [eax] [ebx] \ - modify exact [esi edi eax ebx edx]; - -void mul_byte_asm(u32 *flags,u16 *ax,u8 d,u8 s); -#pragma aux mul_byte_asm = \ - "push [edi]" \ - "popf" \ - "mul bl" \ - "pushf" \ - "pop [edi]" \ - "mov [esi],ax" \ - parm [edi] [esi] [al] [bl] \ - modify exact [esi ax bl]; - -void mul_word_asm(u32 *flags,u16 *ax,u16 *dx,u16 d,u16 s); -#pragma aux mul_word_asm = \ - "push [edi]" \ - "popf" \ - "mul bx" \ - "pushf" \ - "pop [edi]" \ - "mov [esi],ax" \ - "mov [ecx],dx" \ - parm [edi] [esi] [ecx] [ax] [bx]\ - modify exact [esi edi ax bx dx]; - -void mul_long_asm(u32 *flags,u32 *eax,u32 *edx,u32 d,u32 s); -#pragma aux mul_long_asm = \ - "push [edi]" \ - "popf" \ - "mul ebx" \ - "pushf" \ - "pop [edi]" \ - "mov [esi],eax" \ - "mov [ecx],edx" \ - parm [edi] [esi] [ecx] [eax] [ebx] \ - modify exact [esi edi eax ebx edx]; - -void idiv_byte_asm(u32 *flags,u8 *al,u8 *ah,u16 d,u8 s); -#pragma aux idiv_byte_asm = \ - "push [edi]" \ - "popf" \ - "idiv bl" \ - "pushf" \ - "pop [edi]" \ - "mov [esi],al" \ - "mov [ecx],ah" \ - parm [edi] [esi] [ecx] [ax] [bl]\ - modify exact [esi edi ax bl]; - -void idiv_word_asm(u32 *flags,u16 *ax,u16 *dx,u16 dlo,u16 dhi,u16 s); -#pragma aux idiv_word_asm = \ - "push [edi]" \ - "popf" \ - "idiv bx" \ - "pushf" \ - "pop [edi]" \ - "mov [esi],ax" \ - "mov [ecx],dx" \ - parm [edi] [esi] [ecx] [ax] [dx] [bx]\ - modify exact [esi edi ax dx bx]; - -void idiv_long_asm(u32 *flags,u32 *eax,u32 *edx,u32 dlo,u32 dhi,u32 s); -#pragma aux idiv_long_asm = \ - "push [edi]" \ - "popf" \ - "idiv ebx" \ - "pushf" \ - "pop [edi]" \ - "mov [esi],eax" \ - "mov [ecx],edx" \ - parm [edi] [esi] [ecx] [eax] [edx] [ebx]\ - modify exact [esi edi eax edx ebx]; - -void div_byte_asm(u32 *flags,u8 *al,u8 *ah,u16 d,u8 s); -#pragma aux div_byte_asm = \ - "push [edi]" \ - "popf" \ - "div bl" \ - "pushf" \ - "pop [edi]" \ - "mov [esi],al" \ - "mov [ecx],ah" \ - parm [edi] [esi] [ecx] [ax] [bl]\ - modify exact [esi edi ax bl]; - -void div_word_asm(u32 *flags,u16 *ax,u16 *dx,u16 dlo,u16 dhi,u16 s); -#pragma aux div_word_asm = \ - "push [edi]" \ - "popf" \ - "div bx" \ - "pushf" \ - "pop [edi]" \ - "mov [esi],ax" \ - "mov [ecx],dx" \ - parm [edi] [esi] [ecx] [ax] [dx] [bx]\ - modify exact [esi edi ax dx bx]; - -void div_long_asm(u32 *flags,u32 *eax,u32 *edx,u32 dlo,u32 dhi,u32 s); -#pragma aux div_long_asm = \ - "push [edi]" \ - "popf" \ - "div ebx" \ - "pushf" \ - "pop [edi]" \ - "mov [esi],eax" \ - "mov [ecx],edx" \ - parm [edi] [esi] [ecx] [eax] [edx] [ebx]\ - modify exact [esi edi eax edx ebx]; - -#endif - -#endif /* __X86EMU_PRIM_ASM_H */ diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/prim_ops.h b/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/prim_ops.h deleted file mode 100644 index 1633fe1fae..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/prim_ops.h +++ /dev/null @@ -1,231 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Header file for primitive operation functions. -* -****************************************************************************/ - -#ifndef __X86EMU_PRIM_OPS_H -#define __X86EMU_PRIM_OPS_H - -#include "x86emu/prim_asm.h" - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -u16 aaa_word (u16 d); -u16 aas_word (u16 d); -u16 aad_word (u16 d); -u16 aam_word (u8 d); -u8 adc_byte (u8 d, u8 s); -u16 adc_word (u16 d, u16 s); -u32 adc_long (u32 d, u32 s); -u8 add_byte (u8 d, u8 s); -u16 add_word (u16 d, u16 s); -u32 add_long (u32 d, u32 s); -u8 and_byte (u8 d, u8 s); -u16 and_word (u16 d, u16 s); -u32 and_long (u32 d, u32 s); -u8 cmp_byte (u8 d, u8 s); -u16 cmp_word (u16 d, u16 s); -u32 cmp_long (u32 d, u32 s); -u8 daa_byte (u8 d); -u8 das_byte (u8 d); -u8 dec_byte (u8 d); -u16 dec_word (u16 d); -u32 dec_long (u32 d); -u8 inc_byte (u8 d); -u16 inc_word (u16 d); -u32 inc_long (u32 d); -u8 or_byte (u8 d, u8 s); -u16 or_word (u16 d, u16 s); -u32 or_long (u32 d, u32 s); -u8 neg_byte (u8 s); -u16 neg_word (u16 s); -u32 neg_long (u32 s); -u8 not_byte (u8 s); -u16 not_word (u16 s); -u32 not_long (u32 s); -u8 rcl_byte (u8 d, u8 s); -u16 rcl_word (u16 d, u8 s); -u32 rcl_long (u32 d, u8 s); -u8 rcr_byte (u8 d, u8 s); -u16 rcr_word (u16 d, u8 s); -u32 rcr_long (u32 d, u8 s); -u8 rol_byte (u8 d, u8 s); -u16 rol_word (u16 d, u8 s); -u32 rol_long (u32 d, u8 s); -u8 ror_byte (u8 d, u8 s); -u16 ror_word (u16 d, u8 s); -u32 ror_long (u32 d, u8 s); -u8 shl_byte (u8 d, u8 s); -u16 shl_word (u16 d, u8 s); -u32 shl_long (u32 d, u8 s); -u8 shr_byte (u8 d, u8 s); -u16 shr_word (u16 d, u8 s); -u32 shr_long (u32 d, u8 s); -u8 sar_byte (u8 d, u8 s); -u16 sar_word (u16 d, u8 s); -u32 sar_long (u32 d, u8 s); -u16 shld_word (u16 d, u16 fill, u8 s); -u32 shld_long (u32 d, u32 fill, u8 s); -u16 shrd_word (u16 d, u16 fill, u8 s); -u32 shrd_long (u32 d, u32 fill, u8 s); -u8 sbb_byte (u8 d, u8 s); -u16 sbb_word (u16 d, u16 s); -u32 sbb_long (u32 d, u32 s); -u8 sub_byte (u8 d, u8 s); -u16 sub_word (u16 d, u16 s); -u32 sub_long (u32 d, u32 s); -void test_byte (u8 d, u8 s); -void test_word (u16 d, u16 s); -void test_long (u32 d, u32 s); -u8 xor_byte (u8 d, u8 s); -u16 xor_word (u16 d, u16 s); -u32 xor_long (u32 d, u32 s); -void imul_byte (u8 s); -void imul_word (u16 s); -void imul_long (u32 s); -void imul_long_direct(u32 *res_lo, u32* res_hi,u32 d, u32 s); -void mul_byte (u8 s); -void mul_word (u16 s); -void mul_long (u32 s); -void idiv_byte (u8 s); -void idiv_word (u16 s); -void idiv_long (u32 s); -void div_byte (u8 s); -void div_word (u16 s); -void div_long (u32 s); -void ins (int size); -void outs (int size); -u16 mem_access_word (int addr); -void push_word (u16 w); -void push_long (u32 w); -u16 pop_word (void); -u32 pop_long (void); - -#if defined(__HAVE_INLINE_ASSEMBLER__) && !defined(PRIM_OPS_NO_REDEFINE_ASM) - -#define aaa_word(d) aaa_word_asm(&M.x86.R_EFLG,d) -#define aas_word(d) aas_word_asm(&M.x86.R_EFLG,d) -#define aad_word(d) aad_word_asm(&M.x86.R_EFLG,d) -#define aam_word(d) aam_word_asm(&M.x86.R_EFLG,d) -#define adc_byte(d,s) adc_byte_asm(&M.x86.R_EFLG,d,s) -#define adc_word(d,s) adc_word_asm(&M.x86.R_EFLG,d,s) -#define adc_long(d,s) adc_long_asm(&M.x86.R_EFLG,d,s) -#define add_byte(d,s) add_byte_asm(&M.x86.R_EFLG,d,s) -#define add_word(d,s) add_word_asm(&M.x86.R_EFLG,d,s) -#define add_long(d,s) add_long_asm(&M.x86.R_EFLG,d,s) -#define and_byte(d,s) and_byte_asm(&M.x86.R_EFLG,d,s) -#define and_word(d,s) and_word_asm(&M.x86.R_EFLG,d,s) -#define and_long(d,s) and_long_asm(&M.x86.R_EFLG,d,s) -#define cmp_byte(d,s) cmp_byte_asm(&M.x86.R_EFLG,d,s) -#define cmp_word(d,s) cmp_word_asm(&M.x86.R_EFLG,d,s) -#define cmp_long(d,s) cmp_long_asm(&M.x86.R_EFLG,d,s) -#define daa_byte(d) daa_byte_asm(&M.x86.R_EFLG,d) -#define das_byte(d) das_byte_asm(&M.x86.R_EFLG,d) -#define dec_byte(d) dec_byte_asm(&M.x86.R_EFLG,d) -#define dec_word(d) dec_word_asm(&M.x86.R_EFLG,d) -#define dec_long(d) dec_long_asm(&M.x86.R_EFLG,d) -#define inc_byte(d) inc_byte_asm(&M.x86.R_EFLG,d) -#define inc_word(d) inc_word_asm(&M.x86.R_EFLG,d) -#define inc_long(d) inc_long_asm(&M.x86.R_EFLG,d) -#define or_byte(d,s) or_byte_asm(&M.x86.R_EFLG,d,s) -#define or_word(d,s) or_word_asm(&M.x86.R_EFLG,d,s) -#define or_long(d,s) or_long_asm(&M.x86.R_EFLG,d,s) -#define neg_byte(s) neg_byte_asm(&M.x86.R_EFLG,s) -#define neg_word(s) neg_word_asm(&M.x86.R_EFLG,s) -#define neg_long(s) neg_long_asm(&M.x86.R_EFLG,s) -#define not_byte(s) not_byte_asm(&M.x86.R_EFLG,s) -#define not_word(s) not_word_asm(&M.x86.R_EFLG,s) -#define not_long(s) not_long_asm(&M.x86.R_EFLG,s) -#define rcl_byte(d,s) rcl_byte_asm(&M.x86.R_EFLG,d,s) -#define rcl_word(d,s) rcl_word_asm(&M.x86.R_EFLG,d,s) -#define rcl_long(d,s) rcl_long_asm(&M.x86.R_EFLG,d,s) -#define rcr_byte(d,s) rcr_byte_asm(&M.x86.R_EFLG,d,s) -#define rcr_word(d,s) rcr_word_asm(&M.x86.R_EFLG,d,s) -#define rcr_long(d,s) rcr_long_asm(&M.x86.R_EFLG,d,s) -#define rol_byte(d,s) rol_byte_asm(&M.x86.R_EFLG,d,s) -#define rol_word(d,s) rol_word_asm(&M.x86.R_EFLG,d,s) -#define rol_long(d,s) rol_long_asm(&M.x86.R_EFLG,d,s) -#define ror_byte(d,s) ror_byte_asm(&M.x86.R_EFLG,d,s) -#define ror_word(d,s) ror_word_asm(&M.x86.R_EFLG,d,s) -#define ror_long(d,s) ror_long_asm(&M.x86.R_EFLG,d,s) -#define shl_byte(d,s) shl_byte_asm(&M.x86.R_EFLG,d,s) -#define shl_word(d,s) shl_word_asm(&M.x86.R_EFLG,d,s) -#define shl_long(d,s) shl_long_asm(&M.x86.R_EFLG,d,s) -#define shr_byte(d,s) shr_byte_asm(&M.x86.R_EFLG,d,s) -#define shr_word(d,s) shr_word_asm(&M.x86.R_EFLG,d,s) -#define shr_long(d,s) shr_long_asm(&M.x86.R_EFLG,d,s) -#define sar_byte(d,s) sar_byte_asm(&M.x86.R_EFLG,d,s) -#define sar_word(d,s) sar_word_asm(&M.x86.R_EFLG,d,s) -#define sar_long(d,s) sar_long_asm(&M.x86.R_EFLG,d,s) -#define shld_word(d,fill,s) shld_word_asm(&M.x86.R_EFLG,d,fill,s) -#define shld_long(d,fill,s) shld_long_asm(&M.x86.R_EFLG,d,fill,s) -#define shrd_word(d,fill,s) shrd_word_asm(&M.x86.R_EFLG,d,fill,s) -#define shrd_long(d,fill,s) shrd_long_asm(&M.x86.R_EFLG,d,fill,s) -#define sbb_byte(d,s) sbb_byte_asm(&M.x86.R_EFLG,d,s) -#define sbb_word(d,s) sbb_word_asm(&M.x86.R_EFLG,d,s) -#define sbb_long(d,s) sbb_long_asm(&M.x86.R_EFLG,d,s) -#define sub_byte(d,s) sub_byte_asm(&M.x86.R_EFLG,d,s) -#define sub_word(d,s) sub_word_asm(&M.x86.R_EFLG,d,s) -#define sub_long(d,s) sub_long_asm(&M.x86.R_EFLG,d,s) -#define test_byte(d,s) test_byte_asm(&M.x86.R_EFLG,d,s) -#define test_word(d,s) test_word_asm(&M.x86.R_EFLG,d,s) -#define test_long(d,s) test_long_asm(&M.x86.R_EFLG,d,s) -#define xor_byte(d,s) xor_byte_asm(&M.x86.R_EFLG,d,s) -#define xor_word(d,s) xor_word_asm(&M.x86.R_EFLG,d,s) -#define xor_long(d,s) xor_long_asm(&M.x86.R_EFLG,d,s) -#define imul_byte(s) imul_byte_asm(&M.x86.R_EFLG,&M.x86.R_AX,M.x86.R_AL,s) -#define imul_word(s) imul_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,s) -#define imul_long(s) imul_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s) -#define imul_long_direct(res_lo,res_hi,d,s) imul_long_asm(&M.x86.R_EFLG,res_lo,res_hi,d,s) -#define mul_byte(s) mul_byte_asm(&M.x86.R_EFLG,&M.x86.R_AX,M.x86.R_AL,s) -#define mul_word(s) mul_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,s) -#define mul_long(s) mul_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s) -#define idiv_byte(s) idiv_byte_asm(&M.x86.R_EFLG,&M.x86.R_AL,&M.x86.R_AH,M.x86.R_AX,s) -#define idiv_word(s) idiv_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,M.x86.R_DX,s) -#define idiv_long(s) idiv_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,M.x86.R_EDX,s) -#define div_byte(s) div_byte_asm(&M.x86.R_EFLG,&M.x86.R_AL,&M.x86.R_AH,M.x86.R_AX,s) -#define div_word(s) div_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,M.x86.R_DX,s) -#define div_long(s) div_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,M.x86.R_EDX,s) - -#endif - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif - -#endif /* __X86EMU_PRIM_OPS_H */ diff --git a/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/x86emui.h b/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/x86emui.h deleted file mode 100644 index bff49039e0..0000000000 --- a/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/x86emui.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -* -* Realmode X86 Emulator Library -* -* Copyright (C) 1996-1999 SciTech Software, Inc. -* Copyright (C) David Mosberger-Tang -* Copyright (C) 1999 Egbert Eich -* -* ======================================================================== -* -* Permission to use, copy, modify, distribute, and sell this software and -* its documentation for any purpose is hereby granted without fee, -* provided that the above copyright notice appear in all copies and that -* both that copyright notice and this permission notice appear in -* supporting documentation, and that the name of the authors not be used -* in advertising or publicity pertaining to distribution of the software -* without specific, written prior permission. The authors makes no -* representations about the suitability of this software for any purpose. -* It is provided "as is" without express or implied warranty. -* -* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -* PERFORMANCE OF THIS SOFTWARE. -* -* ======================================================================== -* -* Language: ANSI C -* Environment: Any -* Developer: Kendall Bennett -* -* Description: Header file for system specific functions. These functions -* are always compiled and linked in the OS depedent libraries, -* and never in a binary portable driver. -* -****************************************************************************/ - -#ifndef __X86EMU_X86EMUI_H -#define __X86EMU_X86EMUI_H - -/* If we are compiling in C++ mode, we can compile some functions as - * inline to increase performance (however the code size increases quite - * dramatically in this case). - */ - -#if defined(__cplusplus) && !defined(_NO_INLINE) -#define _INLINE inline -#else -#define _INLINE static -#endif - -/* Get rid of unused parameters in C++ compilation mode */ - -#ifdef __cplusplus -#define X86EMU_UNUSED(v) -#else -#define X86EMU_UNUSED(v) v -#endif - -#include "x86emu.h" -#include "x86emu/regs.h" -#include "x86emu/debug.h" -#include "x86emu/decode.h" -#include "x86emu/ops.h" -#include "x86emu/prim_ops.h" -#include "x86emu/fpu.h" -#include "x86emu/fpu_regs.h" -#include -#include - -/*--------------------------- Inline Functions ----------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -extern u8 (X86APIP sys_rdb)(u32 addr); -extern u16 (X86APIP sys_rdw)(u32 addr); -extern u32 (X86APIP sys_rdl)(u32 addr); -extern void (X86APIP sys_wrb)(u32 addr,u8 val); -extern void (X86APIP sys_wrw)(u32 addr,u16 val); -extern void (X86APIP sys_wrl)(u32 addr,u32 val); - -extern u8 (X86APIP sys_inb)(X86EMU_pioAddr addr); -extern u16 (X86APIP sys_inw)(X86EMU_pioAddr addr); -extern u32 (X86APIP sys_inl)(X86EMU_pioAddr addr); -extern void (X86APIP sys_outb)(X86EMU_pioAddr addr,u8 val); -extern void (X86APIP sys_outw)(X86EMU_pioAddr addr,u16 val); -extern void (X86APIP sys_outl)(X86EMU_pioAddr addr,u32 val); - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif - -#endif /* __X86EMU_X86EMUI_H */ diff --git a/board/MAI/bios_emulator/x86interface.c b/board/MAI/bios_emulator/x86interface.c deleted file mode 100644 index 909cb3cf94..0000000000 --- a/board/MAI/bios_emulator/x86interface.c +++ /dev/null @@ -1,814 +0,0 @@ -#include "x86emu.h" -#include "glue.h" - - -/* - * This isn't nice, but there are a lot of incompatibilities in the U-Boot and scitech include - * files that this is the only really workable solution. - * Might be cleaned out later. - */ - -#ifdef DEBUG -#undef DEBUG -#endif - -#undef IO_LOGGING -#undef MEM_LOGGING - -#ifdef IO_LOGGING -#define LOGIO(port, format, args...) if (dolog(port)) _printf(format , ## args) -#else -#define LOGIO(port, format, args...) -#endif - -#ifdef MEM_LOGGIN -#define LOGMEM(format, args...) _printf(format , ## args) -#else -#define LOGMEM(format, args...) -#endif - -#ifdef DEBUG -#define PRINTF(format, args...) _printf(format , ## args) -#else -#define PRINTF(format, argc...) -#endif - -typedef unsigned char UBYTE; -typedef unsigned short UWORD; -typedef unsigned long ULONG; - -typedef char BYTE; -typedef short WORT; -typedef long LONG; - -#define EMULATOR_MEM_SIZE (1024*1024) -#define EMULATOR_BIOS_OFFSET 0xC0000 -#define EMULATOR_STRAP_OFFSET 0x30000 -#define EMULATOR_STACK_OFFSET 0x20000 -#define EMULATOR_LOGO_OFFSET 0x40000 /* If you change this, change the strap code, too */ -#define VIDEO_BASE (void *)0xFD0B8000 - -extern char *getenv(char *); -extern int tstc(void); -extern int getc(void); -extern unsigned char video_get_attr(void); - -int atoi(char *string) -{ - int res = 0; - while (*string>='0' && *string <='9') - { - res *= 10; - res += *string-'0'; - string++; - } - - return res; -} - -void cons_gets(char *buffer) -{ - int i = 0; - char c = 0; - - buffer[0] = 0; - if (getenv("x86_runthru")) return; /*FIXME: */ - while (c != 0x0D && c != 0x0A) - { - while (!tstc()); - c = getc(); - if (c>=32 && c < 127) - { - buffer[i] = c; - i++; - buffer[i] = 0; - putc(c); - } - else - { - if (c == 0x08) - { - if (i>0) i--; - buffer[i] = 0; - } - } - } - buffer[i] = '\n'; - buffer[i+1] = 0; -} - -char *bios_date = "08/14/02"; -UBYTE model = 0xFC; -UBYTE submodel = 0x00; - -static inline UBYTE read_byte(volatile UBYTE* from) -{ - int x; - asm volatile ("lbz %0,%1\n eieio" : "=r" (x) : "m" (*from)); - return (UBYTE)x; -} - -static inline void write_byte(volatile UBYTE *to, int x) -{ - asm volatile ("stb %1,%0\n eieio" : "=m" (*to) : "r" (x)); -} - -static inline UWORD read_word_little(volatile UWORD *from) -{ - int x; - asm volatile ("lhbrx %0,0,%1\n eieio" : "=r" (x) : "r" (from), "m" (*from)); - return (UWORD)x; -} - -static inline UWORD read_word_big(volatile UWORD *from) -{ - int x; - asm volatile ("lhz %0,%1\n eieio" : "=r" (x) : "m" (*from)); - return (UWORD)x; -} - -static inline void write_word_little(volatile UWORD *to, int x) -{ - asm volatile ("sthbrx %1,0,%2\n eieio" : "=m" (*to) : "r" (x), "r" (to)); -} - -static inline void write_word_big(volatile UWORD *to, int x) -{ - asm volatile ("sth %1,%0\n eieio" : "=m" (*to) : "r" (x)); -} - -static inline ULONG read_long_little(volatile ULONG *from) -{ - unsigned long x; - asm volatile ("lwbrx %0,0,%1\n eieio" : "=r" (x) : "r" (from), "m"(*from)); - return (ULONG)x; -} - -static inline ULONG read_long_big(volatile ULONG *from) -{ - unsigned long x; - asm volatile ("lwz %0,%1\n eieio" : "=r" (x) : "m" (*from)); - return (ULONG)x; -} - -static inline void write_long_little(volatile ULONG *to, ULONG x) -{ - asm volatile ("stwbrx %1,0,%2\n eieio" : "=m" (*to) : "r" (x), "r" (to)); -} - -static inline void write_long_big(volatile ULONG *to, ULONG x) -{ - asm volatile ("stw %1,%0\n eieio" : "=m" (*to) : "r" (x)); -} - -static int log_init = 0; -static int log_do = 0; -static int log_low = 0; - -int dolog(int port) -{ - if (log_init && log_do) - { - if (log_low && port > 0x400) return 0; - return 1; - } - - if (!log_init) - { - log_init = 1; - log_do = (getenv("x86_logio") != (char *)0); - log_low = (getenv("x86_loglow") != (char *)0); - if (log_do) - { - if (log_low && port > 0x400) return 0; - return 1; - } - } - return 0; -} - -/* Converts an emulator address to a physical address. */ -/* Handles all special cases (bios date, model etc), and might need work */ -u32 memaddr(u32 addr) -{ -/* if (addr >= 0xF0000 && addr < 0xFFFFF) printf("WARNING: Segment F access (0x%x)\n", addr); */ -/* printf("MemAddr=%p\n", addr); */ - if (addr >= 0xA0000 && addr < 0xC0000) - return 0xFD000000 + addr; - else if (addr >= 0xFFFF5 && addr < 0xFFFFE) - { - return (u32)bios_date+addr-0xFFFF5; - } - else if (addr == 0xFFFFE) - return (u32)&model; - else if (addr == 0xFFFFF) - return (u32)&submodel; - else if (addr >= 0x80000000) - { - /*printf("Warning: High memory access at 0x%x\n", addr); */ - return addr; - } - else - return (u32)M.mem_base+addr; -} - -u8 A1_rdb(u32 addr) -{ - u8 a = read_byte((UBYTE *)memaddr(addr)); - LOGMEM("rdb: %x -> %x\n", addr, a); - return a; -} - -u16 A1_rdw(u32 addr) -{ - u16 a = read_word_little((UWORD *)memaddr(addr)); - LOGMEM("rdw: %x -> %x\n", addr, a); - return a; -} - -u32 A1_rdl(u32 addr) -{ - u32 a = read_long_little((ULONG *)memaddr(addr)); - LOGMEM("rdl: %x -> %x\n", addr, a); - return a; -} - -void A1_wrb(u32 addr, u8 val) -{ - LOGMEM("wrb: %x <- %x\n", addr, val); - write_byte((UBYTE *)memaddr(addr), val); -} - -void A1_wrw(u32 addr, u16 val) -{ - LOGMEM("wrw: %x <- %x\n", addr, val); - write_word_little((UWORD *)memaddr(addr), val); -} - -void A1_wrl(u32 addr, u32 val) -{ - LOGMEM("wrl: %x <- %x\n", addr, val); - write_long_little((ULONG *)memaddr(addr), val); -} - -X86EMU_memFuncs _A1_mem = -{ - A1_rdb, - A1_rdw, - A1_rdl, - A1_wrb, - A1_wrw, - A1_wrl, -}; - -#define ARTICIAS_PCI_CFGADDR 0xfec00cf8 -#define ARTICIAS_PCI_CFGDATA 0xfee00cfc -#define IOBASE 0xFE000000 - -#define in_byte(from) read_byte( (UBYTE *)port_to_mem(from)) -#define in_word(from) read_word_little((UWORD *)port_to_mem(from)) -#define in_long(from) read_long_little((ULONG *)port_to_mem(from)) -#define out_byte(to, val) write_byte((UBYTE *)port_to_mem(to), val) -#define out_word(to, val) write_word_little((UWORD *)port_to_mem(to), val) -#define out_long(to, val) write_long_little((ULONG *)port_to_mem(to), val) - -u32 port_to_mem(int port) -{ - if (port >= 0xCFC && port <= 0xCFF) return 0xFEE00000+port; - else if (port >= 0xCF8 && port <= 0xCFB) return 0xFEC00000+port; - else return IOBASE + port; -} - -u8 A1_inb(int port) -{ - u8 a; - /*if (port == 0x3BA) return 0; */ - a = in_byte(port); - LOGIO(port, "inb: %Xh -> %d (%Xh)\n", port, a, a); - return a; -} - -u16 A1_inw(int port) -{ - u16 a = in_word(port); - LOGIO(port, "inw: %Xh -> %d (%Xh)\n", port, a, a); - return a; -} - -u32 A1_inl(int port) -{ - u32 a = in_long(port); - LOGIO(port, "inl: %Xh -> %d (%Xh)\n", port, a, a); - return a; -} - -void A1_outb(int port, u8 val) -{ - LOGIO(port, "outb: %Xh <- %d (%Xh)\n", port, val, val); -/* if (port == 0xCF8) port = 0xCFB; - else if (port == 0xCF9) port = 0xCFA; - else if (port == 0xCFA) port = 0xCF9; - else if (port == 0xCFB) port = 0xCF8;*/ - out_byte(port, val); -} - -void A1_outw(int port, u16 val) -{ - LOGIO(port, "outw: %Xh <- %d (%Xh)\n", port, val, val); - out_word(port, val); -} - -void A1_outl(int port, u32 val) -{ - LOGIO(port, "outl: %Xh <- %d (%Xh)\n", port, val, val); - out_long(port, val); -} - -X86EMU_pioFuncs _A1_pio = -{ - A1_inb, - A1_inw, - A1_inl, - A1_outb, - A1_outw, - A1_outl, -}; - -static int reloced_ops = 0; - -void reloc_ops(void *reloc_addr) -{ - extern void (*x86emu_optab[256])(u8); - extern void (*x86emu_optab2[256])(u8); - extern void tables_relocate(unsigned int offset); - int i; - unsigned long delta; - if (reloced_ops == 1) return; - reloced_ops = 1; - - delta = TEXT_BASE - (unsigned long)reloc_addr; - - for (i=0; i<256; i++) - { - x86emu_optab[i] -= delta; - x86emu_optab2[i] -= delta; - } - - _A1_mem.rdb = A1_rdb; - _A1_mem.rdw = A1_rdw; - _A1_mem.rdl = A1_rdl; - _A1_mem.wrb = A1_wrb; - _A1_mem.wrw = A1_wrw; - _A1_mem.wrl = A1_wrl; - - _A1_pio.inb = A1_inb; - _A1_pio.inw = A1_inw; - _A1_pio.inl = A1_inl; - _A1_pio.outb = A1_outb; - _A1_pio.outw = A1_outw; - _A1_pio.outl = A1_outl; - - tables_relocate(delta); - -} - - -#define ANY_KEY(text) \ - printf(text); \ - while (!tstc()); - - -unsigned char more_strap[] = { - 0xb4, 0x0, 0xb0, 0x2, 0xcd, 0x10, -}; -#define MORE_STRAP_BYTES 6 /* Additional bytes of strap code */ - - -unsigned char *done_msg="VGA Initialized\0"; - -int execute_bios(pci_dev_t gr_dev, void *reloc_addr) -{ - extern void bios_init(void); - extern void remove_init_data(void); - extern int video_rows(void); - extern int video_cols(void); - extern int video_size(int, int); - u8 *strap; - unsigned char *logo; - u8 cfg; - int i; - char c; - char *s; -#ifdef EASTEREGG - int easteregg_active = 0; -#endif - char *pal_reset; - u8 *fb; - unsigned char *msg; - unsigned char current_attr; - - PRINTF("Trying to remove init data\n"); - remove_init_data(); - PRINTF("Removed init data from cache, now in RAM\n"); - - reloc_ops(reloc_addr); - PRINTF("Attempting to run emulator on %02x:%02x:%02x\n", - PCI_BUS(gr_dev), PCI_DEV(gr_dev), PCI_FUNC(gr_dev)); - - /* Enable compatibility hole for emulator access to frame buffer */ - PRINTF("Enabling compatibility hole\n"); - enable_compatibility_hole(); - - /* Allocate memory */ - /* FIXME: We shouldn't use this much memory really. */ - memset(&M, 0, sizeof(X86EMU_sysEnv)); - M.mem_base = malloc(EMULATOR_MEM_SIZE); - M.mem_size = EMULATOR_MEM_SIZE; - - if (!M.mem_base) - { - PRINTF("Unable to allocate one megabyte for emulator\n"); - return 0; - } - - if (attempt_map_rom(gr_dev, M.mem_base + EMULATOR_BIOS_OFFSET) == 0) - { - PRINTF("Error mapping rom. Emulation terminated\n"); - return 0; - } - -#if 1 /*def DEBUG*/ - s = getenv("x86_ask_start"); - if (s) - { - printf("Press 'q' to skip initialization, 'd' for dry init\n'i' for i/o session"); - while (!tstc()); - c = getc(); - if (c == 'q') return 0; - if (c == 'd') - { - extern void bios_set_mode(int mode); - bios_set_mode(0x03); - return 0; - } - if (c == 'i') do_inout(); - } - - -#endif - -#ifdef EASTEREGG -/* if (tstc()) - { - if (getc() == 'c') - { - easteregg_active = 1; - } - } -*/ - if (getenv("easteregg")) - { - easteregg_active = 1; - } - - if (easteregg_active) - { - /* Yay! */ - setenv("x86_mode", "1"); - setenv("vga_fg_color", "11"); - setenv("vga_bg_color", "1"); - easteregg_active = 1; - } -#endif - - strap = (u8*)M.mem_base + EMULATOR_STRAP_OFFSET; - - { - char *m = getenv("x86_mode"); - if (m) - { - more_strap[3] = atoi(m); - if (more_strap[3] == 1) video_size(40, 25); - else video_size(80, 25); - } - } - - /* - * Poke the strap routine. This might need a bit of extending - * if there is a mode switch involved, i.e. we want to int10 - * afterwards to set a different graphics mode, or alternatively - * there might be a different start address requirement if the - * ROM doesn't have an x86 image in its first image. - */ - - PRINTF("Poking strap...\n"); - - /* FAR CALL c000:0003 */ - *strap++ = 0x9A; *strap++ = 0x03; *strap++ = 0x00; - *strap++ = 0x00; *strap++ = 0xC0; - -#if 1 - /* insert additional strap code */ - for (i=0; i < MORE_STRAP_BYTES; i++) - { - *strap++ = more_strap[i]; - } -#endif - /* HALT */ - *strap++ = 0xF4; - - PRINTF("Setting up logo data\n"); - logo = (unsigned char *)M.mem_base + EMULATOR_LOGO_OFFSET; - for (i=0; i<16; i++) - { - *logo++ = 0xFF; - } - - /* - * Setup the init parameters. - * Per PCI specs, AH must contain the bus and AL - * must contain the devfn, encoded as (dev<<3)|fn - */ - - /* Execution starts here */ - M.x86.R_CS = SEG(EMULATOR_STRAP_OFFSET); - M.x86.R_IP = OFF(EMULATOR_STRAP_OFFSET); - - /* Stack at top of ram */ - M.x86.R_SS = SEG(EMULATOR_STACK_OFFSET); - M.x86.R_SP = OFF(EMULATOR_STACK_OFFSET); - - /* Input parameters */ - M.x86.R_AH = PCI_BUS(gr_dev); - M.x86.R_AL = (PCI_DEV(gr_dev)<<3) | PCI_FUNC(gr_dev); - - /* Set the I/O and memory access functions */ - X86EMU_setupMemFuncs(&_A1_mem); - X86EMU_setupPioFuncs(&_A1_pio); - - /* Enable timer 2 */ - cfg = in_byte(0x61); /* Get Misc control */ - cfg |= 0x01; /* Enable timer 2 */ - out_byte(0x61, cfg); /* output again */ - - /* Set up the timers */ - out_byte(0x43, 0x54); - out_byte(0x41, 0x18); - - out_byte(0x43, 0x36); - out_byte(0x40, 0x00); - out_byte(0x40, 0x00); - - out_byte(0x43, 0xb6); - out_byte(0x42, 0x31); - out_byte(0x42, 0x13); - - /* Init the "BIOS". */ - bios_init(); - - /* Video Card Reset */ - out_byte(0x3D8, 0); - out_byte(0x3B8, 1); - (void)in_byte(0x3BA); - (void)in_byte(0x3DA); - out_byte(0x3C0, 0); - out_byte(0x61, 0xFC); - -#ifdef DEBUG - s = _getenv("x86_singlestep"); - if (s && strcmp(s, "on")==0) - { - PRINTF("Enabling single stepping for debug\n"); - X86EMU_trace_on(); - } -#endif - - /* Ready set go... */ - PRINTF("Running emulator\n"); - X86EMU_exec(); - PRINTF("Done running emulator\n"); - -/* FIXME: Remove me */ - pal_reset = getenv("x86_palette_reset"); - if (pal_reset && strcmp(pal_reset, "on") == 0) - { - PRINTF("Palette reset\n"); - /*(void)in_byte(0x3da); */ - /*out_byte(0x3c0, 0); */ - - out_byte(0x3C8, 0); - out_byte(0x3C9, 0); - out_byte(0x3C9, 0); - out_byte(0x3C9, 0); - for (i=0; i<254; i++) - { - out_byte(0x3C9, 63); - out_byte(0x3C9, 63); - out_byte(0x3C9, 63); - } - - out_byte(0x3c0, 0x20); - } -/* FIXME: remove me */ -#ifdef EASTEREGG - if (easteregg_active) - { - extern void video_easteregg(void); - video_easteregg(); - } -#endif -/* - current_attr = video_get_attr(); - fb = (u8 *)VIDEO_BASE; - for (i=0; i