From c7de829c796978e519984df2f1c8cfcf921a39a4 Mon Sep 17 00:00:00 2001
From: wdenk <wdenk>
Date: Tue, 19 Nov 2002 11:04:11 +0000
Subject: [PATCH] * Patch by Thomas Frieden, 13 Nov 2002:   Add code for
 AmigaOne board   (preliminary merge to U-Boot, still WIP)

* Patch by Jon Diekema, 12 Nov 2002:
  - Adding URL for IEEE OUI lookup
  - Making the autoboot #defines dependent on CONFIG_AUTOBOOT_KEYED
    being defined.
  - In the CONFIG_EXTRA_ENV_SETTINGS #define, the root-on-initrd and
    root-on-nfs macros are designed to switch how the default boot
    method gets defined.
---
 CHANGELOG                                     |    12 +
 CREDITS                                       |     4 +
 MAINTAINERS                                   |     5 +-
 Makefile                                      |     3 +
 board/MAI/AmigaOneG3SE/AmigaOneG3SE.c         |   116 +
 board/MAI/AmigaOneG3SE/Makefile               |    53 +
 board/MAI/AmigaOneG3SE/articiaS.c             |   704 +
 board/MAI/AmigaOneG3SE/articiaS.h             |   143 +
 board/MAI/AmigaOneG3SE/articiaS_pci.c         |   573 +
 board/MAI/AmigaOneG3SE/board_asm_init.S       |   157 +
 board/MAI/AmigaOneG3SE/cmd_boota.c            |   123 +
 board/MAI/AmigaOneG3SE/config.mk              |    33 +
 board/MAI/AmigaOneG3SE/enet.c                 |   886 ++
 board/MAI/AmigaOneG3SE/flash.c                |    35 +
 board/MAI/AmigaOneG3SE/flash_new.c            |   652 +
 board/MAI/AmigaOneG3SE/i8259.c                |   230 +
 board/MAI/AmigaOneG3SE/i8259.h                |    56 +
 board/MAI/AmigaOneG3SE/interrupts.c           |   268 +
 board/MAI/AmigaOneG3SE/macros.h               |    84 +
 board/MAI/AmigaOneG3SE/memio.S                |    74 +
 board/MAI/AmigaOneG3SE/memio.h                |   113 +
 board/MAI/AmigaOneG3SE/memory_dump            |    30 +
 board/MAI/AmigaOneG3SE/nvram.c                |    37 +
 board/MAI/AmigaOneG3SE/ps2kbd.c               |   699 +
 board/MAI/AmigaOneG3SE/ps2kbd.h               |    41 +
 board/MAI/AmigaOneG3SE/serial.c               |   247 +
 board/MAI/AmigaOneG3SE/short_types.h          |    36 +
 board/MAI/AmigaOneG3SE/smbus.c                |   206 +
 board/MAI/AmigaOneG3SE/smbus.h                |    22 +
 board/MAI/AmigaOneG3SE/start.txt              |   201 +
 board/MAI/AmigaOneG3SE/todo.txt               |     3 +
 board/MAI/AmigaOneG3SE/u-boot.lds             |   131 +
 board/MAI/AmigaOneG3SE/usb_uhci.c             |  1179 ++
 board/MAI/AmigaOneG3SE/usb_uhci.h             |   194 +
 board/MAI/AmigaOneG3SE/via686.c               |   299 +
 board/MAI/AmigaOneG3SE/via686.h               |    29 +
 board/MAI/AmigaOneG3SE/video.c                |   539 +
 board/MAI/bios_emulator/bios.c                |   335 +
 board/MAI/bios_emulator/glue.c                |   528 +
 board/MAI/bios_emulator/glue.h                |    57 +
 .../scitech/bin-linux/glibc/dmake             |   Bin 0 -> 70812 bytes
 .../scitech/bin-linux/glibc/k_cp              |   Bin 0 -> 37612 bytes
 .../scitech/bin-linux/glibc/k_echo            |   Bin 0 -> 11924 bytes
 .../scitech/bin-linux/glibc/k_rm              |   Bin 0 -> 38300 bytes
 .../scitech/bin-linux/glibc/makedep           |   Bin 0 -> 58623 bytes
 .../scitech/bin-linux/glibc/nasm              |   Bin 0 -> 263498 bytes
 .../scitech/bin-linux/glibc/ndisasm           |   Bin 0 -> 100192 bytes
 .../scitech/bin-linux/glibc/trans             |   Bin 0 -> 9244 bytes
 .../scitech/bin-linux/libc/dmake              |   Bin 0 -> 71264 bytes
 .../bios_emulator/scitech/bin-linux/libc/nasm |   Bin 0 -> 168228 bytes
 .../scitech/bin-linux/libc/ndisasm            |   Bin 0 -> 66888 bytes
 .../scitech/bin-linux/libc/trans              |   Bin 0 -> 8984 bytes
 .../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   |   155 +
 .../MAI/bios_emulator/scitech/include/event.h |   696 +
 .../MAI/bios_emulator/scitech/include/mtrr.h  |    72 +
 .../bios_emulator/scitech/include/pcilib.h    |   414 +
 .../bios_emulator/scitech/include/pm_help.h   |   167 +
 .../bios_emulator/scitech/include/pm_wctl.h   |    76 +
 .../MAI/bios_emulator/scitech/include/pmapi.h |  1149 ++
 .../MAI/bios_emulator/scitech/include/pmimp.h |   194 +
 .../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/readme.txt      |     1 +
 .../lib/debug/linux/gcc/libc/readme.txt       |     1 +
 .../lib/release/linux/gcc/glibc/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  |   181 +
 .../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             |   181 +
 .../scitech/makedefs/gcc_win32.mk             |   136 +
 .../bios_emulator/scitech/makedefs/hc32.mk    |   113 +
 .../scitech/makedefs/makedefs.prj             |   Bin 0 -> 9025 bytes
 .../bios_emulator/scitech/makedefs/qnx4.mk    |   165 +
 .../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        |    48 +
 .../scitech/makedefs/rules/gcc_freebsd.mk     |    47 +
 .../scitech/makedefs/rules/gcc_linux.mk       |    94 +
 .../scitech/makedefs/rules/gcc_win32.mk       |    91 +
 .../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            |   265 +
 .../bios_emulator/scitech/makedefs/sc16.mk    |   128 +
 .../bios_emulator/scitech/makedefs/sc32.mk    |   178 +
 .../bios_emulator/scitech/makedefs/startup.mk |   162 +
 .../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    |   354 +
 .../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 |   220 +
 .../bios_emulator/scitech/src/common/center.c |   123 +
 .../scitech/src/common/cmdline.c              |   428 +
 .../bios_emulator/scitech/src/common/gabeos.c |   146 +
 .../bios_emulator/scitech/src/common/gados.c  |   136 +
 .../bios_emulator/scitech/src/common/galib.c  |   269 +
 .../scitech/src/common/galinux.c              |   148 +
 .../scitech/src/common/gantdrv.c              |   137 +
 .../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  |   137 +
 .../scitech/src/common/gawin32.c              |   256 +
 .../scitech/src/common/gtfcalc.c              |   436 +
 .../scitech/src/common/libcimp.c              |   828 ++
 .../bios_emulator/scitech/src/common/makefile |    18 +
 .../scitech/src/common/peloader.c             |   587 +
 .../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 |   190 +
 .../scitech/src/pm/common/keyboard.c          |   450 +
 .../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              |  1361 ++
 .../scitech/src/pm/linux/event.svga           |  1058 ++
 .../scitech/src/pm/linux/oshdr.h              |    61 +
 .../bios_emulator/scitech/src/pm/linux/pm.c   |  1810 +++
 .../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            |    65 +
 .../scitech/src/pm/ntdrv/int86.c              |   252 +
 .../bios_emulator/scitech/src/pm/ntdrv/irq.c  |   143 +
 .../bios_emulator/scitech/src/pm/ntdrv/mem.c  |   519 +
 .../scitech/src/pm/ntdrv/oshdr.h              |    46 +
 .../bios_emulator/scitech/src/pm/ntdrv/pm.c   |   934 ++
 .../scitech/src/pm/ntdrv/stdio.c              |   331 +
 .../scitech/src/pm/ntdrv/stdlib.c             |   140 +
 .../scitech/src/pm/ntdrv/vflat.c              |    45 +
 .../scitech/src/pm/ntdrv/ztimer.c             |   124 +
 .../scitech/src/pm/os2/_pmos2.asm             |   180 +
 .../scitech/src/pm/os2/cpuinfo.c              |    66 +
 .../bios_emulator/scitech/src/pm/os2/event.c  |   566 +
 .../bios_emulator/scitech/src/pm/os2/mon.h    |   165 +
 .../bios_emulator/scitech/src/pm/os2/oshdr.h  |    42 +
 .../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  |   602 +
 .../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            |    82 +
 .../bios_emulator/scitech/src/pm/tests/rtc.c  |    92 +
 .../bios_emulator/scitech/src/pm/tests/save.c |    70 +
 .../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              |   200 +
 .../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 |   305 +
 .../bios_emulator/scitech/src/pm/vxd/oshdr.h  |    29 +
 .../MAI/bios_emulator/scitech/src/pm/vxd/pm.c |  1360 ++
 .../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              |   583 +
 .../scitech/src/pm/win32/event.c              |   460 +
 .../scitech/src/pm/win32/ntservc.c            |   259 +
 .../scitech/src/pm/win32/oshdr.h              |    80 +
 .../bios_emulator/scitech/src/pm/win32/pm.c   |  1460 ++
 .../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 |   517 +
 .../scitech/src/v86bios/AsmMacros.h           |   450 +
 .../bios_emulator/scitech/src/v86bios/README  |    35 +
 .../bios_emulator/scitech/src/v86bios/awk.scr |    15 +
 .../bios_emulator/scitech/src/v86bios/cbios.c |   415 +
 .../scitech/src/v86bios/command.c             |    41 +
 .../scitech/src/v86bios/console.c             |   104 +
 .../bios_emulator/scitech/src/v86bios/debug.h |    62 +
 .../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   |   126 +
 .../scitech/src/v86bios/parser.y              |   498 +
 .../bios_emulator/scitech/src/v86bios/pci.c   |   903 ++
 .../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             |   215 +
 .../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         |    79 +
 .../scitech/src/x86emu/makefile.linux         |    81 +
 .../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        |   815 ++
 board/MAI/menu/cmd_menu.c                     |     9 +
 board/MAI/menu/menu.c                         |    66 +
 board/MAI/menu/menu.h                         |   174 +
 common/cmd_bootm.c                            |    11 +
 common/cmd_fdc.c                              |    62 +-
 common/cmd_ide.c                              |   193 +-
 common/cmd_nvedit.c                           |    12 +
 common/cmd_pci.c                              |     2 +-
 common/command.c                              |    11 +
 common/console.c                              |     4 +
 common/docecc.c                               |     2 -
 common/env_common.c                           |    13 +
 common/hush.c                                 |     5 -
 common/main.c                                 |    35 +
 cpu/74xx_7xx/cpu.c                            |    19 +-
 cpu/74xx_7xx/interrupts.c                     |     2 +-
 cpu/74xx_7xx/speed.c                          |     4 +
 cpu/74xx_7xx/traps.c                          |    21 +
 disk/Makefile                                 |     2 +-
 disk/part.c                                   |    28 +-
 disk/part_amiga.c                             |   399 +
 disk/part_amiga.h                             |   157 +
 disk/part_dos.h                               |     6 +
 disk/part_iso.c                               |     1 +
 disk/part_mac.h                               |     3 +
 doc/README.amigaone                           |    12 +
 drivers/pci.c                                 |    17 +-
 drivers/pci_auto.c                            |    32 +-
 examples/syscall.S                            |     2 +
 include/asm-ppc/global_data.h                 |     3 +
 include/cmd_boota.h                           |    42 +
 include/cmd_bsp.h                             |   110 +-
 include/cmd_confdefs.h                        |    51 +-
 include/cmd_menu.h                            |    42 +
 include/common.h                              |    12 +
 include/configs/AmigaOneG3SE.h                |   383 +
 include/configs/sbc8260.h                     |    79 +-
 include/part.h                                |     9 +
 include/pci.h                                 |     3 +-
 include/syscall.h                             |     7 +-
 lib_ppc/board.c                               |     6 +
 net/eth.c                                     |     4 +
 rtc/mc146818.c                                |    10 +-
 rtc/mk48t59.c                                 |    18 +
 tools/updater/Makefile                        |    86 +
 tools/updater/cmd_flash.c                     |   431 +
 tools/updater/ctype.c                         |    56 +
 tools/updater/dummy.c                         |     1 +
 tools/updater/flash.c                         |   184 +
 tools/updater/flash_hw.c                      |   660 +
 tools/updater/junk                            |     1 +
 tools/updater/ppcstring.S                     |   216 +
 tools/updater/string.c                        |   340 +
 tools/updater/update.c                        |    67 +
 tools/updater/utils.c                         |   148 +
 539 files changed, 118454 insertions(+), 138 deletions(-)
 create mode 100644 board/MAI/AmigaOneG3SE/AmigaOneG3SE.c
 create mode 100644 board/MAI/AmigaOneG3SE/Makefile
 create mode 100644 board/MAI/AmigaOneG3SE/articiaS.c
 create mode 100644 board/MAI/AmigaOneG3SE/articiaS.h
 create mode 100644 board/MAI/AmigaOneG3SE/articiaS_pci.c
 create mode 100644 board/MAI/AmigaOneG3SE/board_asm_init.S
 create mode 100644 board/MAI/AmigaOneG3SE/cmd_boota.c
 create mode 100644 board/MAI/AmigaOneG3SE/config.mk
 create mode 100644 board/MAI/AmigaOneG3SE/enet.c
 create mode 100644 board/MAI/AmigaOneG3SE/flash.c
 create mode 100644 board/MAI/AmigaOneG3SE/flash_new.c
 create mode 100644 board/MAI/AmigaOneG3SE/i8259.c
 create mode 100644 board/MAI/AmigaOneG3SE/i8259.h
 create mode 100644 board/MAI/AmigaOneG3SE/interrupts.c
 create mode 100644 board/MAI/AmigaOneG3SE/macros.h
 create mode 100644 board/MAI/AmigaOneG3SE/memio.S
 create mode 100644 board/MAI/AmigaOneG3SE/memio.h
 create mode 100644 board/MAI/AmigaOneG3SE/memory_dump
 create mode 100644 board/MAI/AmigaOneG3SE/nvram.c
 create mode 100644 board/MAI/AmigaOneG3SE/ps2kbd.c
 create mode 100644 board/MAI/AmigaOneG3SE/ps2kbd.h
 create mode 100644 board/MAI/AmigaOneG3SE/serial.c
 create mode 100644 board/MAI/AmigaOneG3SE/short_types.h
 create mode 100644 board/MAI/AmigaOneG3SE/smbus.c
 create mode 100644 board/MAI/AmigaOneG3SE/smbus.h
 create mode 100644 board/MAI/AmigaOneG3SE/start.txt
 create mode 100644 board/MAI/AmigaOneG3SE/todo.txt
 create mode 100644 board/MAI/AmigaOneG3SE/u-boot.lds
 create mode 100644 board/MAI/AmigaOneG3SE/usb_uhci.c
 create mode 100644 board/MAI/AmigaOneG3SE/usb_uhci.h
 create mode 100644 board/MAI/AmigaOneG3SE/via686.c
 create mode 100644 board/MAI/AmigaOneG3SE/via686.h
 create mode 100644 board/MAI/AmigaOneG3SE/video.c
 create mode 100644 board/MAI/bios_emulator/bios.c
 create mode 100644 board/MAI/bios_emulator/glue.c
 create mode 100644 board/MAI/bios_emulator/glue.h
 create mode 100644 board/MAI/bios_emulator/scitech/bin-linux/glibc/dmake
 create mode 100644 board/MAI/bios_emulator/scitech/bin-linux/glibc/k_cp
 create mode 100644 board/MAI/bios_emulator/scitech/bin-linux/glibc/k_echo
 create mode 100644 board/MAI/bios_emulator/scitech/bin-linux/glibc/k_rm
 create mode 100644 board/MAI/bios_emulator/scitech/bin-linux/glibc/makedep
 create mode 100644 board/MAI/bios_emulator/scitech/bin-linux/glibc/nasm
 create mode 100644 board/MAI/bios_emulator/scitech/bin-linux/glibc/ndisasm
 create mode 100644 board/MAI/bios_emulator/scitech/bin-linux/glibc/trans
 create mode 100644 board/MAI/bios_emulator/scitech/bin-linux/libc/dmake
 create mode 100644 board/MAI/bios_emulator/scitech/bin-linux/libc/nasm
 create mode 100644 board/MAI/bios_emulator/scitech/bin-linux/libc/ndisasm
 create mode 100644 board/MAI/bios_emulator/scitech/bin-linux/libc/trans
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc31-d16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc45-c32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc45-d16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc45-d32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc45-snp.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc45-tnt.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc45-vxd.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc45-w16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc45-w32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc50-c32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc50-d16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc50-d32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc50-smx.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc50-snp.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc50-tnt.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc50-vxd.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc50-w16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc50-w32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bc50-x11.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bcb5-c32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bcb5-d16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bcb5-d32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bcb5-smx.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bcb5-snp.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bcb5-tnt.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bcb5-vxd.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bcb5-w16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bcb5-w32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/bcb5-x11.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/build
 create mode 100644 board/MAI/bios_emulator/scitech/bin/build.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/build_db.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/build_it.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/cddrv.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/cdit
 create mode 100644 board/MAI/bios_emulator/scitech/bin/cdit.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/djgpp.env
 create mode 100644 board/MAI/bios_emulator/scitech/bin/djgpp_db.env
 create mode 100644 board/MAI/bios_emulator/scitech/bin/findint3.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/gcc-beos.sh
 create mode 100644 board/MAI/bios_emulator/scitech/bin/gcc-freebsd.sh
 create mode 100644 board/MAI/bios_emulator/scitech/bin/gcc-linux.sh
 create mode 100644 board/MAI/bios_emulator/scitech/bin/gcc2-c32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/gcc2-dos.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/gcc2-linux.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/gcc2-w32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/makelib.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/meltobjs.sh
 create mode 100644 board/MAI/bios_emulator/scitech/bin/ntddk.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/qnx4.sh
 create mode 100644 board/MAI/bios_emulator/scitech/bin/qnxnto.sh
 create mode 100644 board/MAI/bios_emulator/scitech/bin/set-vars-beos.sh
 create mode 100644 board/MAI/bios_emulator/scitech/bin/set-vars-freebsd.sh
 create mode 100644 board/MAI/bios_emulator/scitech/bin/set-vars-linux.sh
 create mode 100644 board/MAI/bios_emulator/scitech/bin/set-vars-qnx.sh
 create mode 100644 board/MAI/bios_emulator/scitech/bin/set-vars.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc40-c32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc40-d16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc40-drv9x.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc40-drvnt.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc40-snp.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc40-tnt.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc40-w16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc40-w32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc40-x11.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc50-c32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc50-d16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc50-drv9x.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc50-drvnt.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc50-rtt.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc50-snp.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc50-tnt.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc50-w16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc50-w32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc50-x11.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc60-c32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc60-d16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc60-drv9x.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc60-drvnt.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc60-drvw2k.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc60-snp.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc60-tnt.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc60-w16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc60-w32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/vc60-x11.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/w2kddk.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10-c32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10-d16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10-d32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10-o16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10-o32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10-p32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10-qnx.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10-snp.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10-tnt.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10-w16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10-w32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10-x11.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10ac32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10ad16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10ad32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10ao16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10ao32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10ap32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10asnp.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10atnt.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10aw16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc10aw32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc11-c32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc11-d16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc11-d32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc11-o16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc11-o32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc11-p32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc11-qnx.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc11-snp.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc11-tnt.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc11-w16.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc11-w32.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/wc11-x11.bat
 create mode 100644 board/MAI/bios_emulator/scitech/bin/win32sdk.bat
 create mode 100644 board/MAI/bios_emulator/scitech/include/biosemu.h
 create mode 100644 board/MAI/bios_emulator/scitech/include/event.h
 create mode 100644 board/MAI/bios_emulator/scitech/include/mtrr.h
 create mode 100644 board/MAI/bios_emulator/scitech/include/pcilib.h
 create mode 100644 board/MAI/bios_emulator/scitech/include/pm_help.h
 create mode 100644 board/MAI/bios_emulator/scitech/include/pm_wctl.h
 create mode 100644 board/MAI/bios_emulator/scitech/include/pmapi.h
 create mode 100644 board/MAI/bios_emulator/scitech/include/pmimp.h
 create mode 100644 board/MAI/bios_emulator/scitech/include/pmint.h
 create mode 100644 board/MAI/bios_emulator/scitech/include/scitech.h
 create mode 100644 board/MAI/bios_emulator/scitech/include/scitech.mac
 create mode 100644 board/MAI/bios_emulator/scitech/include/x86emu.h
 create mode 100644 board/MAI/bios_emulator/scitech/include/x86emu/fpu_regs.h
 create mode 100644 board/MAI/bios_emulator/scitech/include/x86emu/regs.h
 create mode 100644 board/MAI/bios_emulator/scitech/include/x86emu/types.h
 create mode 100644 board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/glibc/readme.txt
 create mode 100644 board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/libc/readme.txt
 create mode 100644 board/MAI/bios_emulator/scitech/lib/release/linux/gcc/glibc/readme.txt
 create mode 100644 board/MAI/bios_emulator/scitech/lib/release/linux/gcc/libc/readme.txt
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/bc16.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/bc3.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/bc32.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/bcos2.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/cl16.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/cl386.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/common.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/emx.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/gcc_beos.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/gcc_dos.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/gcc_freebsd.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/gcc_linux.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/gcc_win32.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/hc32.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/makedefs.prj
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/qnx4.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/qnxnto.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/bc16.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/bc3.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/bc32.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/bcos2.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/cl16.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/cl386.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/dj32.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/emx.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/gcc_beos.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/gcc_freebsd.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/gcc_linux.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/gcc_win32.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/hc32.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/qnx4.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/qnxnto.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/sc16.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/sc32.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/va32.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/va365.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/vc16.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/vc32.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/wc16.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/rules/wc32.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/sc16.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/sc32.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/startup.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/va32.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/va365.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/vc16.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/vc32.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/wc16.mk
 create mode 100644 board/MAI/bios_emulator/scitech/makedefs/wc32.mk
 create mode 100644 board/MAI/bios_emulator/scitech/src/biosemu/besys.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/biosemu/bios.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/biosemu/biosemu.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/biosemu/biosemui.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/biosemu/makefile
 create mode 100644 board/MAI/bios_emulator/scitech/src/biosemu/makefile.cross
 create mode 100644 board/MAI/bios_emulator/scitech/src/biosemu/warmboot.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/_aa_imp.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/_ga_imp.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/_gatimer.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/_pm_imp.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/aabeos.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/aados.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/aalib.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/aalinux.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/aaos2.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/aaqnx.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/aartt.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/aasmx.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/aavxd.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/aawin32.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/agplib.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/center.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/cmdline.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/gabeos.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/gados.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/galib.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/galinux.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/gantdrv.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/gaos2.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/gaqnx.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/gartt.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/gasmx.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/gavxd.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/gawin32.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/gtfcalc.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/libcimp.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/makefile
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/peloader.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/common/vesavbe.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/beos/cpuinfo.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/beos/event.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/beos/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/beos/pm.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/beos/vflat.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/beos/ztimer.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/codepage/us_eng.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/common.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/_cpuinfo.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/_dma.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/_int64.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/_joy.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/_mtrr.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/_pcihelp.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/agp.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/keyboard.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/malloc.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/mtrr.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/pcilib.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/unixio.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/common/vgastate.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/cpuinfo.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/debug.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/_event.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/_lztimer.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/_pm.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/_pmdos.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/_vflat.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/cpuinfo.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/event.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/pm.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/pmdos.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/vflat.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/dos/ztimer.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/event.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/linux/cpuinfo.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/linux/event.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/linux/event.svga
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/linux/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/linux/pm.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/linux/vflat.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/linux/ztimer.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/makefile
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/_irq.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/_pm.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/cpuinfo.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/int86.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/irq.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/mem.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/pm.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdio.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdlib.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/vflat.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/ntdrv/ztimer.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/_pmos2.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/cpuinfo.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/event.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/mon.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/pm.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/vflat.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2/ztimer.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2pm/event.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/os2pm/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/photon/event.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/photon/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/pm.vpw
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/pmcommon.vpj
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/pmdos.vpj
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/pmlinux.vpj
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/pmntdrv.vpj
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/pmqnx.vpj
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/pmvxd.vpj
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/pmwin32.vpj
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/_mtrrqnx.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/cpuinfo.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/event.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/mtrrqnx.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/pm.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/vflat.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/qnx/ztimer.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/rttarget/cpuinfo.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/rttarget/event.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/rttarget/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/rttarget/pm.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/rttarget/vflat.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/rttarget/ztimer.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/_event.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/_lztimer.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/_pm.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/_pmsmx.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/_vflat.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/cpuinfo.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/event.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/pm.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/pmsmx.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/vflat.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/smx/ztimer.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/stub/cpuinfo.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/stub/event.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/stub/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/stub/pm.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/stub/vflat.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/stub/ztimer.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/altbrk.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/altcrit.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/biosptr.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/block.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/brk.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/callreal.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/checks.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/cpu.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/critical.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/getch.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/isvesa.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/key.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/key15.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/memtest.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/mouse.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/restore.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/rtc.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/save.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/showpci.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/tick.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/timerc.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/timercpp.cpp
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/uswc.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/vftest.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/tests/video.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/vdd/cpuinfo.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/vdd/fileio.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/vdd/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/vdd/pm.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/vdd/vflat.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/vdd/ztimer.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/vxd/_pm.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/vxd/cpuinfo.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/vxd/fileio.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/vxd/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/vxd/pm.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/vxd/vflat.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/vxd/ztimer.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/_pmwin32.asm
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/cpuinfo.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/ddraw.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/event.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/ntservc.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/pm.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/vflat.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/win32/ztimer.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/x11/event.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/x11/oshdr.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/z_samples.vpj
 create mode 100644 board/MAI/bios_emulator/scitech/src/pm/ztimer.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/AsmMacros.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/README
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/awk.scr
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/cbios.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/command.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/console.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/debug.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/happy_cards
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/hexdump
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/int.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/io.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/lex.l
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/main.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/makefile.linux
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/mem.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/parser.y
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/pci.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/pci.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/v86.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/v86bios.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/v86bios.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/working_cards
 create mode 100644 board/MAI/bios_emulator/scitech/src/v86bios/x86emu.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/LICENSE
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/debug.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/decode.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/fpu.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/makefile
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/makefile.cross
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/makefile.linux
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/ops.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/ops2.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/prim_ops.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/sys.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/validate.c
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/x86emu/debug.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/x86emu/decode.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/x86emu/fpu.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/x86emu/ops.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/x86emu/prim_asm.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/x86emu/prim_ops.h
 create mode 100644 board/MAI/bios_emulator/scitech/src/x86emu/x86emu/x86emui.h
 create mode 100644 board/MAI/bios_emulator/x86interface.c
 create mode 100644 board/MAI/menu/cmd_menu.c
 create mode 100644 board/MAI/menu/menu.c
 create mode 100644 board/MAI/menu/menu.h
 create mode 100644 disk/part_amiga.c
 create mode 100644 disk/part_amiga.h
 create mode 100644 doc/README.amigaone
 create mode 100644 include/cmd_boota.h
 create mode 100644 include/cmd_menu.h
 create mode 100644 include/configs/AmigaOneG3SE.h
 create mode 100644 tools/updater/Makefile
 create mode 100644 tools/updater/cmd_flash.c
 create mode 100644 tools/updater/ctype.c
 create mode 100644 tools/updater/dummy.c
 create mode 100644 tools/updater/flash.c
 create mode 100644 tools/updater/flash_hw.c
 create mode 100644 tools/updater/junk
 create mode 100644 tools/updater/ppcstring.S
 create mode 100644 tools/updater/string.c
 create mode 100644 tools/updater/update.c
 create mode 100644 tools/updater/utils.c

diff --git a/CHANGELOG b/CHANGELOG
index 35c285db370..5b26e95abb3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,18 @@
 Changes since for U-Boot 0.1.0:
 ======================================================================
 
+* Patch by Thomas Frieden, 13 Nov 2002:
+  Add code for AmigaOne board
+  (preliminary merge to U-Boot, still WIP)
+
+* Patch by Jon Diekema, 12 Nov 2002:
+  - Adding URL for IEEE OUI lookup
+  - Making the autoboot #defines dependent on CONFIG_AUTOBOOT_KEYED
+    being defined.
+  - In the CONFIG_EXTRA_ENV_SETTINGS #define, the root-on-initrd and
+    root-on-nfs macros are designed to switch how the default boot
+    method gets defined.
+
 * Patch by Daniel Engström, 13 Nov 2002:
   Add support for i386 architecture and AMD SC520 board
 
diff --git a/CREDITS b/CREDITS
index 0f7d9656e53..d8c2a105326 100644
--- a/CREDITS
+++ b/CREDITS
@@ -92,6 +92,10 @@ E: wg@denx.de
 D: Support for Interphase 4539 T1/E1/J1 PMC, PN62, CCM, SCM boards
 W: www.denx.de
 
+N: Thomas Frieden
+E: ThomasF@hyperion-entertainment.com
+D: Support for AmigaOne
+
 N: Frank Gottschling
 E: fgottschling@eltec.de
 D: Support for ELTEC MHPC/BAB7xx/ELPPC boards, cfb-console, i8042, SMI LynxEM
diff --git a/MAINTAINERS b/MAINTAINERS
index c924c654037..969e0f83c3f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -33,7 +33,6 @@ Jerry Van Baren <vanbaren_gerald@si.com>
 
 Oliver Brown <obrown@adventnetworks.com>
 
-	sbc8260			MPC8260
 	gw8260			MPC8260
 
 Conn Clark <clark@esteem.com>
@@ -91,6 +90,10 @@ Dave Ellis <DGE@sixnetio.com>
 
 	SXNI855T		MPC8xx
 
+Thomas Frieden <ThomasF@hyperion-entertainment.com>
+
+	AmigaOneG3SE		MPC7xx
+
 Frank Gottschling <fgottschling@eltec.de>
 
 	MHPC			MPC8xx
diff --git a/Makefile b/Makefile
index d3e92f41187..ec2140034c6 100644
--- a/Makefile
+++ b/Makefile
@@ -564,6 +564,9 @@ TQM8260_300MHz_config:	unconfig
 ## 74xx/7xx Systems
 #########################################################################
 
+AmigaOneG3SE_config:	unconfig
+	@./mkconfig $(@:_config=) ppc 74xx_7xx AmigaOneG3SE MAI
+
 EVB64260_config	\
 EVB64260_750CX_config:	unconfig
 	@./mkconfig EVB64260 ppc 74xx_7xx evb64260
diff --git a/board/MAI/AmigaOneG3SE/AmigaOneG3SE.c b/board/MAI/AmigaOneG3SE/AmigaOneG3SE.c
new file mode 100644
index 00000000000..0cf5388a433
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/AmigaOneG3SE.c
@@ -0,0 +1,116 @@
+/*
+ * (C) Copyright 2002
+ * Hyperion Entertainment, ThomasF@hyperion-entertainment.com
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <pci.h>
+#include "articiaS.h"
+#include "memio.h"
+#include "via686.h"
+
+__asm(" .globl send_kb                                      \n
+        send_kb:                                            \n
+                lis     r9, 0xfe00                          \n
+                                                            \n
+                li      r4, 0x10        # retries           \n
+                mtctr   r4                                  \n
+                                                            \n
+        idle:                                               \n
+                lbz     r4, 0x64(r9)                        \n
+                andi.   r4, r4, 0x02                        \n
+                bne     idle                                \n
+                                                            \n
+        ready:                                              \n
+                stb     r3, 0x60(r9)                        \n
+                                                            \n
+        check:                                              \n
+                lbz     r4, 0x64(r9)                        \n
+                andi.   r4, r4, 0x01                        \n
+                beq     check                               \n
+                                                            \n
+                lbz     r4, 0x60(r9)                        \n
+                cmpwi   r4, 0xfa                            \n
+                beq     done                                \n
+                                                            \n
+                bdnz    idle                                \n
+                                                            \n
+                li      r3, 0                               \n
+                blr                                         \n
+                                                            \n
+        done:                                               \n
+                li      r3, 1                               \n
+                blr                                         \n
+                                                            \n
+        .globl test_kb                                      \n
+        test_kb:                                            \n
+                mflr    r10                                 \n
+	        li      r3, 0xed                            \n
+                bl      send_kb                             \n
+                li      r3, 0x01                            \n
+                bl      send_kb                             \n
+                mtlr    r10                                 \n
+                blr                                         \n
+");
+
+
+int checkboard (void)
+{
+	printf ("AmigaOneG3SE\n");
+
+	return 1;
+}
+
+long initdram (int board_type)
+{
+	return articiaS_ram_init ();
+}
+
+
+
+void after_reloc (ulong dest_addr)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+
+	board_init_r (gd, dest_addr);
+}
+
+
+int misc_init_r (void)
+{
+	extern pci_dev_t video_dev;
+	extern void drv_video_init (void);
+
+	if (video_dev != ~0)
+		drv_video_init ();
+
+	return (0);
+}
+
+
+void pci_init (void)
+{
+#ifndef CONFIG_RAMBOOT
+	articiaS_pci_init ();
+#endif
+}
diff --git a/board/MAI/AmigaOneG3SE/Makefile b/board/MAI/AmigaOneG3SE/Makefile
new file mode 100644
index 00000000000..727174640a7
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/Makefile
@@ -0,0 +1,53 @@
+#
+# (C) Copyright 2002
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= lib$(BOARD).a
+
+COBJS	= $(BOARD).o articiaS.o flash.o serial.o smbus.o articiaS_pci.o \
+		via686.o i8259.o ../bios_emulator/x86interface.o 	\
+		../bios_emulator/bios.o ../bios_emulator/glue.o		\
+		interrupts.o ps2kbd.o video.o usb_uhci.o enet.o	        \
+		../menu/cmd_menu.o cmd_boota.o nvram.o
+
+AOBJS	= board_asm_init.o memio.o
+
+OBJS	= $(COBJS) $(AOBJS) 
+
+## FIXME !!!
+# EMUOBJS = ../bios_emulator/scitech/src/x86emu/*.o
+
+
+$(LIB):	.depend $(OBJS) $(EMUOBJS)
+	-rm $(LIB)
+	$(AR) crv $@ $(OBJS) $(EMUOBJS)
+
+#########################################################################
+
+.depend: Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
+	$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+
+sinclude .depend
+
+#########################################################################
diff --git a/board/MAI/AmigaOneG3SE/articiaS.c b/board/MAI/AmigaOneG3SE/articiaS.c
new file mode 100644
index 00000000000..af85444f485
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/articiaS.c
@@ -0,0 +1,704 @@
+/*
+ * (C) Copyright 2002
+ * Hyperion Entertainment, ThomasF@hyperion-entertainment.com 
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <pci.h>
+#include <asm/processor.h>
+#include "memio.h"
+#include "articiaS.h"
+#include "smbus.h"
+#include "via686.h"
+
+#undef DEBUG
+
+struct dimm_bank {
+	uint8 used;			/* Bank is populated */
+	uint32 rows;			/* Number of row addresses */
+	uint32 columns;			/* Number of column addresses */
+	uint8 registered;		/* SIMM is registered */
+	uint8 ecc;			/* SIMM has ecc */
+	uint8 burst_len;		/* Supported burst lengths */
+	uint32 cas_lat;			/* Supported CAS latencies */
+	uint32 cas_used;		/* CAS to use (not set by user) */
+	uint32 trcd;			/* RAS to CAS latency */
+	uint32 trp;			/* Precharge latency */
+	uint32 tclk_hi;			/* SDRAM cycle time (highest CAS latency) */
+	uint32 tclk_2hi;		/* SDRAM second highest CAS latency */
+	uint32 size;			/* Size of bank in bytes */
+	uint8 auto_refresh;		/* Module supports auto refresh */
+	uint32 refresh_time;		/* Refresh time (in ns) */
+};
+
+
+/*
+** Based in part on the evb64260 code
+*/
+
+/*
+ * translate ns.ns/10 coding of SPD timing values
+ * into 10 ps unit values
+ */
+static inline unsigned short NS10to10PS (unsigned char spd_byte)
+{
+	unsigned short ns, ns10;
+
+	/* isolate upper nibble */
+	ns = (spd_byte >> 4) & 0x0F;
+	/* isolate lower nibble */
+	ns10 = (spd_byte & 0x0F);
+
+	return (ns * 100 + ns10 * 10);
+}
+
+/*
+ * translate ns coding of SPD timing values
+ * into 10 ps unit values
+ */
+static inline unsigned short NSto10PS (unsigned char spd_byte)
+{
+	return (spd_byte * 100);
+}
+
+
+long detect_sdram (uint8 * rom, int dimmNum, struct dimm_bank *banks)
+{
+	int dimm_address = (dimmNum == 0) ? SM_DIMM0_ADDR : SM_DIMM1_ADDR;
+	uint32 busclock = get_bus_freq (0);
+	uint32 memclock = busclock;
+	uint32 tmemclock = 1000000000 / (memclock / 100);
+	uint32 datawidth;
+
+	if (sm_get_data (rom, dimm_address) == 0) {
+		/* Nothing in slot, make both banks empty */
+		debug ("Slot %d: vacant\n", dimmNum);
+		banks[0].used = 0;
+		banks[1].used = 0;
+		return 0;
+	}
+
+	if (rom[2] != 0x04) {
+		debug ("Slot %d: No SDRAM\n", dimmNum);
+		banks[0].used = 0;
+		banks[1].used = 0;
+		return 0;
+	}
+
+	/* Determine number of banks/rows */
+	if (rom[5] == 1) {
+		banks[0].used = 1;
+		banks[1].used = 0;
+	} else {
+		banks[0].used = 1;
+		banks[1].used = 1;
+	}
+
+	/* Determine number of row addresses */
+	if (rom[3] & 0xf0) {
+		/* Different banks sizes */
+		banks[0].rows = rom[3] & 0x0f;
+		banks[1].rows = (rom[3] & 0xf0) >> 4;
+	} else {
+		/* Equal sized banks */
+		banks[0].rows = rom[3] & 0x0f;
+		banks[1].rows = banks[0].rows;
+	}
+
+	/* Determine number of column addresses */
+	if (rom[4] & 0xf0) {
+		/* Different bank sizes */
+		banks[0].columns = rom[4] & 0x0f;
+		banks[1].columns = (rom[4] & 0xf0) >> 4;
+	} else {
+		banks[0].columns = rom[4] & 0x0f;
+		banks[1].columns = banks[0].columns;
+	}
+
+	/* Check Jedec revision, and modify row/column accordingly */
+	if (rom[62] > 0x10) {
+		if (banks[0].rows <= 3)
+			banks[0].rows += 15;
+		if (banks[1].rows <= 3)
+			banks[1].rows += 15;
+		if (banks[0].columns <= 3)
+			banks[0].columns += 15;
+		if (banks[0].columns <= 3)
+			banks[0].columns += 15;
+	}
+
+	/* Check registered/unregisterd */
+	if (rom[21] & 0x12) {
+		banks[0].registered = 1;
+		banks[1].registered = 1;
+	} else {
+		banks[0].registered = 0;
+		banks[1].registered = 0;
+	}
+
+#ifdef CONFIG_ECC
+	/* Check parity/ECC */
+	banks[0].ecc = (rom[11] == 0x02);
+	banks[1].ecc = (rom[11] == 0x02);
+#endif
+
+	/* Find burst lengths supported */
+	banks[0].burst_len = rom[16] & 0x8f;
+	banks[1].burst_len = rom[16] & 0x8f;
+
+	/* Find possible cas latencies */
+	banks[0].cas_lat = rom[18] & 0x7F;
+	banks[1].cas_lat = rom[18] & 0x7F;
+
+	/* RAS/CAS latency */
+	banks[0].trcd = (NSto10PS (rom[29]) + (tmemclock - 1)) / tmemclock;
+	banks[1].trcd = (NSto10PS (rom[29]) + (tmemclock - 1)) / tmemclock;
+
+	/* Precharge latency */
+	banks[0].trp = (NSto10PS (rom[27]) + (tmemclock - 1)) / tmemclock;
+	banks[1].trp = (NSto10PS (rom[27]) + (tmemclock - 1)) / tmemclock;
+
+	/* highest CAS latency */
+	banks[0].tclk_hi = NS10to10PS (rom[9]);
+	banks[1].tclk_hi = NS10to10PS (rom[9]);
+
+	/* second highest CAS latency */
+	banks[0].tclk_2hi = NS10to10PS (rom[23]);
+	banks[1].tclk_2hi = NS10to10PS (rom[23]);
+
+	/* bank sizes */
+	datawidth = rom[13] & 0x7f;
+	banks[0].size =
+			(1L << (banks[0].rows + banks[0].columns)) *
+			/* FIXME datawidth */ 8 * rom[17];
+	if (rom[13] & 0x80)
+		banks[1].size = 2 * banks[0].size;
+	else
+		banks[1].size = (1L << (banks[1].rows + banks[1].columns)) *
+				/* FIXME datawidth */ 8 * rom[17];
+
+	/* Refresh */
+	if (rom[12] & 0x80) {
+		banks[0].auto_refresh = 1;
+		banks[1].auto_refresh = 1;
+	} else {
+		banks[0].auto_refresh = 0;
+		banks[1].auto_refresh = 0;
+	}
+
+	switch (rom[12] & 0x7f) {
+	case 0:
+		banks[0].refresh_time = (1562500 + (tmemclock - 1)) / tmemclock;
+		banks[1].refresh_time = (1562500 + (tmemclock - 1)) / tmemclock;
+		break;
+	case 1:
+		banks[0].refresh_time = (390600 + (tmemclock - 1)) / tmemclock;
+		banks[1].refresh_time = (390600 + (tmemclock - 1)) / tmemclock;
+		break;
+	case 2:
+		banks[0].refresh_time = (781200 + (tmemclock - 1)) / tmemclock;
+		banks[1].refresh_time = (781200 + (tmemclock - 1)) / tmemclock;
+		break;
+	case 3:
+		banks[0].refresh_time = (3125000 + (tmemclock - 1)) / tmemclock;
+		banks[1].refresh_time = (3125000 + (tmemclock - 1)) / tmemclock;
+		break;
+	case 4:
+		banks[0].refresh_time = (6250000 + (tmemclock - 1)) / tmemclock;
+		banks[1].refresh_time = (6250000 + (tmemclock - 1)) / tmemclock;
+		break;
+	case 5:
+		banks[0].refresh_time = (12500000 + (tmemclock - 1)) / tmemclock;
+		banks[1].refresh_time = (12500000 + (tmemclock - 1)) / tmemclock;
+		break;
+	default:
+		banks[0].refresh_time = 0x100;	/* Default of Articia S */
+		banks[1].refresh_time = 0x100;
+		break;
+	}
+
+#ifdef DEBUG
+	printf ("\nInformation for SIMM bank %ld:\n", dimmNum);
+	printf ("Number of banks: %ld\n", banks[0].used + banks[1].used);
+	printf ("Number of row addresses: %ld\n", banks[0].rows);
+	printf ("Number of coumns addresses: %ld\n", banks[0].columns);
+	printf ("SIMM is %sregistered\n",
+			banks[0].registered == 0 ? "not " : "");
+#ifdef CONFIG_ECC
+	printf ("SIMM %s ECC\n",
+			banks[0].ecc == 1 ? "supports" : "doesn't support");
+#endif
+	printf ("Supported burst lenghts: %s %s %s %s %s\n",
+			banks[0].burst_len & 0x08 ? "8" : " ",
+			banks[0].burst_len & 0x04 ? "4" : " ",
+			banks[0].burst_len & 0x02 ? "2" : " ",
+			banks[0].burst_len & 0x01 ? "1" : " ",
+			banks[0].burst_len & 0x80 ? "PAGE" : "    ");
+	printf ("Supported CAS latencies: %s %s %s\n",
+			banks[0].cas_lat & 0x04 ? "CAS 3" : "     ",
+			banks[0].cas_lat & 0x02 ? "CAS 2" : "     ",
+			banks[0].cas_lat & 0x01 ? "CAS 1" : "     ");
+	printf ("RAS to CAS latency: %ld\n", banks[0].trcd);
+	printf ("Precharge latency: %ld\n", banks[0].trp);
+	printf ("SDRAM highest CAS latency: %ld\n", banks[0].tclk_hi);
+	printf ("SDRAM 2nd highest CAS latency: %ld\n", banks[0].tclk_2hi);
+	printf ("SDRAM data width: %ld\n", datawidth);
+	printf ("Auto Refresh %ssupported\n",
+			banks[0].auto_refresh ? "" : "not ");
+	printf ("Refresh time: %ld clocks\n", banks[0].refresh_time);
+	if (banks[0].used)
+		printf ("Bank 0 size: %ld MB\n", banks[0].size / 1024 / 1024);
+	if (banks[1].used)
+		printf ("Bank 1 size: %ld MB\n", banks[1].size / 1024 / 1024);
+
+	printf ("\n");
+#endif
+
+	sm_term ();
+	return 1;
+}
+
+void select_cas (struct dimm_bank *banks, uint8 fast)
+{
+	if (!banks[0].used) {
+		banks[0].cas_used = 0;
+		banks[0].cas_used = 0;
+		return;
+	}
+
+	if (fast) {
+		/* Search for fast CAS */
+		uint32 i;
+		uint32 c = 0x01;
+
+		for (i = 1; i < 5; i++) {
+			if (banks[0].cas_lat & c) {
+				banks[0].cas_used = i;
+				banks[1].cas_used = i;
+				debug ("Using CAS %d (fast)\n", i);
+				return;
+			}
+			c <<= 1;
+		}
+
+		/* Default to CAS 3 */
+		banks[0].cas_used = 3;
+		banks[1].cas_used = 3;
+		debug ("Using CAS 3 (fast)\n");
+
+		return;
+	} else {
+		/* Search for slow cas */
+		uint32 i;
+		uint32 c = 0x08;
+
+		for (i = 4; i > 1; i--) {
+			if (banks[0].cas_lat & c) {
+				banks[0].cas_used = i;
+				banks[1].cas_used = i;
+				debug ("Using CAS %d (slow)\n", i);
+				return;
+			}
+			c >>= 1;
+		}
+
+		/* Default to CAS 3 */
+		banks[0].cas_used = 3;
+		banks[1].cas_used = 3;
+		debug ("Using CAS 3 (slow)\n");
+
+		return;
+	}
+
+	banks[0].cas_used = 3;
+	banks[1].cas_used = 3;
+	debug ("Using CAS 3\n");
+
+	return;
+}
+
+uint32 get_reg_setting (uint32 banks, uint32 rows, uint32 columns, uint32 size)
+{
+	uint32 i;
+
+	struct RowColumnSize {
+		uint32 banks;
+		uint32 rows;
+		uint32 columns;
+		uint32 size;
+		uint32 register_value;
+	};
+
+	struct RowColumnSize rcs_map[] = {
+		/*  Sbk Radr Cadr   MB     Value */
+		{1, 11, 8, 8, 0x00840f00},
+		{1, 11, 9, 16, 0x00925f00},
+		{1, 11, 10, 32, 0x00a64f00},
+		{2, 12, 8, 32, 0x00c55f00},
+		{2, 12, 9, 64, 0x00d66f00},
+		{2, 12, 10, 128, 0x00e77f00},
+		{2, 12, 11, 256, 0x00ff8f00},
+		{2, 13, 11, 512, 0x00ff9f00},
+		{0, 0, 0, 0, 0x00000000}
+	};
+
+
+	i = 0;
+
+	while (rcs_map[i].banks != 0) {
+		if (rows == rcs_map[i].rows
+			&& columns == rcs_map[i].columns
+			&& (size / 1024 / 1024) == rcs_map[i].size)
+			return rcs_map[i].register_value;
+
+		i++;
+	}
+
+	return 0;
+}
+
+uint32 burst_to_len (uint32 support)
+{
+	if (support & 0x80)
+		return 0x7;
+	else if (support & 0x8)
+		return 0x3;
+	else if (support & 0x4)
+		return 0x2;
+	else if (support & 0x2)
+		return 0x1;
+	else if (support & 0x1)
+		return 0x0;
+
+	return 0;
+}
+
+long articiaS_ram_init (void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+
+	register uint32 i;
+	register uint32 value1;
+	register uint32 value2;
+	uint8 rom[128];
+	uint32 burst_len;
+	uint32 burst_support;
+	uint32 total_ram = 0;
+
+	struct dimm_bank banks[4];	/* FIXME: Move to initram */
+	uint32 busclock = get_bus_freq (0);
+	uint32 memclock = busclock;
+	uint32 reg32;
+	uint32 refresh_clocks;
+	uint8 auto_refresh;
+
+	memset (banks, 0, sizeof (struct dimm_bank) * 4);
+
+	detect_sdram (rom, 0, &banks[0]);
+	detect_sdram (rom, 1, &banks[2]);
+
+	for (i = 0; i < 4; i++) {
+		total_ram = total_ram + (banks[i].used * banks[i].size);
+	}
+
+	pci_write_cfg_long (0, 0, GLOBALINFO0, 0x117430c0);
+	pci_write_cfg_long (0, 0, HBUSACR0, 0x1f0100b0);
+	pci_write_cfg_long (0, 0, SRAM_CR, 0x00f12000);	/* Note: Might also try 0x00f10000 (original: 0x00f12000) */
+	pci_write_cfg_byte (0, 0, DRAM_RAS_CTL0, 0x3f);
+	pci_write_cfg_byte (0, 0, DRAM_RAS_CTL1, 0x00);	/*  was: 0x04); */
+	pci_write_cfg_word (0, 0, DRAM_ECC0, 0x2020);	/*  was: 0x2400);  No ECC yet */
+
+	/* FIXME: Move this stuff to seperate function, like setup_dimm_bank */
+	if (banks[0].used) {
+		value1 = get_reg_setting (banks[0].used + banks[1].used,
+					  banks[0].rows, banks[0].columns,
+					  banks[0].size);
+	} else {
+		value1 = 0;
+	}
+
+	if (banks[1].used) {
+		value2 = get_reg_setting (banks[0].used + banks[1].used,
+					  banks[1].rows, banks[1].columns,
+					  banks[1].size);
+	} else {
+		value2 = 0;
+	}
+
+	pci_write_cfg_long (0, 0, DIMM0_B0_SCR0, value1);
+	pci_write_cfg_long (0, 0, DIMM0_B1_SCR0, value2);
+
+	debug ("DIMM0_B0_SCR0 = 0x%08x\n", value1);
+	debug ("DIMM0_B1_SCR0 = 0x%08x\n", value2);
+
+	if (banks[2].used) {
+		value1 = get_reg_setting (banks[2].used + banks[3].used,
+					  banks[2].rows, banks[2].columns,
+					  banks[2].size);
+	} else {
+		value1 = 0;
+	}
+
+	if (banks[3].used) {
+		value2 = get_reg_setting (banks[2].used + banks[3].used,
+					  banks[3].rows, banks[3].columns,
+					  banks[3].size);
+	} else {
+		value2 = 0;
+	}
+
+	pci_write_cfg_long (0, 0, DIMM1_B2_SCR0, value1);
+	pci_write_cfg_long (0, 0, DIMM1_B3_SCR0, value2);
+
+	debug ("DIMM0_B2_SCR0 = 0x%08x\n", value1);
+	debug ("DIMM0_B3_SCR0 = 0x%08x\n", value2);
+
+	pci_write_cfg_long (0, 0, DIMM2_B4_SCR0, 0);
+	pci_write_cfg_long (0, 0, DIMM2_B5_SCR0, 0);
+	pci_write_cfg_long (0, 0, DIMM3_B6_SCR0, 0);
+	pci_write_cfg_long (0, 0, DIMM3_B7_SCR0, 0);
+
+	/* Determine timing */
+	select_cas (&banks[0], 0);
+	select_cas (&banks[2], 0);
+
+	/* FIXME: What about write recovery */
+	/*                    Auto refresh    Precharge */
+#if 0
+	reg32 = (0x3 << 13) | (0x7 << 10) | ((banks[0].trp - 2) << 8) |
+	/*    Write recovery  CAS Latency */
+		(0x1 << 6) | (banks[0].cas_used << 4) |
+	/*      RAS/CAS latency */
+		((banks[0].trcd - 1) << 0);
+
+	reg32 |= ((0x3 << 13) | (0x7 << 10) | ((banks[2].trp - 2) << 8) |
+		  (0x1 << 6) | (banks[2].cas_used << 4) |
+		  ((banks[2].trcd - 1) << 0)) << 16;
+#else
+	if (100000000 == gd->bus_clk)
+		reg32 = 0x71737173;
+	else
+		reg32 = 0x69736973;
+#endif
+	pci_write_cfg_long (0, 0, DIMM0_TCR0, reg32);
+	debug ("DIMM0_TCR0 = 0x%08x\n", reg32);
+
+	/* Write default in DIMM2/3 (not used on A1) */
+	pci_write_cfg_long (0, 0, DIMM2_TCR0, 0x7d737d73);
+
+
+	/* Determine buffered/unbuffered mode for each SIMM. Uses first bank as reference (second, if present, uses the same) */
+	reg32 = pci_read_cfg_long (0, 0, DRAM_GCR0);
+	reg32 &= 0xFF00FFFF;
+
+#if 0
+	if (banks[0].used && banks[0].registered)
+		reg32 |= 0x1 << 16;
+
+	if (banks[2].used && banks[2].registered)
+		reg32 |= 0x1 << 18;
+#else
+	if (banks[0].registered || banks[2].registered)
+		reg32 |= 0x55 << 16;
+#endif
+	pci_write_cfg_long (0, 0, DRAM_GCR0, reg32);
+	debug ("DRAM_GCR0 = 0x%08x\n", reg32);
+
+	/* Determine refresh */
+	refresh_clocks = 0xffffffff;
+	auto_refresh = 1;
+
+	for (i = 0; i < 4; i++) {
+		if (banks[i].used) {
+			if (banks[i].auto_refresh == 0)
+				auto_refresh = 0;
+			if (banks[i].refresh_time < refresh_clocks)
+				refresh_clocks = banks[i].refresh_time;
+		}
+	}
+
+
+#if 1
+	/*  It seems this is suggested by the ArticiaS data book */
+	if (100000000 == gd->bus_clk)
+		refresh_clocks = 1561;
+	else
+		refresh_clocks = 2083;
+#endif
+
+
+	debug ("Refresh set to %ld clocks, auto refresh %s\n",
+		   refresh_clocks, auto_refresh ? "on" : "off");
+
+	pci_write_cfg_long (0, 0, DRAM_REFRESH0,
+			(1 << 16) | (1 << 15) | (auto_refresh << 12) |
+			(refresh_clocks));
+	debug ("DRAM_REFRESH0 = 0x%08x\n",
+			(1 << 16) | (1 << 15) | (auto_refresh << 12) |
+			(refresh_clocks));
+
+/*     pci_write_cfg_long(0, 0, DRAM_REFRESH0,   0x00019400);  */
+
+	/* Set mode registers */
+	/* FIXME: For now, set same burst len for all modules. Dunno if that's necessary */
+	/* Find a common burst len */
+	burst_support = 0xff;
+
+	if (banks[0].used)
+		burst_support = banks[0].burst_len;
+	if (banks[1].used)
+		burst_support = banks[1].burst_len;
+	if (banks[2].used)
+		burst_support = banks[2].burst_len;
+	if (banks[3].used)
+		burst_support = banks[3].burst_len;
+
+	/* 
+	   ** Mode register:
+	   ** Bits         Use
+	   ** 0-2          Burst len
+	   ** 3            Burst type (0 = sequential, 1 = interleave)
+	   ** 4-6          CAS latency
+	   ** 7-8          Operation mode (0 = default, all others invalid)
+	   ** 9            Write burst
+	   ** 10-11        Reserved
+	   **
+	   ** Mode register burst table:
+	   ** A2 A1 A0     lenght
+	   ** 0  0  0      1
+	   ** 0  0  1      2
+	   ** 0  1  0      4
+	   ** 0  1  1      8
+	   ** 1  0  0      invalid
+	   ** 1  0  1      invalid
+	   ** 1  1  0      invalid
+	   ** 1  1  1      page (only valid for non-interleaved)
+	 */
+
+	burst_len = burst_to_len (burst_support);
+	burst_len = 2;				/* FIXME */
+
+	if (banks[0].used) {
+		pci_write_cfg_word (0, 0, DRAM_PCR0,
+			0x8000 | burst_len | (banks[0].cas_used << 4));
+		debug ("Mode bank 0: 0x%08x\n",
+			0x8000 | burst_len | (banks[0].cas_used << 4));
+	} else {
+		/*  Seems to be needed to disable the bank */
+		pci_write_cfg_word (0, 0, DRAM_PCR0, 0x0000 | 0x032);
+	}
+
+	if (banks[1].used) {
+		pci_write_cfg_word (0, 0, DRAM_PCR0,
+			0x9000 | burst_len | (banks[1].cas_used << 4));
+		debug ("Mode bank 1: 0x%08x\n",
+			0x8000 | burst_len | (banks[1].cas_used << 4));
+	} else {
+		/*  Seems to be needed to disable the bank */
+		pci_write_cfg_word (0, 0, DRAM_PCR0, 0x1000 | 0x032);
+	}
+
+
+	if (banks[2].used) {
+		pci_write_cfg_word (0, 0, DRAM_PCR0,
+			0xa000 | burst_len | (banks[2].cas_used << 4));
+		debug ("Mode bank 2: 0x%08x\n",
+			0x8000 | burst_len | (banks[2].cas_used << 4));
+	} else {
+		/*  Seems to be needed to disable the bank */
+		pci_write_cfg_word (0, 0, DRAM_PCR0, 0x2000 | 0x032);
+	}
+
+
+	if (banks[3].used) {
+		pci_write_cfg_word (0, 0, DRAM_PCR0,
+			0xb000 | burst_len | (banks[3].cas_used << 4));
+		debug ("Mode bank 3: 0x%08x\n",
+			0x8000 | burst_len | (banks[3].cas_used << 4));
+	} else {
+		/*  Seems to be needed to disable the bank */
+		pci_write_cfg_word (0, 0, DRAM_PCR0, 0x3000 | 0x032);
+	}
+
+
+	pci_write_cfg_word (0, 0, 0xba, 0x00);
+
+	return total_ram;
+}
+
+extern int drv_isa_kbd_init (void);
+
+int last_stage_init (void)
+{
+	drv_isa_kbd_init ();
+	return 0;
+}
+
+int overwrite_console (void)
+{
+	return (0);
+}
+
+#define in_8 read_byte
+#define out_8 write_byte
+
+static __inline__ unsigned long get_msr (void)
+{
+	unsigned long msr;
+
+	asm volatile ("mfmsr %0":"=r" (msr):);
+
+	return msr;
+}
+
+static __inline__ void set_msr (unsigned long msr)
+{
+	asm volatile ("mtmsr %0"::"r" (msr));
+}
+
+int board_pre_init (void)
+{
+	unsigned char c_value = 0;
+	unsigned long msr;
+
+	/* Basic init of PS/2 keyboard (needed for some reason)... */
+	/* Ripped from John's code */
+	while ((in_8 ((unsigned char *) 0xfe000064) & 0x02) != 0);
+	out_8 ((unsigned char *) 0xfe000064, 0xaa);
+	while ((in_8 ((unsigned char *) 0xfe000064) & 0x01) == 0);
+	c_value = in_8 ((unsigned char *) 0xfe000060);
+	while ((in_8 ((unsigned char *) 0xfe000064) & 0x02) != 0);
+	out_8 ((unsigned char *) 0xfe000064, 0xab);
+	while ((in_8 ((unsigned char *) 0xfe000064) & 0x01) == 0);
+	c_value = in_8 ((unsigned char *) 0xfe000060);
+	while ((in_8 ((unsigned char *) 0xfe000064) & 0x02) != 0);
+	out_8 ((unsigned char *) 0xfe000064, 0xae);
+/*     while ((in_8((unsigned char *)0xfe000064) & 0x01) == 0); */
+/*     c_value = in_8((unsigned char *)0xfe000060); */
+
+	/*  Enable FPU */
+	msr = get_msr ();
+	set_msr (msr | MSR_FP);
+
+	via_calibrate_bus_freq ();
+
+	return 0;
+}
diff --git a/board/MAI/AmigaOneG3SE/articiaS.h b/board/MAI/AmigaOneG3SE/articiaS.h
new file mode 100644
index 00000000000..158d70ab8eb
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/articiaS.h
@@ -0,0 +1,143 @@
+#ifndef ARTICIAS_H
+#define ARTICIAS_H
+
+#include "short_types.h"
+#include <common.h>
+
+#define REG_GROUP       0xF0
+
+/* ArticiaS registers */
+#define GLOBALINFO0     0x50
+#define GLOBALINFO1     0x51
+#define GLOBALINFO2     0x52
+#define GLOBALINFO3     0x53
+#define GLOBALCTL0      0x54
+#define GLOBALCTL1      0x55
+#define NVRAMCTL        0x56
+#define PCI1ACR0        0x58
+#define PCI1ACR1        0x59
+#define PCI1ACR2        0x5a
+#define PCI1ACR3        0x5b
+#define HBUSACR0        0x5c
+#define HBUSACR1        0x5d
+#define HBUSACR2        0x5e
+#define HBUSACR3        0x5f
+#define HOSTINT0        0x68
+#define HOSTINT1        0x69
+#define HOSTINT2        0x6a
+#define HOSTINT3        0x6b
+#define HOSTRBCR        0x70
+#define XDBCR           0x74
+
+#define LBSBCR2         0xd2
+
+
+/* Memory controller */
+
+#define DIMM0_B0_SCR0   0x90
+#define DIMM0_B1_SCR0   0x94
+#define DIMM1_B2_SCR0   0x98
+#define DIMM1_B3_SCR0   0x9c
+#define DIMM2_B4_SCR0   0xa0
+#define DIMM2_B5_SCR0   0xa4
+#define DIMM3_B6_SCR0   0xa8
+#define DIMM3_B7_SCR0   0xac
+
+#define DIMM0_TCR0      0xb0
+#define DIMM1_TCR0      0xb2
+#define DIMM2_TCR0      0xb4
+#define DIMM3_TCR0      0xb6
+
+#define DRAM_REFRESH0   0xb8
+#define DRAM_GCR0       0xc0
+#define DRAM_PCR0       0xc6
+#define DRAM_ECC0       0xc4
+#define SRAM_CR         0xc8
+#define DRAM_RAS_CTL0   0xcc
+#define DRAM_RAS_CTL1   0xcd
+
+/* Bits for REG_GROUP */
+#define REG_GROUP_MULTI       (1<<1)
+#define REG_GROUP_SPECIAL     (1<<3)
+#define REG_GROUP_DIAG        (0x1<<4)
+#define REG_GROUP_POWER       (0x2<<4)
+
+
+#define GLOBALINFO0_BO        (1<<7)
+
+
+#define GLOBALINFO2_B1ARBITER (1<<6)
+
+
+#define HBUSACR0_CPUAPC       (1<<0)
+#define HBUSACR0_NUMREQ_2     (0<<1)
+#define HBUSACR0_NUMREQ_3     (1<<1)
+#define HBUSACR0_NUMREQ_4     (2<<1)
+#define HBUSACR0_NUMREQ_MASK  (7<<1)
+#define HBUSACR0_RAW          (1<<6)
+#define HBUSACR0_WAIT         (1<<7)
+#define HBUSACR0_RESERVED     (0x30)
+
+
+#define HBUSACR2_BURST        (1<<0)
+#define HBUSACR2_LAT          (1<<1)
+
+
+#define HBUSACR3_LMWC_SM      (1<<0)
+#define HBUSACR3_LMWC_PCI1    (1<<1)
+#define HBUSACR3_LMWC_PCI0    (1<<2)
+#define HBUSACR3_PMWC_PCI1    (1<<3)
+#define HBUSACR3_PMWC_PCI0    (1<<4)
+#define HBUSACR3_FKH          (1<<5)
+#define HBUSACR3_92H_EN       (1<<6)
+#define HBUSACR3_60H_64H_EN   (1<<7)
+
+
+#define HOSTRBCR_PREFETCH     (1<<4)
+
+
+#define XDBCR_HWTOXD          (1<<0)
+#define XDBCR_KBTOXD          (1<<1)
+#define XDBCR_RTCTOXD         (1<<2)
+#define XDBCR_SCALE_1_1       (0x0<<3)       
+#define XDBCR_SCALE_2_2       (0x1<<3)       
+#define XDBCR_SCALE_3_2       (0x2<<3)       
+#define XDBCR_SCALE_4_4       (0x3<<3)       
+#define XDBCR_SCALE_5_8       (0x4<<3)       
+#define XDBCR_SCALE_6_8       (0x5<<3)       
+#define XDBCR_SCALE_8_8       (0x6<<3)       
+#define XDBCR_SCALE_0_16      (0x7<<3)       
+#define XDBCR_XDPROM          (1<<7)
+
+
+#define LBSBCR2_1_RWAC        (1<<2)
+
+
+/* PCI controller */
+#define ARTICIAS_PCI_CFGADDR  0xfec00cf8
+#define ARTICIAS_PCI_CFGDATA  0xfee00cfc
+
+#define ARTICIAS_PCI_BUS       0x80000000
+#define ARTICIAS_PCI_MAXSIZE   0x7cffffff
+#define ARTICIAS_PCI_PHYS      0x80000000
+
+#define ARTICIAS_SYS_BUS       0x00000000
+#define ARTICIAS_SYS_MAXSIZE   0x7fffffff
+#define ARTICIAS_SYS_PHYS      0x00000000
+
+#define ARTICIAS_PCIIO_BUS     0x00800000
+#define ARTICIAS_PCIIO_MAXSIZE 0x003fffff
+#define ARTICIAS_PCIIO_PHYS    0xfe800000
+
+#define ARTICIAS_ISAIO_BUS     0x00002000
+#define ARTICIAS_ISAIO_MAXSIZE 0x0000d000
+#define ARTICIAS_ISAIO_PHYS    0xfe002000
+
+
+
+/* Prototypes */
+long articiaS_ram_init(void);
+void articiaS_pci_init(void);
+
+
+#endif
diff --git a/board/MAI/AmigaOneG3SE/articiaS_pci.c b/board/MAI/AmigaOneG3SE/articiaS_pci.c
new file mode 100644
index 00000000000..774c32dd08c
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/articiaS_pci.c
@@ -0,0 +1,573 @@
+/*
+ * (C) Copyright 2002
+ * Hyperion Entertainment, Hans-JoergF@hyperion-entertainment.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <pci.h>
+#include "memio.h"
+#include "articiaS.h"
+
+//#define ARTICIA_PCI_DEBUG
+
+#ifdef  ARTICIA_PCI_DEBUG
+#define PRINTF(fmt,args...)     printf (fmt ,##args)
+#else
+#define PRINTF(fmt,args...)
+#endif
+
+struct pci_controller articiaS_hose;
+
+long irq_alloc(long wanted);
+
+static pci_dev_t pci_hose_find_class(struct pci_controller *hose, int bus, short find_class, int index);
+static int articiaS_init_vga(void);
+static void pci_cfgfunc_dummy(struct pci_controller *host, pci_dev_t dev, struct pci_config_table *table);
+unsigned char pci_irq_alloc(void);
+
+extern void via_cfgfunc_via686(struct pci_controller * host, pci_dev_t dev, struct pci_config_table *table);
+extern void via_cfgfunc_ide_init(struct pci_controller *host, pci_dev_t dev, struct pci_config_table *table);
+extern void via_init_irq_routing(uint8 []);
+extern void via_init_afterscan(void);
+
+#define cfgfunc_via686      1
+#define cfgfunc_dummy  2
+#define cfgfunc_ide_init    3
+
+static struct pci_config_table config_table[] =
+{
+    {
+	0x1106, PCI_ANY_ID, PCI_CLASS_BRIDGE_ISA, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
+	(void *)cfgfunc_via686, {0, 0, 0}
+    },
+    {
+	0x1106, PCI_ANY_ID, PCI_ANY_ID, 0,7,4,
+	(void *)cfgfunc_dummy, {0,0,0}
+    },
+    {
+	0x1106, 0x3068, PCI_ANY_ID, 0, 7, PCI_ANY_ID,
+	(void *)cfgfunc_dummy, {0,0,0}
+    },
+    {
+	0x1106, PCI_ANY_ID, PCI_ANY_ID, 0,7,1,
+	(void *)cfgfunc_ide_init, {0,0,0}
+    },
+    {
+	0,
+    }
+};
+
+
+void pci_cfgfunc_dummy(struct pci_controller *host, pci_dev_t dev, struct pci_config_table *table)
+{
+
+
+}
+
+unsigned long irq_penalties[16] =
+{
+    1000,    /* 0:timer */
+    1000,    /* 1:keyboard */
+    1000,    /* 2:cascade */
+    50,      /* 3:serial (COM2) */
+    50,      /* 4:serial (COM1) */
+    4,       /* 5:USB2 */
+    100,     /* 6:floppy */
+    3,       /* 7:parallel */
+    50,      /* 8:AC97/MC97 */
+    0,       /* 9: */
+    3,       /* 10:: */
+    0,       /* 11: */
+    3,       /* 12: USB1 */
+    0,       /* 13: */
+    100,     /* 14: ide0 */
+    100,     /* 15: ide1 */
+};
+
+
+/*
+ * The following defines a hard-coded interrupt mapping for the
+ * know devices on the board.
+ * If a device isn't found here, assumed to be a device that's
+ * plugged into a PCI or AGP slot
+ * NOTE: This table is machine dependant.
+ */
+
+struct pci_irq_fixup_table
+{
+    uint8   bus;             /* Bus number */
+    uint8   device;          /* Device number */
+    uint8   func;            /* Function number */
+    uint8   interrupt;       /* Interrupt to use (0xff to disable) */
+};
+
+struct pci_irq_fixup_table fixuptab [] =
+{
+    { 0, 0, 0, 0xff},        /* Articia S host bridge */
+    { 0, 1, 0, 0xff},        /* Articia S AGP bridge */
+//    { 0, 6, 0, 0x05},        /* 3COM ethernet */
+    { 0, 7, 0, 0xff},        /* VIA southbridge */
+    { 0, 7, 1, 0x0e},        /* IDE controller in legacy mode */
+//    { 0, 7, 2, 0x05},        /* First USB controller */
+//    { 0, 7, 3, 0x0c},        /* Second USB controller (shares interrupt with ethernet) */
+    { 0, 7, 4, 0xff},        /* ACPI Power Management */
+//    { 0, 7, 5, 0x08},        /* AC97 */
+//    { 0, 7, 6, 0x08},        /* MC97 */
+    { 0xff, 0xff, 0xff, 0xff}
+};
+
+
+/*
+ * This table maps IRQ's to PCI interrupts
+ */
+
+uint8 pci_intmap[4] = {0, 0, 0, 0};
+
+/*
+ * Map PCI slots to interrupt routings
+ * This table lists the device number assigned to a card inserted
+ * into the slot, along with a permutation for the slot's IRQ routing.
+ * NOTE: This table is machine dependant.
+ */
+
+struct pci_slot_irq_routing
+{
+    uint8 bus;
+    uint8 device;
+
+    uint8 ints[4];
+};
+
+struct pci_slot_irq_routing amigaone_pci_routing[] =
+{
+    {0,  8,   {0, 1, 2, 3}},       /* Slot 1 (left of riser slot) */
+    {0,  9,   {1, 2, 3, 0}},       /* Slot 2 (middle slot) */
+    {0, 10,   {2, 3, 0, 1}},       /* Slot 3 (leftmost slot) */
+    {1,  0,   {1, 0, 2, 3}},       /* AGP slot (only IRQA and IRQB) */
+    {1,  1,   {1, 2, 3, 0}},       /* PCI slot on AGP bus */
+    {0,  6,   {3, 3, 3, 3}},       /* On board ethernet */
+    {0,  7,   {0, 1, 2, 3}},       /* Southbridge */
+    {0xff, 0, {0, 0, 0, 0}}
+};
+
+void articiaS_pci_irq_init(void)
+{
+    char *s;
+
+    s = getenv("pci_irqa");
+    if (s)
+	pci_intmap[0] = simple_strtoul (s, NULL, 10);
+    else
+	pci_intmap[0] = pci_irq_alloc();
+
+    s = getenv("pci_irqb");
+    if (s)
+	pci_intmap[1] = simple_strtoul (s, NULL, 10);
+    else
+	pci_intmap[1] = pci_irq_alloc();
+
+    s = getenv("pci_irqc");
+    if (s)
+	pci_intmap[2] = simple_strtoul (s, NULL, 10);
+    else
+	pci_intmap[2] = pci_irq_alloc();
+
+    s = getenv("pci_irqd");
+    if (s)
+	pci_intmap[3] = simple_strtoul (s, NULL, 10);
+    else
+	pci_intmap[3] = pci_irq_alloc();
+}
+
+
+unsigned char pci_irq_alloc(void)
+{
+    int i;
+    int interrupt = 10;
+    unsigned long min_penalty = 1000;
+
+    /* Search for the minimal penalty, favoring interrupts at the end */
+    for (i = 0; i < 16; i++)
+    {
+	if (irq_penalties[i] <= min_penalty)
+	{
+	    interrupt = i;
+	    min_penalty = irq_penalties[i];
+	}
+    }
+
+    PRINTF("pci_irq_alloc: Minimal penalty is %ld for %d\n", min_penalty, interrupt);
+
+    irq_penalties[interrupt]++;
+
+    return interrupt;
+}
+
+
+void articiaS_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
+{
+    int8 bus, device, func, pin, line;
+    int i;
+
+    bus = PCI_BUS(dev);
+    device = PCI_DEV(dev);
+    func = PCI_FUNC(dev);
+
+    PRINTF("Fixup irq of %d:%d.%d\n", bus, device, func);
+
+    /* Search for the device in the table */
+    for (i = 0; fixuptab[i].bus != 0xff; i++)
+    {
+	if (bus == fixuptab[i].bus && device == fixuptab[i].device && func == fixuptab[i].func)
+	{
+	    /* If the device needs an interrupt, write it */
+	    if (fixuptab[i].interrupt != 0xff)
+	    {
+		PRINTF("Assigning IRQ %d (fixed)\n", fixuptab[i].interrupt);
+		pci_write_config_byte(dev, PCI_INTERRUPT_LINE, fixuptab[i].interrupt);
+	    }
+	    else
+	    {
+		/* Otherwise, see if it wants an interrupt, and disable it if needed */
+		pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
+		if (pin)
+		{
+		    PRINTF("Disabling IRQ\n");
+		    pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 0xff);
+		}
+	    }
+
+	    return;
+	}
+    }
+
+    /* If we get here, we have another PCI device in a slot... find the appropriate IRQ */
+
+    /* Find matching pin */
+    pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
+    pin--;
+
+    /* Search for it's map */
+    for (i = 0; amigaone_pci_routing[i].bus != 0xff; i++)
+    {
+	if (bus == amigaone_pci_routing[i].bus && device == amigaone_pci_routing[i].device)
+	{
+	    line = pci_intmap[amigaone_pci_routing[i].ints[pin]];
+	    PRINTF("Assigning IRQ %d (pin %d)\n", line, pin);
+	    pci_write_config_byte(dev, PCI_INTERRUPT_LINE, line);
+	    return;
+	}
+    }
+
+    PRINTF("Unkonwn PCI device found\n");
+}
+
+void articiaS_pci_init (void)
+{
+    int i;
+    char *s;
+
+    PRINTF("atriciaS_pci_init\n");
+
+    // Why aren't these relocated??
+    for (i=0; config_table[i].config_device; i++)
+    {
+	switch((int)config_table[i].config_device)
+	{
+	case cfgfunc_via686:     config_table[i].config_device = via_cfgfunc_via686;      break;
+	case cfgfunc_dummy:      config_table[i].config_device = pci_cfgfunc_dummy;       break;
+	case cfgfunc_ide_init:   config_table[i].config_device = via_cfgfunc_ide_init;    break;
+	default: PRINTF("Error: Unknown constant\n");
+	}
+    }
+
+    articiaS_hose.first_busno = 0;
+    articiaS_hose.last_busno = 0xff;
+    articiaS_hose.config_table = config_table;
+    articiaS_hose.fixup_irq = articiaS_pci_fixup_irq;
+
+    articiaS_pci_irq_init();
+
+    /* System memory */
+    pci_set_region(articiaS_hose.regions + 0,
+		   ARTICIAS_SYS_BUS,
+		   ARTICIAS_SYS_PHYS,
+		   ARTICIAS_SYS_MAXSIZE,
+		   PCI_REGION_MEM | PCI_REGION_MEMORY);
+
+    /* PCI memory space */
+    pci_set_region(articiaS_hose.regions + 1,
+		   ARTICIAS_PCI_BUS,
+		   ARTICIAS_PCI_PHYS,
+		   ARTICIAS_PCI_MAXSIZE,
+		   PCI_REGION_MEM);
+
+    /* PCI io space */
+    pci_set_region(articiaS_hose.regions + 2,
+		   ARTICIAS_PCIIO_BUS,
+		   ARTICIAS_PCIIO_PHYS,
+		   ARTICIAS_PCIIO_MAXSIZE,
+		   PCI_REGION_IO);
+
+    /* PCI/ISA io space */
+    pci_set_region(articiaS_hose.regions + 3,
+		   ARTICIAS_ISAIO_BUS,
+		   ARTICIAS_ISAIO_PHYS,
+		   ARTICIAS_ISAIO_MAXSIZE,
+		   PCI_REGION_IO);
+
+
+
+    articiaS_hose.region_count = 4;
+
+    pci_setup_indirect(&articiaS_hose, ARTICIAS_PCI_CFGADDR, ARTICIAS_PCI_CFGDATA);
+    PRINTF("Registering articia hose...\n");
+    pci_register_hose(&articiaS_hose);
+    PRINTF("Enabling AGP...\n");
+    pci_write_config_byte(PCI_BDF(0,0,0), 0x58, 0x01);
+    PRINTF("Scanning bus...\n");
+    articiaS_hose.last_busno = pci_hose_scan(&articiaS_hose);
+
+    via_init_irq_routing(pci_intmap);
+
+    PRINTF("After-Scan results:\n");
+    PRINTF("Bus range: %d - %d\n", articiaS_hose.first_busno , articiaS_hose.last_busno);
+
+    via_init_afterscan();
+
+    pci_write_config_byte(PCI_BDF(0,1,0), PCI_INTERRUPT_LINE, 0xFF);
+
+    s = getenv("as_irq");
+    if (s)
+    {
+	pci_write_config_byte(PCI_BDF(0,0,0), PCI_INTERRUPT_LINE, simple_strtoul (s, NULL, 10));
+    }
+
+    s = getenv("x86_run_bios");
+    if (!s || (s && strcmp(s, "on")==0))
+    {
+	if (articiaS_init_vga() == -1)
+	{
+	    /* If the VGA didn't init and we have stdout set to VGA, reset to serial */
+/* 	    s = getenv("stdout"); */
+/* 	    if (s && strcmp(s, "vga") == 0) */
+/* 	    { */
+/* 		setenv("stdout", "serial"); */
+/* 	    } */
+	}
+    }
+    pci_write_config_byte(PCI_BDF(0,1,0), PCI_INTERRUPT_LINE, 0xFF);
+
+}
+
+pci_dev_t pci_hose_find_class(struct pci_controller *hose, int bus, short find_class, int index)
+{
+    unsigned int sub_bus, found_multi=0;
+    unsigned short vendor, class;
+    unsigned char header_type;
+    pci_dev_t dev;
+    u8 c1, c2;
+
+    sub_bus = bus;
+
+    for (dev =  PCI_BDF(bus,0,0);
+	 dev <  PCI_BDF(bus,PCI_MAX_PCI_DEVICES-1,PCI_MAX_PCI_FUNCTIONS-1);
+	 dev += PCI_BDF(0,0,1))
+    {
+	if ( dev == PCI_BDF(hose->first_busno,0,0) )
+	    continue;
+
+	if (PCI_FUNC(dev) && !found_multi)
+	    continue;
+
+	pci_hose_read_config_byte(hose, dev, PCI_HEADER_TYPE, &header_type);
+
+	pci_hose_read_config_word(hose, dev, PCI_VENDOR_ID, &vendor);
+
+	if (vendor != 0xffff && vendor != 0x0000)
+	{
+
+	    if (!PCI_FUNC(dev))
+		found_multi = header_type & 0x80;
+	    pci_hose_read_config_byte(hose, dev, 0x0B, &c1);
+	    pci_hose_read_config_byte(hose, dev, 0x0A, &c2);
+	    class = c1<<8 | c2;
+	    //printf("At %02x:%02x:%02x: class %x\n",
+	    //	   PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev), class);
+	    if (class == find_class)
+	    {
+		if (index == 0)
+		    return dev;
+		else index--;
+	    }
+	}
+    }
+
+    return ~0;
+}
+
+
+/*
+ * For a given bus number, find the bridge on this hose that provides this
+ * bus number. The function scans for bridges and peeks config space offset
+ * 0x19 (PCI_SECONDARY_BUS).
+ */
+pci_dev_t pci_find_bridge_for_bus(struct pci_controller *hose, int busnr)
+{
+    pci_dev_t dev;
+    int bus;
+    unsigned int found_multi=0;
+    unsigned char header_type;
+    unsigned short vendor;
+    unsigned char secondary_bus;
+
+    if (hose == NULL) hose = &articiaS_hose;
+
+    if (busnr < hose->first_busno || busnr > hose->last_busno) return PCI_ANY_ID; // Not in range
+
+    /*
+     * The bridge must be on a lower bus number
+     */
+    for (bus = hose->first_busno; bus < busnr; bus++)
+    {
+	for (dev =  PCI_BDF(bus,0,0);
+	     dev <  PCI_BDF(bus,PCI_MAX_PCI_DEVICES-1,PCI_MAX_PCI_FUNCTIONS-1);
+	     dev += PCI_BDF(0,0,1))
+	{
+	    if ( dev == PCI_BDF(hose->first_busno,0,0) )
+		continue;
+
+	    if (PCI_FUNC(dev) && !found_multi)
+		continue;
+
+	    pci_hose_read_config_byte(hose, dev, PCI_HEADER_TYPE, &header_type);
+
+	    pci_hose_read_config_word(hose, dev, PCI_VENDOR_ID, &vendor);
+
+	    if (vendor != 0xffff && vendor != 0x0000)
+	    {
+
+		if (!PCI_FUNC(dev))
+		    found_multi = header_type & 0x80;
+		if (header_type == 1) // Bridge device header
+		{
+		    pci_hose_read_config_byte(hose, dev, PCI_SECONDARY_BUS, &secondary_bus);
+		    if ((int)secondary_bus == busnr) return dev;
+		}
+
+	    }
+	}
+    }
+    return PCI_ANY_ID;
+}
+
+static short classes[] =
+{
+    PCI_CLASS_DISPLAY_VGA,
+    PCI_CLASS_DISPLAY_XGA,
+    PCI_CLASS_DISPLAY_3D,
+    PCI_CLASS_DISPLAY_OTHER,
+    ~0
+};
+
+extern int execute_bios(pci_dev_t gr_dev, void *);
+
+pci_dev_t video_dev;
+
+int articiaS_init_vga (void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+
+    extern void shutdown_bios(void);
+    pci_dev_t dev = ~0;
+    int busnr = 0;
+    int classnr = 0;
+
+    video_dev = PCI_ANY_ID;
+
+    printf("VGA:   ");
+
+    PRINTF("Trying to initialize x86 VGA Card(s)\n");
+
+    while (dev == ~0)
+    {
+	PRINTF("Searching for class 0x%x on bus %d\n", classes[classnr], busnr);
+	/* Find the first of this class on this bus */
+	dev = pci_hose_find_class(&articiaS_hose, busnr, classes[classnr], 0);
+	if (dev != ~0) break;
+	busnr++;
+	if (busnr > articiaS_hose.last_busno)
+	{
+	    busnr = 0;
+	    classnr ++;
+	    if (classes[classnr] == ~0)
+	    {
+		printf("NOT PRESENT\n");
+		return -1;
+	    }
+	}
+    }
+
+    /*
+     * If we get here we have found the first graphics card.
+     * If the bus number is not 0, then it is probably behind a bridge, and the
+     * bridge needs to be told to forward VGA access.
+     */
+
+    if (PCI_BUS(dev) != 0)
+    {
+	pci_dev_t bridge;
+	PRINTF("Behind bridge, looking for bridge\n");
+	bridge = pci_find_bridge_for_bus(&articiaS_hose, PCI_BUS(dev));
+	if (dev != PCI_ANY_ID)
+	{
+	    unsigned char agp_control_0;
+	    PRINTF("Got the bridge at %02x:%02x:%02x\n",
+		   PCI_BUS(bridge), PCI_DEV(bridge), PCI_FUNC(bridge));
+	    pci_hose_read_config_byte(&articiaS_hose, bridge, 0x3E, &agp_control_0);
+	    agp_control_0 |= 0x18;
+	    pci_hose_write_config_byte(&articiaS_hose, bridge, 0x3E, agp_control_0);
+	    PRINTF("Configured for VGA forwarding\n");
+	}
+    }
+
+    /*
+     * Now try to run the bios
+     */
+
+    if (execute_bios(dev, gd->relocaddr))
+    {
+	printf("OK\n");
+	video_dev = dev;
+    }
+    else
+    {
+	printf("ERROR\n");
+    }
+
+    PRINTF("Done scanning.\n");
+
+    shutdown_bios();
+
+    if (dev == PCI_ANY_ID) return -1;
+    else return 0;
+
+}
diff --git a/board/MAI/AmigaOneG3SE/board_asm_init.S b/board/MAI/AmigaOneG3SE/board_asm_init.S
new file mode 100644
index 00000000000..a421c5dc435
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/board_asm_init.S
@@ -0,0 +1,157 @@
+	#include	"macros.h"
+	
+	
+
+#define GLOBALINFO0	      0x50	
+#define GLOBALINFO0_BO        (1<<7)
+#define GLOBALINFO2_B1ARBITER (1<<6)
+#define HBUSACR0              0x5c
+#define HBUSACR2_BURST        (1<<0)
+#define HBUSACR2_LAT          (1<<1)
+	
+#define RECEIVER_HOLDING 0
+#define TRANSMITTER_HOLDING 0
+#define INTERRUPT_ENABLE 1
+#define INTERRUPT_STATUS 2
+#define FIFO_CONTROL 2
+#define LINE_CONTROL 3
+#define MODEM_CONTROL 4
+#define LINE_STATUS 5
+#define MODEM_STATUS 6
+#define SCRATCH_PAD 7
+
+#define DIVISOR_LATCH_LSB 0
+#define DIVISOR_LATCH_MSB 1
+#define PRESCALER_DIVISION 5
+
+#define UART(x) (0x3f8+(x))
+
+#define GLOBALINFO0           0x50
+#define GLOBALINFO0_BO        (1<<7)
+#define GLOBALINFO2_B1ARBITER (1<<6)
+#define HBUSACR0              0x5c
+#define HBUSACR2_BURST        (1<<0)
+#define HBUSACR2_LAT          (1<<1)
+
+#define SUPERIO_1               ((7 << 3) | (0))
+#define SUPERIO_2               ((7 << 3) | (1))
+	
+	.globl	board_asm_init
+	
+board_asm_init:
+	mflr	r29
+	/* Set 'Must-set' register */
+	li	r3, 0
+	li	r4, 0
+	li	r5, 0x5e
+	bl	pci_read_cfg_byte
+	ori	r3, r3, (1<<1)
+	xori	r6, r3, (1<<1)
+	li	r3, 0
+	bl	pci_write_cfg_byte
+
+	li	r3, 0
+	li	r5, 0x52
+	bl	pci_read_cfg_byte
+	ori	r6, r3, (1<<6)
+	li	r3, 0
+	bl	pci_write_cfg_byte
+
+	li	r3, 0
+	li	r4, 0x08
+	li	r5, 0xd2
+	bl	pci_read_cfg_byte
+	ori	r6, r3, (1<<2)
+	li	r3, 0
+	bl	pci_write_cfg_byte
+
+
+	/* Do PCI reset */
+/*	li	r3, 0
+	li	r4, 0x38
+	li	r5, 0x47
+	bl	pci_read_cfg_byte
+	ori	r6, r3, 0x01
+	li	r3, 0
+	li	r4, 0x38
+	li	r5, 0x47
+	bl	pci_write_cfg_byte*/
+
+	
+	/* Enable NVRAM for environment */
+	li	r3, 0
+	li	r4, 0
+	li	r5, 0x56
+	li	r6, 0x0B
+	bl	pci_write_cfg_byte
+
+
+	/* Init Super-I/O chips */
+
+	siowb	0x40, 0x08
+	siowb	0x41, 0x01
+	siowb	0x45, 0x80
+	siowb	0x46, 0x60	
+	siowb	0x47, 0x20
+	siowb	0x48, 0x01
+	siowb	0x4a, 0xc4
+	siowb	0x50, 0x0e
+	siowb	0x51, 0x76
+	siowb	0x52, 0x34
+	siowb	0x54, 0x00
+	siowb	0x55, 0x90
+	siowb	0x56, 0x99
+	siowb	0x57, 0x90
+	siowb	0x85, 0x01
+		
+	/* Enable configuration mode for SuperIO */
+	li	r3, 0
+	li	r4, (7<<3)
+	li	r5, 0x85
+	bl	pci_read_cfg_byte
+	ori	r6, r3, 0x02
+	mr	r31, r6
+	li	r3,0
+	bl	pci_write_cfg_byte
+
+	/* COM1 as 3f8 */
+	outb	0x3f0, 0xe7
+	outb	0x3f1, 0xfe
+
+	/* COM2 as 2f8 */
+	outb	0x3f0, 0xe8
+	outb	0x3f1, 0xeb
+
+	/* Enable */
+	outb	0x3f0, 0xe2
+	inb	r3, 0x3f1
+	ori	r3, r3, 0x0c
+	outb	0x3f0, 0xe2
+	outbr	0x3f1, r3
+	
+	/* Disable configuration mode */
+	li	r3, 0
+	li	r4, (7<<3)
+	li	r5, 0x85
+	mr	r6, r31
+	bl	pci_write_cfg_byte
+
+	/* Set line control */
+	outb	UART(LINE_CONTROL), 0x83
+	outb	UART(DIVISOR_LATCH_LSB), 0x0c
+	outb	UART(DIVISOR_LATCH_MSB), 0x00
+	outb	UART(LINE_CONTROL), 0x3
+
+	mtlr	r29
+	blr
+
+		
+	.globl	new_reset
+	.globl	new_reset_end
+new_reset:
+	li	r0, 0x100
+	oris	r0, r0, 0xFFF0
+	mtlr	r0
+	blr
+	
+new_reset_end:	
\ No newline at end of file
diff --git a/board/MAI/AmigaOneG3SE/cmd_boota.c b/board/MAI/AmigaOneG3SE/cmd_boota.c
new file mode 100644
index 00000000000..140aaff0447
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/cmd_boota.c
@@ -0,0 +1,123 @@
+#include <common.h>
+#include <command.h>
+#include <cmd_boota.h>
+#include "../disk/part_amiga.h"
+#include <asm/cache.h>
+
+
+#undef BOOTA_DEBUG
+
+#ifdef BOOTA_DEBUG
+#define PRINTF(fmt,args...)	printf (fmt ,##args)
+#else
+#define PRINTF(fmt,args...)
+#endif
+
+struct block_header {
+	u32 id;
+	u32 summed_longs;
+	s32 chk_sum;
+};
+
+extern block_dev_desc_t *ide_get_dev (int dev);
+extern struct bootcode_block *get_bootcode (block_dev_desc_t * dev_desc);
+extern int sum_block (struct block_header *header);
+
+struct bootcode_block bblk;
+
+int do_boota (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+	unsigned char *load_address = (unsigned char *) CFG_LOAD_ADDR;
+	unsigned char *base_address;
+	unsigned long offset;
+
+	unsigned long part_number = 0;
+	block_dev_desc_t *boot_disk;
+	char *s;
+	struct bootcode_block *boot_code;
+
+	/* Get parameters */
+
+	switch (argc) {
+	case 2:
+		load_address = (unsigned char *) simple_strtol (argv[1], NULL, 16);
+		part_number = 0;
+		break;
+	case 3:
+		load_address = (unsigned char *) simple_strtol (argv[1], NULL, 16);
+		part_number = simple_strtol (argv[2], NULL, 16);
+		break;
+	}
+
+	base_address = load_address;
+
+	PRINTF ("Loading boot code from disk %d to %p\n", part_number,
+			load_address);
+
+	/* Find the appropriate disk device */
+	boot_disk = ide_get_dev (part_number);
+	if (!boot_disk) {
+		PRINTF ("Unknown disk %d\n", part_number);
+		return 1;
+	}
+
+	/* Find the bootcode block */
+	boot_code = get_bootcode (boot_disk);
+	if (!boot_code) {
+		PRINTF ("Not a bootable disk %d\n", part_number);
+		return 1;
+	}
+
+	/* Only use the offset from the first block */
+	offset = boot_code->load_data[0];
+	memcpy (load_address, &boot_code->load_data[1], 122 * 4);
+	load_address += 122 * 4;
+
+	/* Setup for the loop */
+	bblk.next = boot_code->next;
+	boot_code = &bblk;
+
+	/* Scan the chain, and copy the loader succesively into the destination area */
+	while (0xffffffff != boot_code->next) {
+		PRINTF ("Loading block %d\n", boot_code->next);
+
+		/* Load block */
+		if (1 !=
+			boot_disk->block_read (boot_disk->dev, boot_code->next, 1,
+								   (ulong *) & bblk)) {
+			PRINTF ("Read error\n");
+			return 1;
+		}
+
+		/* check sum */
+		if (sum_block ((struct block_header *) (ulong *) & bblk) != 0) {
+			PRINTF ("Checksum error\n");
+			return 1;
+		}
+
+		/* Ok, concatenate it to the already loaded code */
+		memcpy (load_address, boot_code->load_data, 123 * 4);
+		load_address += 123 * 4;
+	}
+
+	printf ("Bootcode loaded to %p (size %d)\n", base_address,
+			load_address - base_address);
+	printf ("Entry point at %p\n", base_address + offset);
+
+	flush_cache (base_address, load_address - base_address);
+
+
+	s = getenv ("autostart");
+	if (s && strcmp (s, "yes") == 0) {
+		DECLARE_GLOBAL_DATA_PTR;
+
+		void (*boot) (bd_t *, char *, block_dev_desc_t *);
+		char *args;
+
+		boot = (void (*)(bd_t *, char *, block_dev_desc_t *)) (base_address + offset);
+		boot (gd->bd, getenv ("amiga_bootargs"), boot_disk);
+	}
+
+
+	return 0;
+}
diff --git a/board/MAI/AmigaOneG3SE/config.mk b/board/MAI/AmigaOneG3SE/config.mk
new file mode 100644
index 00000000000..0537cd977ad
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/config.mk
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2002
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+#
+# AmigaOneG3SE boards
+#
+
+X86EMU =  -I../bios_emulator/scitech/include -I../bios_emulator/scitech/src/x86emu
+
+TEXT_BASE = 0xfff00000
+
+PLATFORM_CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE) -Wa,-mregnames -DEASTEREGG $(X86EMU) #-DDEBUG
+
diff --git a/board/MAI/AmigaOneG3SE/enet.c b/board/MAI/AmigaOneG3SE/enet.c
new file mode 100644
index 00000000000..0aaa8bf6396
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/enet.c
@@ -0,0 +1,886 @@
+/*
+ * (C) Copyright 2002
+ * Adam Kowalczyk, ACK Software Controls Inc. akowalczyk@cogeco.ca
+ *
+ * Some portions taken from 3c59x.c Written 1996-1999 by Donald Becker.
+ *
+ * Outline of the program based on eepro100.c which is
+ *
+ * (C) Copyright 2002
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <net.h>
+#include <asm/io.h>
+#include <pci.h>
+
+#include "articiaS.h"
+#include "memio.h"
+
+/* 3Com Ethernet PCI definitions*/
+
+// #define PCI_VENDOR_ID_3COM		0x10B7
+#define PCI_DEVICE_ID_3COM_3C905C	0x9200
+
+/* 3Com Commands, top 5 bits are command and bottom 11 bits are parameters */
+
+#define TotalReset 		(0<<11) 
+#define SelectWindow 		(1<<11)
+#define StartCoax 		(2<<11)
+#define RxDisable 		(3<<11) 
+#define RxEnable 		(4<<11) 
+#define RxReset 		(5<<11)
+#define UpStall 		(6<<11) 
+#define UpUnstall 		(6<<11)+1
+#define DownStall 		(6<<11)+2 
+#define DownUnstall 		(6<<11)+3
+#define RxDiscard 		(8<<11)
+#define TxEnable 		(9<<11)
+#define TxDisable 		(10<<11) 
+#define TxReset 		(11<<11)
+#define FakeIntr 		(12<<11) 
+#define AckIntr 		(13<<11) 
+#define SetIntrEnb 		(14<<11)
+#define SetStatusEnb 		(15<<11) 
+#define SetRxFilter 		(16<<11)
+#define SetRxThreshold 		(17<<11)
+#define SetTxThreshold 		(18<<11) 
+#define SetTxStart 		(19<<11)
+#define StartDMAUp 		(20<<11)
+#define StartDMADown 		(20<<11)+1
+#define StatsEnable		(21<<11)
+#define StatsDisable		(22<<11) 
+#define StopCoax 		(23<<11)
+#define SetFilterBit 		(25<<11)
+
+/* The SetRxFilter command accepts the following classes */
+
+#define RxStation 		1 
+#define RxMulticast		2 
+#define RxBroadcast		4 
+#define RxProm 			8
+
+/* 3Com status word defnitions */
+
+#define IntLatch 		0x0001
+#define HostError 		0x0002
+#define TxComplete 		0x0004
+#define TxAvailable 		0x0008
+#define RxComplete 		0x0010 
+#define RxEarly 		0x0020
+#define IntReq 			0x0040
+#define StatsFull 		0x0080
+#define DMADone 		(1<<8)
+#define DownComplete 		(1<<9) 
+#define UpComplete 		(1<<10)
+#define DMAInProgress 		(1<<11)			/* DMA controller is still busy.*/
+#define CmdInProgress 		(1<<12)           	/* EL3_CMD is still busy.*/
+
+/* Polling Registers */
+
+#define DnPoll			0x2d
+#define UpPoll			0x3d
+
+/* Register window 0 offets */
+
+#define Wn0EepromCmd 		10	          	/* Window 0: EEPROM command register. */
+#define Wn0EepromData 		12             		/* Window 0: EEPROM results register. */
+#define IntrStatus		0x0E	                /* Valid in all windows. */
+
+/* Register window 0 EEPROM bits */
+
+#define EEPROM_Read 		0x80
+#define EEPROM_WRITE 		0x40
+#define EEPROM_ERASE 		0xC0
+#define EEPROM_EWENB 		0x30            	/* Enable erasing/writing for 10 msec. */
+#define EEPROM_EWDIS 		0x00            	/* Disable EWENB before 10 msec timeout. */
+
+/* EEPROM locations. */
+
+#define PhysAddr01		0 
+#define PhysAddr23		1
+#define PhysAddr45		2 
+#define ModelID			3
+#define EtherLink3ID		7 
+#define IFXcvrIO		8 
+#define IRQLine			9
+#define NodeAddr01		10 
+#define NodeAddr23		11 
+#define NodeAddr45		12
+#define DriverTune		13 
+#define Checksum		15
+
+/* Register window 1 offsets, the window used in normal operation */
+
+#define TX_FIFO 		0x10  
+#define RX_FIFO 		0x10  
+#define RxErrors 		0x14
+#define RxStatus 		0x18  
+#define Timer			0x1A 
+#define TxStatus 		0x1B
+#define TxFree 			0x1C	 		/* Remaining free bytes in Tx buffer. */
+
+/* Register Window 2 */
+        
+#define Wn2_ResetOptions	12
+
+/* Register Window 3: MAC/config bits */
+
+#define Wn3_Config		0			/* Internal Configuration */
+#define Wn3_MAC_Ctrl		6
+#define Wn3_Options		8
+
+#define BFEXT(value, offset, bitcount)  					\
+    	((((unsigned long)(value)) >> (offset)) & ((1 << (bitcount)) - 1))
+
+#define BFINS(lhs, rhs, offset, bitcount)                                       \
+        (((lhs) & ~((((1 << (bitcount)) - 1)) << (offset))) |   		\
+        (((rhs) & ((1 << (bitcount)) - 1)) << (offset)))
+
+#define RAM_SIZE(v)             BFEXT(v, 0, 3)
+#define RAM_WIDTH(v)    	BFEXT(v, 3, 1)
+#define RAM_SPEED(v)    	BFEXT(v, 4, 2)
+#define ROM_SIZE(v)             BFEXT(v, 6, 2)
+#define RAM_SPLIT(v)    	BFEXT(v, 16, 2)
+#define XCVR(v)                 BFEXT(v, 20, 4)
+#define AUTOSELECT(v)   	BFEXT(v, 24, 1)
+
+/* Register Window 4: Xcvr/media bits */
+        
+#define Wn4_FIFODiag 		4
+#define Wn4_NetDiag 		6
+#define Wn4_PhysicalMgmt	8
+#define Wn4_Media 		10
+
+#define Media_SQE 		0x0008     		/* Enable SQE error counting for AUI. */
+#define Media_10TP 		0x00C0			/* Enable link beat and jabber for 10baseT. */
+#define Media_Lnk 		0x0080			/* Enable just link beat for 100TX/100FX. */
+#define Media_LnkBeat 		0x0800
+
+/* Register Window 7: Bus Master control */
+
+#define Wn7_MasterAddr 		0
+#define Wn7_MasterLen 		6
+#define Wn7_MasterStatus 	12
+
+/* Boomerang bus master control registers. */
+
+#define PktStatus 		0x20
+#define DownListPtr		0x24
+#define FragAddr 		0x28
+#define FragLen 		0x2c
+#define TxFreeThreshold 	0x2f
+#define UpPktStatus 		0x30
+#define UpListPtr 		0x38
+
+/* The Rx and Tx descriptor lists. */
+
+#define LAST_FRAG       0x80000000                      /* Last Addr/Len pair in descriptor. */
+#define DN_COMPLETE     0x00010000                      /* This packet has been downloaded */
+
+struct rx_desc_3com {
+        u32 next;                                       /* Last entry points to 0	   	*/
+        u32 status;					/* FSH -> Frame Start Header 		*/
+        u32 addr;                                       /* Up to 63 addr/len pairs possible 	*/
+        u32 length;                                     /* Set LAST_FRAG to indicate last pair	*/
+};
+
+/* Values for the Rx status entry. */
+
+#define RxDComplete		0x00008000
+#define RxDError		0x4000
+#define IPChksumErr		(1<<25) 
+#define TCPChksumErr		(1<<26) 
+#define UDPChksumErr		(1<<27)
+#define IPChksumValid		(1<<29) 
+#define TCPChksumValid		(1<<30)
+#define UDPChksumValid		(1<<31)
+
+struct tx_desc_3com {
+        u32 next;                                       /* Last entry points to 0		*/
+        u32 status;                                     /* bits 0:12 length, others see below	*/
+        u32 addr;
+        u32 length;
+};
+
+/* Values for the Tx status entry. */
+
+#define CRCDisable		0x2000
+#define TxDComplete		0x8000
+#define AddIPChksum		0x02000000
+#define AddTCPChksum		0x04000000
+#define AddUDPChksum		0x08000000
+#define TxIntrUploaded		0x80000000              /* IRQ when in FIFO, but maybe not sent. */
+
+/* XCVR Types */
+
+#define XCVR_10baseT		0
+#define XCVR_AUI		1 
+#define XCVR_10baseTOnly	2
+#define XCVR_10base2		3 
+#define XCVR_100baseTx		4
+#define XCVR_100baseFx		5
+#define XCVR_MII		6
+#define XCVR_NWAY		8
+#define XCVR_ExtMII		9
+#define XCVR_Default		10			/* I don't think this is correct -> should have been 0x10 if Auto Negotiate */
+
+struct descriptor {			    		/* A generic descriptor. */
+        u32 next;                                       /* Last entry points to 0	   	*/
+        u32 status;					/* FSH -> Frame Start Header 		*/
+        u32 addr;                                       /* Up to 63 addr/len pairs possible 	*/
+        u32 length;                                     /* Set LAST_FRAG to indicate last pair	*/
+};
+
+/* Misc. definitions */
+
+#define NUM_RX_DESC 		PKTBUFSRX * 10
+#define NUM_TX_DESC 		1            /* Number of TX descriptors   */
+
+#define TOUT_LOOP		1000000
+
+#define ETH_ALEN		6
+
+#define EL3WINDOW(dev, win_num) ETH_OUTW(dev, SelectWindow + (win_num), EL3_CMD)
+#define EL3_CMD 0x0e
+#define EL3_STATUS 0x0e
+
+
+#undef ETH_DEBUG
+
+#ifdef ETH_DEBUG
+#define PRINTF(fmt,args...)     printf (fmt ,##args)
+#else
+#define PRINTF(fmt,args...)
+#endif
+
+
+static struct rx_desc_3com *rx_ring;		 	/* RX descriptor ring         		*/
+static struct tx_desc_3com *tx_ring;		 	/* TX descriptor ring         		*/
+static u8 rx_buffer[NUM_RX_DESC][PKTSIZE_ALIGN];	/* storage for the incoming messages 	*/
+static int rx_next = 0;                      		/* RX descriptor ring pointer 		*/
+static int tx_next = 0;                      		/* TX descriptor ring pointer 		*/
+static int tx_threshold;
+
+static void  init_rx_ring(struct eth_device* dev);
+static void  purge_tx_ring(struct eth_device* dev);
+
+static void  read_hw_addr(struct eth_device* dev, bd_t * bis);
+
+static int eth_3com_init(struct eth_device* dev, bd_t *bis);
+static int eth_3com_send(struct eth_device* dev, volatile void *packet, int length);
+static int eth_3com_recv(struct eth_device* dev);
+static void eth_3com_halt(struct eth_device* dev);
+
+#define io_to_phys(a)	pci_io_to_phys((pci_dev_t)dev->priv, a)
+#define phys_to_io(a)	pci_phys_to_io((pci_dev_t)dev->priv, a)
+#define mem_to_phys(a)	pci_mem_to_phys((pci_dev_t)dev->priv, a)
+#define phys_to_mem(a)	pci_phys_to_mem((pci_dev_t)dev->priv, a)
+
+static inline int ETH_INL(struct eth_device* dev, u_long addr)
+{
+    __asm volatile ("eieio");
+	return le32_to_cpu(*(volatile u32 *)io_to_phys(addr + dev->iobase));
+}
+
+static inline int ETH_INW(struct eth_device* dev, u_long addr)
+{
+    __asm volatile ("eieio");
+	return le16_to_cpu(*(volatile u16 *)io_to_phys(addr + dev->iobase));
+}
+
+static inline int ETH_INB(struct eth_device* dev, u_long addr)
+{
+    __asm volatile ("eieio");
+	return *(volatile u8 *)io_to_phys(addr + dev->iobase);
+}
+
+static inline void ETH_OUTB(struct eth_device* dev, int command, u_long addr)
+{
+	*(volatile u8 *)io_to_phys(addr + dev->iobase) = command;
+    __asm volatile ("eieio");
+}
+
+static inline void ETH_OUTW(struct eth_device* dev, int command, u_long addr)
+{
+	*(volatile u16 *)io_to_phys(addr + dev->iobase) = cpu_to_le16(command);
+    __asm volatile ("eieio");
+}
+
+static inline void ETH_OUTL(struct eth_device* dev, int command, u_long addr)
+{
+	*(volatile u32 *)io_to_phys(addr + dev->iobase) = cpu_to_le32(command);
+    __asm volatile ("eieio");
+}
+
+static inline int ETH_STATUS(struct eth_device* dev)
+{
+    __asm volatile ("eieio");
+	return le16_to_cpu(*(volatile u16 *)io_to_phys(EL3_STATUS + dev->iobase));
+}
+
+static inline void ETH_CMD(struct eth_device* dev, int command)
+{
+	*(volatile u16 *)io_to_phys(EL3_CMD + dev->iobase) = cpu_to_le16(command); 
+    __asm volatile ("eieio");
+}
+
+/* Command register is always in the same spot in all the register windows */
+/* This function issues a command and waits for it so complete by checking the CmdInProgress bit */
+
+static int issue_and_wait(struct eth_device* dev, int command)
+{
+
+        int i, status;
+
+	ETH_CMD(dev, command);
+        for (i = 0; i < 2000; i++) {
+                status = ETH_STATUS(dev);
+		//printf ("Issue: status 0x%4x.\n", status);
+		if (!(status & CmdInProgress))
+                        return 1;
+        }
+
+        /* OK, that didn't work.  Do it the slow way.  One second */
+        for (i = 0; i < 100000; i++) {
+                status = ETH_STATUS(dev);
+		//printf ("Issue: status 0x%4x.\n", status);
+                        return 1;
+                udelay(10);
+        }
+        PRINTF("Ethernet command: 0x%4x did not complete! Status: 0x%4x\n", command, ETH_STATUS(dev) );
+	return 0;
+}
+
+/* Determine network media type and set up 3com accordingly           */
+/* I think I'm going to start with something known first like 10baseT */
+
+static int auto_negotiate(struct eth_device* dev)
+{
+    int i;
+
+    EL3WINDOW(dev, 1);
+
+    // Wait for Auto negotiation to complete
+    for (i = 0; i <= 1000; i++)
+    {
+	if (ETH_INW(dev, 2) & 0x04)
+	    break;
+	udelay(100);
+
+	if (i == 1000)
+	{
+	    PRINTF("Error: Auto negotiation failed\n");
+	    return 0;
+	}
+    }
+    
+
+
+    return 1;
+}
+
+void eth_interrupt(struct eth_device *dev)
+{
+    u16 status = ETH_STATUS(dev);
+
+    printf("eth0: status = 0x%04x\n", status);
+
+    if (!(status & IntLatch))
+	return;
+
+    if (status & (1<<6))
+    {
+	ETH_CMD(dev, AckIntr | (1<<6));
+	printf("Acknowledged Interrupt command\n");
+    }
+
+    if (status & DownComplete)
+    {
+	ETH_CMD(dev, AckIntr | DownComplete);
+	printf("Acknowledged DownComplete\n");
+    }
+
+    if (status & UpComplete)
+    {
+	ETH_CMD(dev, AckIntr | UpComplete);
+	printf("Acknowledged UpComplete\n");
+    }
+
+    ETH_CMD(dev, AckIntr | IntLatch);
+    printf("Acknowledged IntLatch\n");
+}
+
+int eth_3com_initialize(bd_t *bis)
+{
+        u32 eth_iobase = 0, status;
+        int card_number = 0, ret;
+        struct eth_device* dev;
+        pci_dev_t devno;
+	char *s;
+
+	s = getenv("3com_base");
+
+	/* Find ethernet controller on the PCI bus */
+
+	if ((devno = pci_find_device(PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905C, 0)) < 0)
+	{
+		PRINTF("Error: Cannot find the ethernet device on the PCI bus\n");
+		goto Done;
+	}
+
+	if (s)
+	{
+	    unsigned long base = atoi(s);
+	    pci_write_config_dword(devno, PCI_BASE_ADDRESS_0, base | 0x01);
+	}
+
+	ret = pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &eth_iobase);
+        eth_iobase &= ~0xf;
+
+	PRINTF("eth: 3Com Found at Address: 0x%x\n", eth_iobase);
+  
+	pci_write_config_dword(devno, PCI_COMMAND, PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
+
+	 /* Check if I/O accesses and Bus Mastering are enabled */
+
+	ret = pci_read_config_dword(devno, PCI_COMMAND, &status);
+
+	if (!(status & PCI_COMMAND_IO))
+	{
+		printf("Error: Cannot enable IO access.\n");
+		goto Done;
+	}
+
+	if (!(status & PCI_COMMAND_MEMORY))
+	{
+		printf("Error: Cannot enable MEMORY access.\n");
+		goto Done;
+	}
+
+	if (!(status & PCI_COMMAND_MASTER))
+	{
+		printf("Error: Cannot enable Bus Mastering.\n");
+		goto Done;
+	}
+
+        dev = (struct eth_device*) malloc(sizeof(*dev)); //struct eth_device));
+
+        sprintf(dev->name, "3Com 3c920c#%d", card_number);
+        dev->iobase = eth_iobase;
+        dev->priv   = (void*) devno;
+        dev->init   = eth_3com_init;
+        dev->halt   = eth_3com_halt;
+        dev->send   = eth_3com_send;
+        dev->recv   = eth_3com_recv;
+
+        eth_register(dev);
+
+/* 	{ */
+/* 	    char interrupt; */
+/* 	    devno = pci_find_device(PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905C, 0); */
+/* 	    pci_read_config_byte(devno, PCI_INTERRUPT_LINE, &interrupt); */
+	    
+/* 	    printf("Installing eth0 interrupt handler to %d\n", interrupt); */
+/* 	    irq_install_handler(interrupt, eth_interrupt, dev); */
+/* 	} */
+
+        card_number++;
+
+	/* Set the latency timer for value */
+	s = getenv("3com_latency");
+	if (s)
+	{
+	    ret = pci_write_config_byte(devno, PCI_LATENCY_TIMER, (unsigned char)atoi(s));
+	}
+	else ret = pci_write_config_byte(devno, PCI_LATENCY_TIMER, 0x0a);
+
+	read_hw_addr(dev, bis); 				/* get the MAC address from Window 2*/
+
+	/* Reset the ethernet controller */
+
+	PRINTF ("Issuing reset command....\n");
+	if (!issue_and_wait(dev, TotalReset))
+	{
+		printf("Error: Cannot reset ethernet controller.\n");
+		goto Done;
+	}
+	else
+		PRINTF ("Ethernet controller reset.\n");
+
+	/* allocate memory for rx and tx rings */
+
+	if(!(rx_ring = memalign(sizeof(struct rx_desc_3com) * NUM_RX_DESC, 16)))
+	{
+		PRINTF ("Cannot allocate memory for RX_RING.....\n");
+		goto Done;
+	}
+	
+	if (!(tx_ring = memalign(sizeof(struct tx_desc_3com) * NUM_TX_DESC, 16)))
+	{
+		PRINTF ("Cannot allocate memory for TX_RING.....\n");
+		goto Done;
+	}
+	
+Done:
+	return status;
+}
+
+
+static int eth_3com_init(struct eth_device* dev, bd_t *bis)
+{
+	int i, status = 0;
+	int tx_cur, loop;
+	u16 status_enable, intr_enable;
+	struct descriptor *ias_cmd;
+
+	/* Determine what type of network the machine is connected to	*/
+	/* presently drops the connect to 10Mbps			*/	     
+
+	if (!auto_negotiate(dev))
+	{
+		printf("Error: Cannot determine network media.\n");
+		goto Done;
+	}
+
+        issue_and_wait(dev, TxReset);
+        issue_and_wait(dev, RxReset|0x04);
+
+        /* Switch to register set 7 for normal use. */
+        EL3WINDOW(dev, 7);
+
+	/* Initialize Rx and Tx rings */
+
+	init_rx_ring(dev);
+	purge_tx_ring(dev);
+
+ 	ETH_CMD(dev, SetRxFilter | RxStation | RxBroadcast | RxProm);
+
+        issue_and_wait(dev,SetTxStart|0x07ff);
+
+        /* Below sets which indication bits to be seen. */
+
+        status_enable = SetStatusEnb | HostError | DownComplete | UpComplete | (1<<6);
+        ETH_CMD(dev, status_enable);
+
+	/* Below sets no bits are to cause an interrupt since this is just polling */
+
+        intr_enable   = SetIntrEnb;
+//	intr_enable = SetIntrEnb | (1<<9) | (1<<10) | (1<<6);
+        ETH_CMD(dev, intr_enable);
+	ETH_OUTB(dev, 127, UpPoll);
+
+        /* Ack all pending events, and set active indicator mask */
+
+        ETH_CMD(dev, AckIntr | IntLatch | TxAvailable | RxEarly | IntReq);
+        ETH_CMD(dev, intr_enable);
+
+	/* Tell the adapter where the RX ring is located */
+
+	issue_and_wait(dev,UpStall);				/* Stall and set the UplistPtr 		*/
+	ETH_OUTL(dev, (u32)&rx_ring[rx_next], UpListPtr);
+        ETH_CMD(dev, RxEnable); 				/* Enable the receiver. 		*/
+	issue_and_wait(dev,UpUnstall);
+
+	/* Send the Individual Address Setup frame */
+
+	tx_cur       = tx_next;
+	tx_next      = ((tx_next+1) % NUM_TX_DESC);
+
+	ias_cmd             = (struct descriptor *)&tx_ring[tx_cur];
+	ias_cmd->status     = cpu_to_le32(1<<31);		/* set DnIndicate bit. 			*/
+	ias_cmd->next       = 0;
+	ias_cmd->addr       = cpu_to_le32((u32)&bis->bi_enetaddr[0]);
+	ias_cmd->length     = cpu_to_le32(6 | LAST_FRAG);
+
+	/* Tell the adapter where the TX ring is located */
+
+        ETH_CMD(dev, TxEnable); 				/* Enable transmitter. 			*/
+	issue_and_wait(dev, DownStall);				/* Stall and set the DownListPtr. 	*/
+	ETH_OUTL(dev, (u32)&tx_ring[tx_cur], DownListPtr);
+	issue_and_wait(dev, DownUnstall);
+	for (i=0; !(ETH_STATUS(dev) & DownComplete); i++)
+	{
+		if (i >= TOUT_LOOP)
+		{
+			PRINTF("TX Ring status (Init):  0x%4x\n", le32_to_cpu(tx_ring[tx_cur].status));
+			PRINTF("ETH_STATUS: 0x%x\n", ETH_STATUS(dev));
+			goto Done;
+		}
+	}
+	if (ETH_STATUS(dev) & DownComplete)			/* If DownLoad Complete ACK the bit 	*/
+	{
+        	ETH_CMD(dev, AckIntr | DownComplete);		/* acknowledge the indication bit	*/
+ 		issue_and_wait(dev, DownStall);			/* stall and clear DownListPtr 		*/
+		ETH_OUTL(dev, 0, DownListPtr);
+		issue_and_wait(dev, DownUnstall);
+	}
+	status = 1;
+	    
+Done:
+	return status;
+}
+
+int eth_3com_send(struct eth_device* dev, volatile void *packet, int length)
+{
+	int i, status = 0;
+	int tx_cur;
+
+	if (length <= 0)
+	{
+		PRINTF("eth: bad packet size: %d\n", length);
+		goto Done;
+	}
+
+	tx_cur  = tx_next;
+	tx_next = (tx_next+1) % NUM_TX_DESC;
+
+	tx_ring[tx_cur].status  = cpu_to_le32(1<<31);		/* set DnIndicate bit 			*/
+	tx_ring[tx_cur].next    = 0;
+	tx_ring[tx_cur].addr    = cpu_to_le32(((u32) packet));
+	tx_ring[tx_cur].length  = cpu_to_le32(length | LAST_FRAG);
+
+	/* Send the packet */
+
+	issue_and_wait(dev, DownStall);				/* stall and set the DownListPtr 	*/
+	ETH_OUTL(dev, (u32) &tx_ring[tx_cur], DownListPtr);
+	issue_and_wait(dev, DownUnstall);
+
+	for (i=0; !(ETH_STATUS(dev) & DownComplete); i++)
+	{
+		if (i >= TOUT_LOOP)
+		{
+			PRINTF("TX Ring status (send): 0x%4x\n", le32_to_cpu(tx_ring[tx_cur].status));
+			goto Done;
+		}
+	}
+	if (ETH_STATUS(dev) & DownComplete)			/* If DownLoad Complete ACK the bit 	*/
+	{
+        	ETH_CMD(dev, AckIntr | DownComplete);		/* acknowledge the indication bit	*/
+ 		issue_and_wait(dev, DownStall);			/* stall and clear DownListPtr 		*/
+		ETH_OUTL(dev, 0, DownListPtr);
+		issue_and_wait(dev, DownUnstall);
+	}
+	status=1;
+ Done:
+	return status;
+}
+
+void PrintPacket (uchar *packet, int length)
+{
+int loop;
+uchar *ptr;
+
+	printf ("Printing packet of length %x.\n\n", length);
+	ptr = packet;
+	for (loop = 1; loop <= length; loop++)
+	{
+		printf ("%2x ", *ptr++);
+		if ((loop % 40)== 0)
+			printf ("\n");
+	}
+}
+
+int eth_3com_recv(struct eth_device* dev)
+{
+	u16 stat = 0;
+	u32 status;
+	int rx_prev, length = 0;
+
+	while (!(ETH_STATUS(dev) & UpComplete))			/* wait on receipt of packet 	*/
+		;
+
+	status = le32_to_cpu(rx_ring[rx_next].status);		/* packet status		*/
+
+	while (status & (1<<15))
+	{		
+		/* A packet has been received */
+
+		if (status & (1<<15))		
+		{
+			/* A valid frame received  */
+			
+			length = le32_to_cpu(rx_ring[rx_next].status) & 0x1fff;		/* length is in bits 0 - 12 	*/
+			
+			/* Pass the packet up to the protocol layers */
+
+			NetReceive((uchar *)le32_to_cpu(rx_ring[rx_next].addr), length);
+			rx_ring[rx_next].status = 0;					/* clear the status word 	*/
+			ETH_CMD(dev, AckIntr | UpComplete);
+			issue_and_wait(dev, UpUnstall);
+		}
+		else
+		if (stat & HostError)
+		{
+			/* There was an error */
+
+			printf("Rx error status:  0x%4x\n", stat);
+			init_rx_ring(dev);
+			goto Done;
+		}
+
+		rx_prev = rx_next;
+		rx_next = (rx_next + 1) % NUM_RX_DESC;
+		stat = ETH_STATUS(dev);					/* register status 	*/
+		status = le32_to_cpu(rx_ring[rx_next].status);		/* packet status 	*/
+	}
+
+Done:
+	return length;
+}
+
+void eth_3com_halt(struct eth_device* dev)
+{
+	if (!(dev->iobase)) 
+	{
+		goto Done;
+	}
+
+	issue_and_wait(dev, DownStall);		/* shut down transmit and receive */
+	issue_and_wait(dev, UpStall);
+	issue_and_wait(dev, RxDisable);
+	issue_and_wait(dev, TxDisable);
+
+//	free(tx_ring);				/* release memory allocated to the DPD and UPD rings */
+//	free(rx_ring);
+
+Done:
+	return;
+}
+
+static void init_rx_ring(struct eth_device* dev) 
+{
+	int i;
+
+	PRINTF("Initializing rx_ring. rx_buffer = %p\n", rx_buffer);
+	issue_and_wait(dev, UpStall);
+
+	for (i = 0; i < NUM_RX_DESC; i++)
+	{
+		rx_ring[i].next    = cpu_to_le32(((u32) &rx_ring[(i+1) % NUM_RX_DESC]));
+		rx_ring[i].status  = 0;
+		rx_ring[i].addr    = cpu_to_le32(((u32) &rx_buffer[i][0]));
+		rx_ring[i].length  = cpu_to_le32(PKTSIZE_ALIGN | LAST_FRAG);
+	}
+	rx_next = 0;
+}
+
+static void purge_tx_ring(struct eth_device* dev) 
+{
+	int i;
+
+	PRINTF("Purging tx_ring.\n");
+
+	tx_next      = 0;
+
+	for (i = 0; i < NUM_TX_DESC; i++)
+	{
+		tx_ring[i].next    = 0;
+		tx_ring[i].status  = 0;
+		tx_ring[i].addr    = 0;
+		tx_ring[i].length  = 0;
+	}
+}
+
+static void read_hw_addr(struct eth_device* dev, bd_t *bis) 
+{
+	u8 hw_addr[ETH_ALEN];
+	unsigned int eeprom[0x40];
+	unsigned int checksum = 0;
+	int i, j, timer;
+
+        /* Read the station address from the EEPROM. */
+
+        EL3WINDOW(dev, 0);
+	for (i = 0; i < 0x40; i++)
+	{
+        	ETH_OUTW(dev, EEPROM_Read + i, Wn0EepromCmd);
+                /* Pause for at least 162 us. for the read to take place. */
+                for (timer = 10; timer >= 0; timer--) 
+		{
+                	udelay(162);
+                        if ((ETH_INW(dev, Wn0EepromCmd) & 0x8000) == 0)
+                        	break;
+                }
+                eeprom[i] = ETH_INW(dev, Wn0EepromData);
+        }
+
+	/* Checksum calculation.  I'm not sure about this part and there seems to be a bug on the 3com side of things */
+
+        for (i = 0; i < 0x21; i++)
+                checksum  ^= eeprom[i];
+        checksum = (checksum ^ (checksum >> 8)) & 0xff;
+
+        if (checksum != 0xbb)
+                printf(" *** INVALID EEPROM CHECKSUM %4.4x *** \n", checksum);
+
+        for (i = 0, j = 0; i < 3; i++)
+	{
+		hw_addr[j++] = (u8)((eeprom[i+10] >> 8) & 0xff);
+		hw_addr[j++] = (u8)(eeprom[i+10] & 0xff);
+	}
+
+	/*  MAC Address is in window 2, write value from EEPROM to window 2 */
+
+        EL3WINDOW(dev, 2);
+        for (i = 0; i < 6; i++)
+                ETH_OUTB(dev, hw_addr[i], i);
+
+	for (j = 0; j < ETH_ALEN; j+=2)
+	{
+		hw_addr[j]   = (u8)(ETH_INW(dev, j) & 0xff);
+		hw_addr[j+1] = (u8)((ETH_INW(dev, j) >> 8) & 0xff);
+	}
+
+	for (i=0;i<ETH_ALEN;i++) 
+	{
+		if (hw_addr[i] != bis->bi_enetaddr[i]) 
+		{
+/* 			printf("Warning: HW address don't match:\n"); */
+/* 			printf("Address in 3Com Window 2 is         " */
+/* 			       "%02X:%02X:%02X:%02X:%02X:%02X\n", */
+/* 			       hw_addr[0], hw_addr[1], hw_addr[2], */
+/* 			       hw_addr[3], hw_addr[4], hw_addr[5]); */
+/* 			printf("Address used by U-Boot is " */
+/* 			       "%02X:%02X:%02X:%02X:%02X:%02X\n", */
+/* 			       bis->bi_enetaddr[0], bis->bi_enetaddr[1],  */
+/* 			       bis->bi_enetaddr[2], bis->bi_enetaddr[3],  */
+/* 			       bis->bi_enetaddr[4], bis->bi_enetaddr[5]); */
+/* 			goto Done; */
+		    char buffer[256];
+		    if (bis->bi_enetaddr[0] == 0 && bis->bi_enetaddr[1] == 0 &&
+			bis->bi_enetaddr[2] == 0 && bis->bi_enetaddr[3] == 0 &&
+			bis->bi_enetaddr[4] == 0 && bis->bi_enetaddr[5] == 0)
+		    {
+
+			sprintf(buffer, "%02X:%02X:%02X:%02X:%02X:%02X", 
+				hw_addr[0], hw_addr[1], hw_addr[2], 
+				hw_addr[3], hw_addr[4], hw_addr[5]); 
+			setenv("ethaddr", buffer);
+		    }
+		}
+	}
+
+	for(i=0; i<ETH_ALEN; i++) dev->enetaddr[i] = hw_addr[i];
+
+Done:
+	return;
+}
+
diff --git a/board/MAI/AmigaOneG3SE/flash.c b/board/MAI/AmigaOneG3SE/flash.c
new file mode 100644
index 00000000000..409b955fd59
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/flash.c
@@ -0,0 +1,35 @@
+#include <common.h>
+#include <flash.h>
+
+flash_info_t    flash_info[CFG_MAX_FLASH_BANKS];
+
+
+unsigned long flash_init(void)
+{
+    int i;
+
+    for (i = 0; i < CFG_MAX_FLASH_BANKS; i++)
+    {
+	flash_info[i].flash_id = FLASH_UNKNOWN;
+	flash_info[i].sector_count = 0;
+	flash_info[i].size = 0;
+    }
+
+
+    return 1;
+}
+
+int flash_erase(flash_info_t *info, int s_first, int s_last)
+{
+    return 1;
+}
+
+void flash_print_info(flash_info_t *info)
+{
+    printf("No flashrom installed\n");
+}
+
+int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
+{
+    return 0;
+}
diff --git a/board/MAI/AmigaOneG3SE/flash_new.c b/board/MAI/AmigaOneG3SE/flash_new.c
new file mode 100644
index 00000000000..6eebeba0f21
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/flash_new.c
@@ -0,0 +1,652 @@
+/*
+ * (C) Copyright 2001
+ * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
+ *
+ * (C) Copyright 2002
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <flash.h>
+#include <asm/io.h>
+#include "memio.h" 
+
+/*---------------------------------------------------------------------*/
+#undef DEBUG_FLASH
+//#define DEBUG_FLASH
+
+#ifdef DEBUG_FLASH
+#define DEBUGF(fmt,args...) printf(fmt ,##args)
+#else
+#define DEBUGF(fmt,args...)
+#endif
+/*---------------------------------------------------------------------*/
+
+flash_info_t	flash_info[CFG_MAX_FLASH_BANKS];
+
+static ulong flash_get_size (ulong addr, flash_info_t *info);
+static int flash_get_offsets (ulong base, flash_info_t *info);
+static int write_word (flash_info_t *info, ulong dest, ulong data);
+static void flash_reset (ulong addr);
+
+int flash_xd_nest;
+
+static void flash_to_xd(void)
+{
+    unsigned char x;
+
+    flash_xd_nest ++;
+
+    if (flash_xd_nest == 1)
+    {
+	DEBUGF("Flash on XD\n");
+	x = pci_read_cfg_byte(0, 0, 0x74);
+	pci_write_cfg_byte(0, 0, 0x74, x|1);
+    }
+}
+
+static void flash_to_mem(void)
+{
+    unsigned char x;
+
+    flash_xd_nest --;
+   
+    if (flash_xd_nest == 0)
+    {
+	DEBUGF("Flash on memory bus\n");
+	x = pci_read_cfg_byte(0, 0, 0x74);
+	pci_write_cfg_byte(0, 0, 0x74, x&0xFE);
+    }
+}
+
+unsigned long flash_init_old(void)
+{
+    int i;
+
+    for (i = 0; i < CFG_MAX_FLASH_BANKS; i++)
+    {
+	flash_info[i].flash_id = FLASH_UNKNOWN;
+	flash_info[i].sector_count = 0;
+	flash_info[i].size = 0;
+    }
+
+
+    return 1;
+}
+
+unsigned long flash_init (void)
+{
+	unsigned int i;
+	unsigned long flash_size = 0;
+
+	flash_xd_nest = 0;
+
+	flash_to_xd();
+
+	/* Init: no FLASHes known */
+	for (i=0; i<CFG_MAX_FLASH_BANKS; ++i) {
+		flash_info[i].flash_id = FLASH_UNKNOWN;
+		flash_info[i].sector_count = 0;
+		flash_info[i].size = 0;
+	}
+
+	DEBUGF("\n## Get flash size @ 0x%08x\n", CFG_FLASH_BASE);
+
+	flash_size = flash_get_size (CFG_FLASH_BASE, flash_info);
+
+	DEBUGF("## Flash bank size: %08lx\n", flash_size);
+
+	if (flash_size) {
+#if CFG_MONITOR_BASE >= CFG_FLASH_BASE && \
+    CFG_MONITOR_BASE < CFG_FLASH_BASE + CFG_FLASH_MAX_SIZE
+		/* monitor protection ON by default */
+		flash_protect(FLAG_PROTECT_SET,
+			      CFG_MONITOR_BASE,
+			      CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1,
+			      &flash_info[0]);
+#endif
+
+#ifdef CFG_ENV_IS_IN_FLASH
+		/* ENV protection ON by default */
+		flash_protect(FLAG_PROTECT_SET,
+			      CFG_ENV_ADDR,
+			      CFG_ENV_ADDR + CFG_ENV_SECT_SIZE - 1,
+			      &flash_info[0]);
+#endif
+
+	} else {
+		puts ("Warning: the BOOT Flash is not initialised !");
+	}
+
+	flash_to_mem();
+
+	return flash_size;
+}
+
+/*
+ * The following code cannot be run from FLASH!
+ */
+static ulong flash_get_size (ulong addr, flash_info_t *info)
+{
+	short i;
+	uchar value;
+	uchar *x = (uchar *)addr;
+
+	flash_to_xd();
+
+	/* Write auto select command: read Manufacturer ID */
+	x[0x0555] =  0xAA;
+	__asm volatile ("sync\n eieio");
+	x[0x02AA] =  0x55;
+	__asm volatile ("sync\n eieio");
+	x[0x0555] =  0x90;
+	__asm volatile ("sync\n eieio");
+
+	value = x[0];
+	__asm volatile ("sync\n eieio");
+
+	DEBUGF("Manuf. ID @ 0x%08lx: 0x%08x\n", (ulong)addr, value);
+
+	switch (value | (value << 16)) {
+		case AMD_MANUFACT:
+			info->flash_id = FLASH_MAN_AMD;
+			break;
+
+		case FUJ_MANUFACT:
+			info->flash_id = FLASH_MAN_FUJ;
+			break;
+
+		case STM_MANUFACT:
+			info->flash_id = FLASH_MAN_STM;
+			break;
+
+		default:
+			info->flash_id = FLASH_UNKNOWN;
+			info->sector_count = 0;
+			info->size = 0;
+			flash_reset (addr);
+			return 0;
+	}
+
+	value = x[1];
+	__asm volatile ("sync\n eieio");
+
+	DEBUGF("Device ID @ 0x%08lx: 0x%08x\n", addr+1, value);
+
+	switch (value) {
+		case AMD_ID_F040B:
+			DEBUGF("Am29F040B\n");
+			info->flash_id += FLASH_AM040;
+			info->sector_count = 8;
+			info->size = 0x00080000;
+			break;			/* => 512 kB		*/
+
+		case AMD_ID_LV040B:
+			DEBUGF("Am29LV040B\n");
+			info->flash_id += FLASH_AM040;
+			info->sector_count = 8;
+			info->size = 0x00080000;
+			break;			/* => 512 kB		*/
+
+		case AMD_ID_LV400T:
+			DEBUGF("Am29LV400T\n");
+			info->flash_id += FLASH_AM400T;
+			info->sector_count = 11;
+			info->size = 0x00100000;
+			break;			/* => 1 MB		*/
+
+		case AMD_ID_LV400B:
+			DEBUGF("Am29LV400B\n");
+			info->flash_id += FLASH_AM400B;
+			info->sector_count = 11;
+			info->size = 0x00100000;
+			break;			/* => 1 MB		*/
+
+		case AMD_ID_LV800T:
+			DEBUGF("Am29LV800T\n");
+			info->flash_id += FLASH_AM800T;
+			info->sector_count = 19;
+			info->size = 0x00200000;
+			break;			/* => 2 MB		*/
+
+		case AMD_ID_LV800B:
+			DEBUGF("Am29LV400B\n");
+			info->flash_id += FLASH_AM800B;
+			info->sector_count = 19;
+			info->size = 0x00200000;
+			break;			/* => 2 MB		*/
+
+		case AMD_ID_LV160T:
+			DEBUGF("Am29LV160T\n");
+			info->flash_id += FLASH_AM160T;
+			info->sector_count = 35;
+			info->size = 0x00400000;
+			break;			/* => 4 MB		*/
+
+		case AMD_ID_LV160B:
+			DEBUGF("Am29LV160B\n");
+			info->flash_id += FLASH_AM160B;
+			info->sector_count = 35;
+			info->size = 0x00400000;
+			break;			/* => 4 MB		*/
+
+		case AMD_ID_LV320T:
+			DEBUGF("Am29LV320T\n");
+			info->flash_id += FLASH_AM320T;
+			info->sector_count = 67;
+			info->size = 0x00800000;
+			break;			/* => 8 MB		*/
+
+#if 0
+		/* Has the same ID as AMD_ID_LV320T, to be fixed */
+		case AMD_ID_LV320B:
+			DEBUGF("Am29LV320B\n");
+			info->flash_id += FLASH_AM320B;
+			info->sector_count = 67;
+			info->size = 0x00800000;
+			break;			/* => 8 MB		*/
+#endif
+
+		case AMD_ID_LV033C:
+			DEBUGF("Am29LV033C\n");
+			info->flash_id += FLASH_AM033C;
+			info->sector_count = 64;
+			info->size = 0x01000000;
+			break;			/* => 16Mb		*/
+
+		case STM_ID_F040B:
+			DEBUGF("M29F040B\n");
+			info->flash_id += FLASH_AM040;
+			info->sector_count = 8;
+			info->size = 0x00080000;
+			break;			/* => 512 kB		*/
+
+		default:
+			info->flash_id = FLASH_UNKNOWN;
+			flash_reset (addr);
+			flash_to_mem();
+			return (0);		/* => no or unknown flash */
+
+	}
+
+	if (info->sector_count > CFG_MAX_FLASH_SECT) {
+		printf ("** ERROR: sector count %d > max (%d) **\n",
+			info->sector_count, CFG_MAX_FLASH_SECT);
+		info->sector_count = CFG_MAX_FLASH_SECT;
+	}
+
+	if (! flash_get_offsets (addr, info)) {
+		flash_reset (addr);
+		flash_to_mem();
+		return 0;
+	}
+
+	/* check for protected sectors */
+	for (i = 0; i < info->sector_count; i++) {
+		/* read sector protection at sector address, (A7 .. A0) = 0x02 */
+		/* D0 = 1 if protected */
+		value = in8(info->start[i] + 2);
+		iobarrier_rw();
+		info->protect[i] = (value & 1) != 0;
+	}
+
+	/*
+	 * Reset bank to read mode
+	 */
+	flash_reset (addr);
+
+	flash_to_mem();
+
+	return (info->size);
+}
+
+static int flash_get_offsets (ulong base, flash_info_t *info)
+{
+	unsigned int i;
+
+	switch (info->flash_id & FLASH_TYPEMASK) {
+		case FLASH_AM040:
+			/* set sector offsets for uniform sector type	*/
+			for (i = 0; i < info->sector_count; i++) {
+				info->start[i] = base + i * info->size /
+				                            info->sector_count;
+			}
+			break;
+		default:
+			return 0;
+	}
+
+	return 1;
+}
+
+int flash_erase (flash_info_t *info, int s_first, int s_last)
+{
+	volatile ulong addr = info->start[0];
+	int flag, prot, sect, l_sect;
+	ulong start, now, last;
+
+	flash_to_xd();
+
+	if (s_first < 0 || s_first > s_last) {
+		if (info->flash_id == FLASH_UNKNOWN) {
+			printf ("- missing\n");
+		} else {
+			printf ("- no sectors to erase\n");
+		}
+		flash_to_mem();
+		return 1;
+	}
+
+	if (info->flash_id == FLASH_UNKNOWN) {
+		printf ("Can't erase unknown flash type %08lx - aborted\n",
+			info->flash_id);
+		flash_to_mem();
+		return 1;
+	}
+
+	prot = 0;
+	for (sect=s_first; sect<=s_last; ++sect) {
+		if (info->protect[sect]) {
+			prot++;
+		}
+	}
+
+	if (prot) {
+		printf ("- Warning: %d protected sectors will not be erased!\n",
+			prot);
+	} else {
+		printf ("\n");
+	}
+
+	l_sect = -1;
+
+	/* Disable interrupts which might cause a timeout here */
+	flag = disable_interrupts();
+
+	out8(addr + 0x555, 0xAA);
+	iobarrier_rw();
+	out8(addr + 0x2AA, 0x55);
+	iobarrier_rw();
+	out8(addr + 0x555, 0x80);
+	iobarrier_rw();
+	out8(addr + 0x555, 0xAA);
+	iobarrier_rw();
+	out8(addr + 0x2AA, 0x55);
+	iobarrier_rw();
+
+	/* Start erase on unprotected sectors */
+	for (sect = s_first; sect<=s_last; sect++) {
+		if (info->protect[sect] == 0) {	/* not protected */
+			addr = info->start[sect];
+			out8(addr, 0x30);
+			iobarrier_rw();
+			l_sect = sect;
+		}
+	}
+
+	/* re-enable interrupts if necessary */
+	if (flag)
+		enable_interrupts();
+
+	/* wait at least 80us - let's wait 1 ms */
+	udelay (1000);
+
+	/*
+	 * We wait for the last triggered sector
+	 */
+	if (l_sect < 0)
+		goto DONE;
+
+	start = get_timer (0);
+	last  = start;
+	addr = info->start[l_sect];
+
+	DEBUGF ("Start erase timeout: %d\n", CFG_FLASH_ERASE_TOUT);
+
+	while ((in8(addr) & 0x80) != 0x80) {
+		if ((now = get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
+			printf ("Timeout\n");
+			flash_reset (info->start[0]);
+			flash_to_mem();
+			return 1;
+		}
+		/* show that we're waiting */
+		if ((now - last) > 1000) {	/* every second */
+			putc ('.');
+			last = now;
+		}
+		iobarrier_rw();
+	}
+
+DONE:
+	/* reset to read mode */
+	flash_reset (info->start[0]);
+	flash_to_mem();
+
+	printf (" done\n");
+	return 0;
+}
+
+/*
+ * Copy memory to flash, returns:
+ * 0 - OK
+ * 1 - write timeout
+ * 2 - Flash not erased
+ */
+int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
+{
+	ulong cp, wp, data;
+	int i, l, rc;
+
+	flash_to_xd();
+
+	wp = (addr & ~3);	/* get lower word aligned address */
+
+	/*
+	 * handle unaligned start bytes
+	 */
+	if ((l = addr - wp) != 0) {
+		data = 0;
+		for (i=0, cp=wp; i<l; ++i, ++cp) {
+			data = (data << 8) | (*(uchar *)cp);
+		}
+		for (; i<4 && cnt>0; ++i) {
+			data = (data << 8) | *src++;
+			--cnt;
+			++cp;
+		}
+		for (; cnt==0 && i<4; ++i, ++cp) {
+			data = (data << 8) | (*(uchar *)cp);
+		}
+
+		if ((rc = write_word(info, wp, data)) != 0) {
+		        flash_to_mem();
+			return (rc);
+		}
+		wp += 4;
+	}
+
+	/*
+	 * handle word aligned part
+	 */
+	while (cnt >= 4) {
+		data = 0;
+		for (i=0; i<4; ++i) {
+			data = (data << 8) | *src++;
+		}
+		if ((rc = write_word(info, wp, data)) != 0) {
+		        flash_to_mem();
+			return (rc);
+		}
+		wp  += 4;
+		cnt -= 4;
+	}
+
+	if (cnt == 0) {
+		flash_to_mem();
+		return (0);
+	}
+
+	/*
+	 * handle unaligned tail bytes
+	 */
+	data = 0;
+	for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
+		data = (data << 8) | *src++;
+		--cnt;
+	}
+	for (; i<4; ++i, ++cp) {
+		data = (data << 8) | (*(uchar *)cp);
+	}
+
+
+	flash_to_mem();
+	return (write_word(info, wp, data));
+}
+
+/*
+ * Write a word to Flash, returns:
+ * 0 - OK
+ * 1 - write timeout
+ * 2 - Flash not erased
+ */
+static int write_word (flash_info_t *info, ulong dest, ulong data)
+{
+	volatile ulong addr = info->start[0];
+	ulong start;
+	int i;
+
+	flash_to_xd();
+
+	/* Check if Flash is (sufficiently) erased */
+	if ((in32(dest) & data) != data) {
+		flash_to_mem();
+		return (2);
+	}
+
+	/* write each byte out */
+	for (i = 0; i < 4; i++) {
+		char *data_ch = (char *)&data;
+		int flag = disable_interrupts();
+
+		out8(addr + 0x555, 0xAA);
+		iobarrier_rw();
+		out8(addr + 0x2AA, 0x55);
+		iobarrier_rw();
+		out8(addr + 0x555, 0xA0);
+		iobarrier_rw();
+		out8(dest+i, data_ch[i]);
+		iobarrier_rw();
+
+		/* re-enable interrupts if necessary */
+		if (flag)
+			enable_interrupts();
+
+		/* data polling for D7 */
+		start = get_timer (0);
+		while ((in8(dest+i) & 0x80) != (data_ch[i] & 0x80)) {
+			if (get_timer(start) > CFG_FLASH_WRITE_TOUT) {
+				flash_reset (addr);
+				flash_to_mem();
+				return (1);
+			}
+			iobarrier_rw();
+		}
+	}
+
+	flash_reset (addr);
+	flash_to_mem();
+	return (0);
+}
+
+/*
+ * Reset bank to read mode
+ */
+static void flash_reset (ulong addr)
+{
+        flash_to_xd();
+	out8(addr, 0xF0);	/* reset bank */
+	iobarrier_rw();
+	flash_to_mem();
+}
+
+void flash_print_info (flash_info_t *info)
+{
+	int i;
+
+	if (info->flash_id == FLASH_UNKNOWN) {
+		printf ("missing or unknown FLASH type\n");
+		return;
+	}
+
+	switch (info->flash_id & FLASH_VENDMASK) {
+	case FLASH_MAN_AMD:	printf ("AMD ");		break;
+	case FLASH_MAN_FUJ:	printf ("FUJITSU ");		break;
+	case FLASH_MAN_BM:	printf ("BRIGHT MICRO ");	break;
+	case FLASH_MAN_STM:	printf ("SGS THOMSON ");	break;
+	default:		printf ("Unknown Vendor ");	break;
+	}
+
+	switch (info->flash_id & FLASH_TYPEMASK) {
+	case FLASH_AM040:	printf ("29F040 or 29LV040 (4 Mbit, uniform sectors)\n");
+				break;
+	case FLASH_AM400B:	printf ("AM29LV400B (4 Mbit, bottom boot sect)\n");
+				break;
+	case FLASH_AM400T:	printf ("AM29LV400T (4 Mbit, top boot sector)\n");
+				break;
+	case FLASH_AM800B:	printf ("AM29LV800B (8 Mbit, bottom boot sect)\n");
+				break;
+	case FLASH_AM800T:	printf ("AM29LV800T (8 Mbit, top boot sector)\n");
+				break;
+	case FLASH_AM160B:	printf ("AM29LV160B (16 Mbit, bottom boot sect)\n");
+				break;
+	case FLASH_AM160T:	printf ("AM29LV160T (16 Mbit, top boot sector)\n");
+				break;
+	case FLASH_AM320B:	printf ("AM29LV320B (32 Mbit, bottom boot sect)\n");
+				break;
+	case FLASH_AM320T:	printf ("AM29LV320T (32 Mbit, top boot sector)\n");
+				break;
+	default:		printf ("Unknown Chip Type\n");
+				break;
+	}
+
+	if (info->size % 0x100000 == 0) {
+		printf ("  Size: %ld MB in %d Sectors\n",
+			info->size / 0x100000, info->sector_count);
+	} else if (info->size % 0x400 == 0) {
+		printf ("  Size: %ld KB in %d Sectors\n",
+		        info->size / 0x400, info->sector_count);
+	} else {
+		printf ("  Size: %ld B in %d Sectors\n",
+		        info->size, info->sector_count);
+	}
+
+	printf ("  Sector Start Addresses:");
+	for (i=0; i<info->sector_count; ++i) {
+		if ((i % 5) == 0)
+			printf ("\n   ");
+		printf (" %08lX%s",
+			info->start[i],
+			info->protect[i] ? " (RO)" : "     "
+		);
+	}
+	printf ("\n");
+}
diff --git a/board/MAI/AmigaOneG3SE/i8259.c b/board/MAI/AmigaOneG3SE/i8259.c
new file mode 100644
index 00000000000..6cdfc60da40
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/i8259.c
@@ -0,0 +1,230 @@
+/*
+ * (C) Copyright 2002
+ * John W. Linville, linville@tuxdriver.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include "i8259.h"
+
+#undef  IRQ_DEBUG
+
+#ifdef  IRQ_DEBUG
+#define PRINTF(fmt,args...)     printf (fmt ,##args)
+#else
+#define PRINTF(fmt,args...)
+#endif
+
+static inline unsigned char read_byte(volatile unsigned char* from)
+{
+    int x;
+    asm volatile ("lbz %0,%1\n eieio" : "=r" (x) : "m" (*from));
+    return (unsigned char)x;
+}
+
+static inline void write_byte(volatile unsigned char *to, int x)
+{
+    asm volatile ("stb %1,%0\n eieio" : "=m" (*to) : "r" (x));
+}
+
+static inline unsigned long read_long_little(volatile unsigned long *from)
+{
+    unsigned long x;
+    asm volatile ("lwbrx %0,0,%1\n eieio\n sync" : "=r" (x) : "r" (from), "m"(*from));
+    return (unsigned long)x;
+}
+
+#ifdef out8
+#undef out8
+#endif
+
+#ifdef in8
+#undef in8
+#endif
+
+#define out8(addr, byte) write_byte(0xFE000000 | addr, byte)
+#define in8(addr) read_byte(0xFE000000 | addr)
+
+/*
+ * This contains the irq mask for both 8259A irq controllers,
+ */
+static char cached_imr[2] = {0xff, 0xff};
+
+#define cached_imr1	(cached_imr[0])
+#define cached_imr2	(cached_imr[1])
+
+void i8259_init(void)
+{
+	char dummy;
+	PRINTF("Initializing Interrupt controller\n");
+	/* init master interrupt controller */
+	out8(0x20, 0x11); //0x19); // was: 0x11); /* Start init sequence */
+	out8(0x21, 0x00); /* Vector base */
+	out8(0x21, 0x04); /* edge tiggered, Cascade (slave) on IRQ2 */
+	out8(0x21, 0x11); // was: 0x01); /* Select 8086 mode */
+
+	/* init slave interrupt controller */
+	out8(0xA0, 0x11); //0x19); // was: 0x11); /* Start init sequence */
+	out8(0xA1, 0x08); /* Vector base */
+	out8(0xA1, 0x02); /* edge triggered, Cascade (slave) on IRQ2 */
+	out8(0xA1, 0x11); // was: 0x01); /* Select 8086 mode */
+
+	/* always read ISR */
+	out8(0x20, 0x0B);
+	dummy = in8(ISR_1);
+	out8(0xA0, 0x0B);
+	dummy = in8(ISR_2);
+
+/*     out8(0x43, 0x30); */
+/*     out8(0x40, 0); */
+/*     out8(0x40, 0); */
+/*     out8(0x43, 0x70); */
+/*     out8(0x41, 0); */
+/*     out8(0x41, 0); */
+/*     out8(0x43, 0xb0); */
+/*     out8(0x42, 0); */
+/*     out8(0x42, 0); */
+
+	/* Mask all interrupts */
+	out8(IMR_2, cached_imr2);
+	out8(IMR_1, cached_imr1);
+
+	i8259_unmask_irq(2);
+#if 0
+	{
+	    int i;
+	    for (i=0; i<16; i++)
+	    {
+		i8259_unmask_irq(i);
+	    }
+	}
+#endif
+}
+
+static volatile char *pci_intack = (void *)0xFEF00000;
+
+int i8259_irq(void)
+{
+	int irq;
+
+	irq = read_long_little(pci_intack) & 0xff;
+	if (irq==7) {
+		/*
+		 * This may be a spurious interrupt.
+		 *
+		 * Read the interrupt status register (ISR). If the most
+		 * significant bit is not set then there is no valid
+		 * interrupt.
+		 */
+		if(~in8(0x20)&0x80) {
+			irq = -1;
+		}
+	}
+
+	return irq;
+}
+int i8259_get_irq(struct pt_regs *regs)
+{
+	unsigned char irq;
+
+	/*
+	 * Perform an interrupt acknowledge cycle on controller 1
+	 */
+	out8(OCW3_1, 0x0C); /* prepare for poll */
+	irq = in8(IPL_1) & 7;
+	if (irq == 2) {
+		/*
+		 * Interrupt is cascaded so perform interrupt
+		 * acknowledge on controller 2
+		 */
+		out8(OCW3_2, 0x0C); /* prepare for poll */
+		irq = (in8(IPL_2) & 7) + 8;
+		if (irq == 15) {
+			/*
+			 * This may be a spurious interrupt
+			 *
+			 * Read the interrupt status register. If the most
+			 * significant bit is not set then there is no valid
+			 * interrupt
+			 */
+			out8(OCW3_2, 0x0b);
+			if (~(in8(ISR_2) & 0x80)) {
+				return -1;
+			}
+		}
+	} else if (irq == 7) {
+		/*
+		 * This may be a spurious interrupt
+		 *
+		 * Read the interrupt status register. If the most
+		 * significant bit is not set then there is no valid
+		 * interrupt
+		 */
+		out8(OCW3_1, 0x0b);
+		if (~(in8(ISR_1) & 0x80)) {
+			return -1;
+		}
+	}
+	return irq;
+}
+
+/*
+ * Careful! The 8259A is a fragile beast, it pretty
+ * much _has_ to be done exactly like this (mask it
+ * first, _then_ send the EOI, and the order of EOI
+ * to the two 8259s is important!
+ */
+void i8259_mask_and_ack(int irq)
+{
+	if (irq > 7) {
+		cached_imr2 |= (1 << (irq - 8));
+		in8(IMR_2); /* DUMMY */
+		out8(IMR_2, cached_imr2);
+		out8(OCW2_2, 0x20); /* Non-specific EOI */
+		out8(OCW2_1, 0x20); /* Non-specific EOI to cascade */
+	} else {
+		cached_imr1 |= (1 << irq);
+		in8(IMR_1); /* DUMMY */
+		out8(IMR_1, cached_imr1);
+		out8(OCW2_1, 0x20); /* Non-specific EOI */
+	}
+}
+
+void i8259_mask_irq(int irq)
+{
+	if (irq & 8) {
+		cached_imr2 |= (1 << (irq & 7));
+		out8(IMR_2, cached_imr2);
+	} else {
+		cached_imr1 |= (1 << irq);
+		out8(IMR_1, cached_imr1);
+	}
+}
+
+void i8259_unmask_irq(int irq)
+{
+	if (irq & 8) {
+		cached_imr2 &= ~(1 << (irq & 7));
+		out8(IMR_2, cached_imr2);
+	} else {
+		cached_imr1 &= ~(1 << irq);
+		out8(IMR_1, cached_imr1);
+	}
+}
diff --git a/board/MAI/AmigaOneG3SE/i8259.h b/board/MAI/AmigaOneG3SE/i8259.h
new file mode 100644
index 00000000000..05c40522d1f
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/i8259.h
@@ -0,0 +1,56 @@
+/*
+ * (C) Copyright 2002
+ * John W. Linville, linville@tuxdriver.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#define ICW1_1  CFG_ISA_IO_BASE_ADDRESS + ISA_INT1_ICW1
+#define ICW1_2  CFG_ISA_IO_BASE_ADDRESS + ISA_INT2_ICW1
+#define ICW2_1  CFG_ISA_IO_BASE_ADDRESS + ISA_INT1_ICW2
+#define ICW2_2  CFG_ISA_IO_BASE_ADDRESS + ISA_INT2_ICW2
+#define ICW3_1  CFG_ISA_IO_BASE_ADDRESS + ISA_INT1_ICW3
+#define ICW3_2  CFG_ISA_IO_BASE_ADDRESS + ISA_INT2_ICW3
+#define ICW4_1  CFG_ISA_IO_BASE_ADDRESS + ISA_INT1_ICW4
+#define ICW4_2  CFG_ISA_IO_BASE_ADDRESS + ISA_INT2_ICW4
+#define OCW1_1  CFG_ISA_IO_BASE_ADDRESS + ISA_INT1_OCW1
+#define OCW1_2  CFG_ISA_IO_BASE_ADDRESS + ISA_INT2_OCW1
+#define OCW2_1  CFG_ISA_IO_BASE_ADDRESS + ISA_INT1_OCW2
+#define OCW2_2  CFG_ISA_IO_BASE_ADDRESS + ISA_INT2_OCW2
+#define OCW3_1  CFG_ISA_IO_BASE_ADDRESS + ISA_INT1_OCW3
+#define OCW3_2  CFG_ISA_IO_BASE_ADDRESS + ISA_INT2_OCW3
+
+#define IMR_1   OCW1_1
+#define IMR_2   OCW1_2
+
+#define ISR_1   ICW1_1
+#define ISR_2   ICW1_2
+
+#define IPL_1   ICW1_1
+#define IPL_2   ICW1_2
+
+extern void i8259_init(void);
+
+extern int i8259_get_irq(struct pt_regs *regs);
+
+extern void i8259_mask_and_ack(int irq);
+
+extern void i8259_mask_irq(int irq);
+
+extern void i8259_unmask_irq(int irq);
diff --git a/board/MAI/AmigaOneG3SE/interrupts.c b/board/MAI/AmigaOneG3SE/interrupts.c
new file mode 100644
index 00000000000..bb93ea02839
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/interrupts.c
@@ -0,0 +1,268 @@
+/*
+ * (C) Copyright 2002
+ * John W. Linville <linville@tuxdriver.com>
+ *
+ *    Copied and modified from original code by Josh Huber.  Original
+ *    copyright notice preserved below.
+ *
+ * (C) Copyright 2001
+ * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * interrupts.c - just enough support for the decrementer/timer
+ */
+
+#include <common.h>
+#include <asm/processor.h>
+#include <command.h>
+#include "i8259.h"
+
+#undef DEBUG
+#ifdef  DEBUG
+#define PRINTF(fmt,args...)     printf (fmt ,##args)
+#else
+#define PRINTF(fmt,args...)
+#endif
+#define NR_IRQS	16
+
+void irq_alloc_init(void);
+long irq_alloc(long wanted);
+
+/****************************************************************************/
+
+unsigned decrementer_count;	     /* count value for 1e6/HZ microseconds */
+
+struct irq_action {
+    interrupt_handler_t *handler;
+    void *arg;
+    ulong count;
+};
+
+static struct irq_action irq_handlers[NR_IRQS];
+
+/****************************************************************************/
+
+static __inline__ unsigned long
+get_msr(void)
+{
+	unsigned long msr;
+
+	asm volatile("mfmsr %0" : "=r" (msr) :);
+	return msr;
+}
+
+static __inline__ void
+set_msr(unsigned long msr)
+{
+	asm volatile("mtmsr %0" : : "r" (msr)); 
+}
+
+static __inline__ unsigned long
+get_dec(void)
+{
+	unsigned long val;
+
+	asm volatile("mfdec %0" : "=r" (val) :);
+	return val;
+}
+
+
+static __inline__ void
+set_dec(unsigned long val)
+{
+	asm volatile("mtdec %0" : : "r" (val)); 
+}
+
+
+void
+enable_interrupts(void)
+{
+    set_msr (get_msr() | MSR_EE);
+}
+
+/* returns flag if MSR_EE was set before */
+int
+disable_interrupts(void)
+{
+    ulong msr;
+
+    msr = get_msr();
+    set_msr (msr & ~MSR_EE);
+    return ((msr & MSR_EE) != 0);
+}
+
+/****************************************************************************/
+
+int interrupt_init (void)
+{
+    extern void new_reset(void);
+    extern void new_reset_end(void);
+#ifdef DEBUG
+	puts("interrupt_init: setting decrementer_count\n");
+#endif
+	decrementer_count = get_tbclk() / CFG_HZ;
+
+#ifdef DEBUG
+	puts("interrupt_init: setting actual decremter\n");
+#endif
+	set_dec (get_tbclk() / CFG_HZ);
+
+#ifdef DEBUG
+	puts("interrupt_init: clearing external interrupt table\n");
+#endif
+	/* clear external interrupt table here */
+	memset(irq_handlers, 0, sizeof(irq_handlers));
+
+#ifdef DEBUG
+	puts("interrupt_init: initializing interrupt controller\n");
+#endif
+	i8259_init();
+
+#ifdef DEBUG
+	puts("Copying reset trampoline\n");
+#endif
+	/* WARNING: Assmues that the first megabyte is CACHEINHIBIT! */
+	memcpy((void *)0x100, new_reset, new_reset_end - new_reset);
+
+#ifdef DEBUG
+	PRINTF("interrupt_init: enabling interrupts (msr = %08x)\n",
+		get_msr());
+#endif
+	set_msr (get_msr() | MSR_EE);
+
+#ifdef DEBUG
+	PRINTF("interrupt_init: done. (msr = %08x)\n", get_msr());
+#endif
+
+}
+
+/****************************************************************************/
+
+/*
+ * Handle external interrupts
+ */
+void
+external_interrupt(struct pt_regs *regs)
+{
+    extern int i8259_irq(void);
+
+	int irq, unmask = 1;
+
+	irq = i8259_irq(); //i8259_get_irq(regs);
+//	printf("irq = %d, handler at %p ack=%d\n", irq, irq_handlers[irq].handler, *(volatile unsigned char *)0xFEF00000);
+	i8259_mask_and_ack(irq);
+
+	if (irq_handlers[irq].handler != NULL)
+		(*irq_handlers[irq].handler)(irq_handlers[irq].arg);
+	else {
+		PRINTF ("\nBogus External Interrupt IRQ %d\n", irq);
+		/*
+	 	* turn off the bogus interrupt, otherwise it
+	 	* might repeat forever
+	 	*/
+		unmask = 0;
+	}
+
+	if (unmask) i8259_unmask_irq(irq);
+}
+
+volatile ulong timestamp = 0;
+
+/*
+ * timer_interrupt - gets called when the decrementer overflows,
+ * with interrupts disabled.
+ * Trivial implementation - no need to be really accurate.
+ */
+void
+timer_interrupt(struct pt_regs *regs)
+{
+	set_dec(decrementer_count);
+	timestamp++;
+}
+
+/****************************************************************************/
+
+void
+reset_timer(void)
+{
+	timestamp = 0;
+}
+
+ulong
+get_timer(ulong base)
+{
+	return (timestamp - base);
+}
+
+void
+set_timer(ulong t)
+{
+	timestamp = t;
+}
+
+/****************************************************************************/
+
+/*
+ * Install and free a interrupt handler.
+ */
+
+void
+irq_install_handler(int irq, interrupt_handler_t *handler, void *arg)
+{
+	if (irq < 0 || irq >= NR_IRQS) {
+		PRINTF("irq_install_handler: bad irq number %d\n", irq);
+		return;
+	}
+
+	if (irq_handlers[irq].handler != NULL)
+		PRINTF("irq_install_handler: 0x%08lx replacing 0x%08lx\n",
+		       (ulong)handler, (ulong)irq_handlers[irq].handler);
+
+	irq_handlers[irq].handler = handler;
+	irq_handlers[irq].arg     = arg;
+
+	i8259_unmask_irq(irq);
+}
+
+void
+irq_free_handler(int irq)
+{
+	if (irq < 0 || irq >= NR_IRQS) {
+		PRINTF("irq_free_handler: bad irq number %d\n", irq);
+		return;
+	}
+
+	i8259_mask_irq(irq);
+
+	irq_handlers[irq].handler = NULL;
+	irq_handlers[irq].arg     = NULL;
+}
+
+/****************************************************************************/
+
+void
+do_irqinfo(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+{
+	puts("IRQ related functions are unimplemented currently.\n");
+}
+
+
diff --git a/board/MAI/AmigaOneG3SE/macros.h b/board/MAI/AmigaOneG3SE/macros.h
new file mode 100644
index 00000000000..0fbe39b3ba8
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/macros.h
@@ -0,0 +1,84 @@
+
+#ifndef _MACROS_H
+#define _MACROS_H
+
+	/*
+	** Load a long integer into a register
+	*/
+      	.macro liw reg, value
+                lis \reg, \value@h
+                ori \reg, \reg, \value@l
+        .endm
+
+
+	/* 
+	** Generate config_addr request
+	** This macro expects the values in registers:
+	** r3 - bus
+	** r4 - devfn
+	** r5 - offset
+	*/
+	.macro config_addr 	
+		rlwinm	r9, r5, 24, 0, 6
+		rlwinm	r8, r4, 16, 0, 31
+		rlwinm	r7, r3, 8, 0, 31
+		or	r9, r8, r9
+		or	r9, r7, r9
+		ori	r9, r9, 0x80
+		liw	r10, 0xfec00cf8
+		stw	r9, 0(r10)
+		eieio
+		sync
+	.endm
+
+	
+	/*
+	** Generate config_data address
+	*/
+	.macro config_data mask
+		andi.	r9, r5, \mask
+		addi	r9, r9, 0xcfc
+		oris	r9, r9, 0xfee0
+	.endm
+
+
+	/*
+	** Write a byte value to an output port
+	*/
+        .macro outb port, value
+                lis     r2, 0xfe00
+                li      r0, \value
+                stb     r0, \port(r2)
+        .endm
+
+
+	/*
+	** Write a register byte value to an output port
+	*/
+        .macro outbr port, value
+                lis     r2, 0xfe00
+                stb     \value, \port(r2)
+        .endm
+
+
+	/* 
+	** Read a byte value from a port into a specified register
+	*/
+        .macro inb reg, port
+                lis     r2, 0xfe00
+                lbz     \reg, \port(r2)
+        .endm
+
+
+	/*
+	** Write a byte to the SuperIO config area
+	*/
+        .macro siowb offset, value
+                li      r3, 0
+                li      r4, (7<<3)
+                li      r5, \offset
+                li      r6, \value
+                bl      pci_write_cfg_byte
+        .endm
+
+#endif
diff --git a/board/MAI/AmigaOneG3SE/memio.S b/board/MAI/AmigaOneG3SE/memio.S
new file mode 100644
index 00000000000..c4a09aab101
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/memio.S
@@ -0,0 +1,74 @@
+#include	"macros.h"
+
+	
+
+	.globl pci_read_cfg_byte
+	
+pci_read_cfg_byte:
+	config_addr
+	config_data	3
+	eieio
+	sync
+	lbz	r3, 0(r9)
+	blr
+
+	
+
+	.globl pci_write_cfg_byte
+	
+pci_write_cfg_byte:	
+	config_addr
+	config_data	3
+	stb	r6, 0(r9)
+	eieio
+	sync
+	blr
+
+
+
+	.globl pci_read_cfg_word
+	
+pci_read_cfg_word:
+	config_addr
+	config_data	2
+	lhbrx	r3, 0, r9
+	eieio
+	sync
+	blr
+
+
+	
+	.globl pci_write_cfg_word
+	
+pci_write_cfg_word:
+	config_addr
+	config_data	2
+	sthbrx	r6, 0, r9
+	eieio
+	sync
+	blr
+
+	
+
+	.globl pci_read_cfg_long
+	
+pci_read_cfg_long:
+	config_addr
+	config_data	0
+	lwbrx	r3, 0, r9
+	eieio
+	sync
+	blr
+
+
+
+	.globl pci_write_cfg_long
+	
+pci_write_cfg_long:
+	config_addr
+	config_data	0
+	stwbrx	r6, 0, r9
+	eieio
+	sync
+	blr
+
diff --git a/board/MAI/AmigaOneG3SE/memio.h b/board/MAI/AmigaOneG3SE/memio.h
new file mode 100644
index 00000000000..df0839f91dc
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/memio.h
@@ -0,0 +1,113 @@
+/*
+ * Memory mapped IO
+ *
+ * (C) Copyright 2002
+ * Hyperion Entertainment, ThomasF@hyperion-entertainment.com 
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ * You may also use this under a BSD license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	
+ *
+ */ 
+
+#ifndef _MEMIO_H
+#define _MEMIO_H
+
+#include "short_types.h"
+
+#define IOBASE 0xFE000000
+
+#define in_byte(from) read_byte( (uint8 *)(IOBASE | (from)))
+#define in_word(from) read_word_little((uint16 *)(IOBASE | (from)))
+#define in_long(from) read_long_little((uint32 *)(IOBASE | (from)))
+#define out_byte(to, val) write_byte((uint8 *)(IOBASE | (to)), val)
+#define out_word(to, val) write_word_little((uint16 *)(IOBASE | (to)), val)
+#define out_long(to, val) write_long_little((uint32 *)(IOBASE | (to)), val)
+
+
+static inline uint8 read_byte(volatile uint8 *from)
+{
+    int x;
+    asm volatile ("lbz %0,%1\n eieio\n sync" : "=r" (x) : "m" (*from));
+    return (uint8)x;
+}
+
+
+static inline void write_byte(volatile uint8 *to, uint8 x)
+{
+    asm volatile ("stb %1,%0\n eieio\n sync" : "=m" (*to) : "r" (x));
+}
+
+static inline uint16 read_word_little(volatile uint16 *from)
+{
+    int x;
+    asm volatile ("lhbrx %0,0,%1\n eieio\n sync" : "=r" (x) : "r" (from), "m" (*from));
+    return (uint16)x;
+}
+
+static inline uint16 read_word_big(volatile uint16 *from)
+{
+    int x;
+    asm volatile ("lhz %0,%1\n eieio\n sync" : "=r" (x) : "m" (*from));
+    return (uint16)x;
+}
+
+static inline void write_word_little(volatile uint16 *to, int x)
+{
+    asm volatile ("sthbrx %1,0,%2\n eieio\n sync" : "=m" (*to) : "r" (x), "r" (to));
+}
+
+static inline void write_word_big(volatile uint16 *to, int x)
+{
+    asm volatile ("sth %1,%0\n eieio\n sync" : "=m" (*to) : "r" (x));
+}
+
+static inline uint32 read_long_little(volatile uint32 *from)
+{
+    unsigned long x;
+    asm volatile ("lwbrx %0,0,%1\n eieio\n sync" : "=r" (x) : "r" (from), "m"(*from));
+    return (uint32)x;
+}
+
+static inline uint32 read_long_big(volatile uint32 *from)
+{
+    unsigned long x;
+    asm volatile ("lwz %0,%1\n eieio\n sync" : "=r" (x) : "m" (*from));
+    return (uint32)x;
+}
+
+static inline void write_long_little(volatile uint32 *to, uint32 x)
+{
+    asm volatile ("stwbrx %1,0,%2\n eieio\n sync" : "=m" (*to) : "r" (x), "r" (to));
+}
+
+static inline void write_long_big(volatile uint32 *to, uint32 x)
+{
+    asm volatile ("stw %1,%0\n eieio\n sync" : "=m" (*to) : "r" (x));
+}
+
+#define CONFIG_ADDR(bus, devfn, offset) \
+    write_long_big((uint32 *)0xFEC00CF8,           \
+                   ((offset & 0xFC)<<24) | (devfn << 16)  \
+                   | (bus<<8) | 0x80);
+#define CONFIG_DATA(offset,mask) ((void *)(0xFEE00CFC+(offset & mask)))
+
+
+uint8 pci_read_cfg_byte(int32 bus, int32 devfn, int32 offset);
+void pci_write_cfg_byte(int32 bus, int32 devfn, int32 offset, uint8 x);
+uint16 pci_read_cfg_word(int32 bus, int32 devfn, int32 offset);
+void pci_write_cfg_word(int32 bus, int32 devfn, int32 offset, uint16 x);
+uint32 pci_read_cfg_long(int32 bus, int32 devfn, int32 offset);
+void pci_write_cfg_long(int32 bus, int32 devfn, int32 offset, uint32 x);
+
+
+#endif
diff --git a/board/MAI/AmigaOneG3SE/memory_dump b/board/MAI/AmigaOneG3SE/memory_dump
new file mode 100644
index 00000000000..65e79362a6d
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/memory_dump
@@ -0,0 +1,30 @@
+64 MB:
+0x00: 80 08 04 0c 09 01 40 00 01 a0 60 00 80 08 00 01
+0x10: 8f 04 04 01 01 00 06 a0 60 00 00 14 10 14 2d 10
+0x20: 20 10 20 10 00 00 00 00 00 00 00 00 00 00 00 00
+0x30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 f2
+0x40: 7f 61 00 00 00 00 00 00 46 04 00 ff ff ff ff ff
+0x50: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+0x60: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+0x70: ff ff ff ff ff ff ff ff ff ff ff ff ff ff 64 f4
+
+512 MB:
+0x00: 80 08 04 0d 0a 02 40 00 01 75 54 00 82 08 00 01
+0x10: 8f 04 04 01 01 00 0f 00 00 00 00 14 0f 14 2d 40
+0x20: 15 08 15 08 00 00 00 00 00 00 00 00 00 00 00 00
+0x30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 d2
+0x40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+0x50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+0x60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+0x70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 64 fd
+
+256 MB:
+0x00: 80 08 04 0c 0a 02 40 00 01 75 54 00 80 08 00 01
+0x10: 8f 04 06 01 01 00 0e a0 60 00 00 14 0f 14 2d 20
+0x20: 15 08 15 08 00 00 00 00 00 00 00 00 00 00 00 00
+0x30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 b0
+0x40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+0x50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+0x60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+0x70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 64 f6
+
diff --git a/board/MAI/AmigaOneG3SE/nvram.c b/board/MAI/AmigaOneG3SE/nvram.c
new file mode 100644
index 00000000000..5dde15b6a75
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/nvram.c
@@ -0,0 +1,37 @@
+/*
+ * (C) Copyright 2002
+ * Thomas Frieden, Hyperion Entertainment 
+ * ThomasF@hyperion-entertainment.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include "memio.h"
+
+void enable_nvram(void)
+{
+    pci_write_cfg_byte(0, 0, 0x56, 0x0b);
+}
+
+void disable_nvram(void)
+{
+    pci_write_cfg_byte(0, 0, 0x56, 0x0);
+}
+
diff --git a/board/MAI/AmigaOneG3SE/ps2kbd.c b/board/MAI/AmigaOneG3SE/ps2kbd.c
new file mode 100644
index 00000000000..a6d67beecd9
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/ps2kbd.c
@@ -0,0 +1,699 @@
+/*
+ * (C) Copyright 2002
+ * John W. Linville, linville@tuxdriver.com
+ * 
+ * Modified from code for support of MIP405 and PIP405 boards.  Previous
+ * copyright follows.
+ *
+ * (C) Copyright 2001
+ * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Source partly derived from:
+ * linux/drivers/char/pc_keyb.c
+ *
+ *
+ */
+#include <common.h>
+#include <asm/processor.h>
+#include <devices.h>
+#include "ps2kbd.h"
+
+
+unsigned char kbd_read_status(void);
+unsigned char kbd_read_input(void);
+void kbd_send_data(unsigned char data);
+void i8259_mask_irq(unsigned int irq);
+void i8259_unmask_irq(unsigned int irq);
+
+/* used only by send_data - set by keyboard_interrupt */
+
+
+#undef KBG_DEBUG
+//#define KBG_DEBUG
+
+#ifdef KBG_DEBUG
+#define	PRINTF(fmt,args...)	printf (fmt ,##args)
+#else
+#define PRINTF(fmt,args...)
+#endif
+
+#define KBD_STAT_KOBF		0x01
+#define KBD_STAT_IBF		0x02
+#define KBD_STAT_SYS		0x04
+#define KBD_STAT_CD			0x08
+#define KBD_STAT_LOCK		0x10
+#define KBD_STAT_MOBF		0x20
+#define KBD_STAT_TI_OUT	0x40
+#define KBD_STAT_PARERR	0x80
+
+#define KBD_INIT_TIMEOUT 2000		/* Timeout in ms for initializing the keyboard */
+#define KBC_TIMEOUT 250			/* Timeout in ms for sending to keyboard controller */
+#define KBD_TIMEOUT 2000		/* Timeout in ms for keyboard command acknowledge */
+/*
+ *	Keyboard Controller Commands
+ */
+
+#define KBD_CCMD_READ_MODE			0x20	/* Read mode bits */
+#define KBD_CCMD_WRITE_MODE			0x60	/* Write mode bits */
+#define KBD_CCMD_GET_VERSION		0xA1	/* Get controller version */
+#define KBD_CCMD_MOUSE_DISABLE	0xA7	/* Disable mouse interface */
+#define KBD_CCMD_MOUSE_ENABLE		0xA8	/* Enable mouse interface */
+#define KBD_CCMD_TEST_MOUSE			0xA9	/* Mouse interface test */
+#define KBD_CCMD_SELF_TEST			0xAA	/* Controller self test */
+#define KBD_CCMD_KBD_TEST				0xAB	/* Keyboard interface test */
+#define KBD_CCMD_KBD_DISABLE		0xAD	/* Keyboard interface disable */
+#define KBD_CCMD_KBD_ENABLE			0xAE	/* Keyboard interface enable */
+#define KBD_CCMD_WRITE_AUX_OBUF	0xD3    /* Write to output buffer as if
+					   initiated by the auxiliary device */
+#define KBD_CCMD_WRITE_MOUSE		0xD4	/* Write the following byte to the mouse */
+
+/*
+ *	Keyboard Commands
+ */
+
+#define KBD_CMD_SET_LEDS				0xED	/* Set keyboard leds */
+#define KBD_CMD_SET_RATE				0xF3	/* Set typematic rate */
+#define KBD_CMD_ENABLE					0xF4	/* Enable scanning */
+#define KBD_CMD_DISABLE					0xF5	/* Disable scanning */
+#define KBD_CMD_RESET						0xFF	/* Reset */
+
+/*
+ *	Keyboard Replies
+ */
+
+#define KBD_REPLY_POR						0xAA	/* Power on reset */
+#define KBD_REPLY_ACK						0xFA	/* Command ACK */
+#define KBD_REPLY_RESEND				0xFE	/* Command NACK, send the cmd again */
+
+/*
+ *	Status Register Bits
+ */
+
+#define KBD_STAT_OBF 						0x01	/* Keyboard output buffer full */
+#define KBD_STAT_IBF 						0x02	/* Keyboard input buffer full */
+#define KBD_STAT_SELFTEST				0x04	/* Self test successful */
+#define KBD_STAT_CMD						0x08	/* Last write was a command write (0=data) */
+#define KBD_STAT_UNLOCKED				0x10	/* Zero if keyboard locked */
+#define KBD_STAT_MOUSE_OBF			0x20	/* Mouse output buffer full */
+#define KBD_STAT_GTO 						0x40	/* General receive/xmit timeout */
+#define KBD_STAT_PERR 					0x80	/* Parity error */
+
+#define AUX_STAT_OBF (KBD_STAT_OBF | KBD_STAT_MOUSE_OBF)
+
+/*
+ *	Controller Mode Register Bits
+ */
+
+#define KBD_MODE_KBD_INT				0x01	/* Keyboard data generate IRQ1 */
+#define KBD_MODE_MOUSE_INT			0x02	/* Mouse data generate IRQ12 */
+#define KBD_MODE_SYS 						0x04	/* The system flag (?) */
+#define KBD_MODE_NO_KEYLOCK			0x08	/* The keylock doesn't affect the keyboard if set */
+#define KBD_MODE_DISABLE_KBD		0x10	/* Disable keyboard interface */
+#define KBD_MODE_DISABLE_MOUSE	0x20	/* Disable mouse interface */
+#define KBD_MODE_KCC 						0x40	/* Scan code conversion to PC format */
+#define KBD_MODE_RFU						0x80
+
+
+#define KDB_DATA_PORT			0x60
+#define KDB_COMMAND_PORT	0x64
+
+#define 	LED_SCR		0x01	/* scroll lock led */
+#define 	LED_CAP		0x04	/* caps lock led */
+#define 	LED_NUM		0x02	/* num lock led */
+
+#define 	KBD_BUFFER_LEN 0x20  /* size of the keyboardbuffer */
+
+
+
+
+static volatile char kbd_buffer[KBD_BUFFER_LEN];
+static volatile int in_pointer = 0;
+static volatile int out_pointer = 0;
+
+
+static unsigned char num_lock = 0;
+static unsigned char caps_lock = 0;
+static unsigned char scroll_lock = 0;
+static unsigned char shift = 0;
+static unsigned char ctrl = 0;
+static unsigned char alt = 0;
+static unsigned char e0 = 0;
+static unsigned char leds = 0;
+
+#define DEVNAME "ps2kbd"
+
+/* Simple translation table for the keys */
+
+static unsigned char kbd_plain_xlate[] = {
+	0xff,0x1b, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=','\b','\t',	/* 0x00 - 0x0f */
+	 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']','\r',0xff, 'a', 's',	/* 0x10 - 0x1f */
+	 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';','\'', '`',0xff,'\\', 'z', 'x', 'c', 'v',	/* 0x20 - 0x2f */
+	 'b', 'n', 'm', ',', '.', '/',0xff,0xff,0xff, ' ',0xff,0xff,0xff,0xff,0xff,0xff,	/* 0x30 - 0x3f */
+	0xff,0xff,0xff,0xff,0xff,0xff,0xff, '7', '8', '9', '-', '4', '5', '6', '+', '1',	/* 0x40 - 0x4f */
+	 '2', '3', '0', '.',0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,  /* 0x50 - 0x5F */
+	'\r',0xff,0xff
+	};
+	  	  
+static unsigned char kbd_shift_xlate[] = {
+	0xff,0x1b, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+','\b','\t',	/* 0x00 - 0x0f */
+	 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}','\r',0xff, 'A', 'S',	/* 0x10 - 0x1f */
+	 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~',0xff, '|', 'Z', 'X', 'C', 'V',	/* 0x20 - 0x2f */
+	 'B', 'N', 'M', '<', '>', '?',0xff,0xff,0xff, ' ',0xff,0xff,0xff,0xff,0xff,0xff,	/* 0x30 - 0x3f */
+	0xff,0xff,0xff,0xff,0xff,0xff,0xff, '7', '8', '9', '-', '4', '5', '6', '+', '1',	/* 0x40 - 0x4f */
+	 '2', '3', '0', '.',0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,  /* 0x50 - 0x5F */
+	'\r',0xff,0xff
+	};
+
+static unsigned char kbd_ctrl_xlate[] = {
+	0xff,0x1b, '1',0x00, '3', '4', '5',0x1E, '7', '8', '9', '0',0x1F, '=','\b','\t',	/* 0x00 - 0x0f */
+	0x11,0x17,0x05,0x12,0x14,0x18,0x15,0x09,0x0f,0x10,0x1b,0x1d,'\n',0xff,0x01,0x13,	/* 0x10 - 0x1f */
+	0x04,0x06,0x08,0x09,0x0a,0x0b,0x0c, ';','\'', '~',0x00,0x1c,0x1a,0x18,0x03,0x16,	/* 0x20 - 0x2f */
+	0x02,0x0e,0x0d, '<', '>', '?',0xff,0xff,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,	/* 0x30 - 0x3f */
+	0xff,0xff,0xff,0xff,0xff,0xff,0xff, '7', '8', '9', '-', '4', '5', '6', '+', '1',	/* 0x40 - 0x4f */
+	 '2', '3', '0', '.',0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,  /* 0x50 - 0x5F */
+	'\r',0xff,0xff
+	};
+
+/******************************************************************
+ * Init 
+ ******************************************************************/
+
+int isa_kbd_init(void)
+{
+	char* result;
+	result=kbd_initialize();
+	if (result != NULL)
+	{
+	    result = kbd_initialize();
+	}
+	if(result==NULL) {
+		printf("AT Keyboard initialized\n");
+		irq_install_handler(KBD_INTERRUPT, (interrupt_handler_t *)kbd_interrupt, NULL);
+		return (1);
+	}
+	else {
+		printf("%s\n",result);
+		return (-1);
+	}
+}
+
+#ifdef CFG_CONSOLE_OVERWRITE_ROUTINE
+extern int overwrite_console (void);
+#else
+int overwrite_console (void)
+{
+	return (0);
+}
+#endif
+
+int drv_isa_kbd_init (void)
+{
+	int error;
+  	device_t kbddev ;
+	char *stdinname  = getenv ("stdin");
+
+	if(isa_kbd_init()==-1)
+		return -1;
+  	memset (&kbddev, 0, sizeof(kbddev));
+  	strcpy(kbddev.name, DEVNAME);
+  	kbddev.flags =  DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
+  	kbddev.putc = NULL ;
+	kbddev.puts = NULL ;
+	kbddev.getc = kbd_getc ;
+	kbddev.tstc = kbd_testc ;
+
+ 	error = device_register (&kbddev);
+	if(error==0) {
+		/* check if this is the standard input device */
+		if(strcmp(stdinname,DEVNAME)==0) {
+			/* reassign the console */
+			if(overwrite_console()) {
+				return 1;
+			}
+			error=console_assign(stdin,DEVNAME);
+			if(error==0)
+				return 1;
+			else 
+				return error;
+		}
+		return 1;
+	}
+	return error;
+}
+
+/******************************************************************
+ * Queue handling 
+ ******************************************************************/
+/* puts character in the queue and sets up the in and out pointer */
+void kbd_put_queue(char data)
+{
+	if((in_pointer+1)==KBD_BUFFER_LEN) {
+		if(out_pointer==0) {
+			return; /* buffer full */
+		} else{
+			in_pointer=0;
+		}
+	} else {
+		if((in_pointer+1)==out_pointer)
+			return; /* buffer full */
+		in_pointer++;
+	}
+	kbd_buffer[in_pointer]=data;
+	return;
+}
+
+/* test if a character is in the queue */
+int kbd_testc(void)
+{
+	if(in_pointer==out_pointer)
+		return(0); /* no data */
+	else
+		return(1);	
+}
+/* gets the character from the queue */
+int kbd_getc(void)
+{
+	char c;
+
+	while(in_pointer==out_pointer);
+	if((out_pointer+1)==KBD_BUFFER_LEN) 
+		out_pointer=0;
+	else
+		out_pointer++;
+	c=kbd_buffer[out_pointer];
+	return (int)c;
+	
+}
+
+
+/* set LEDs */
+
+void kbd_set_leds(void)
+{
+	if(caps_lock==0)
+		leds&=~LED_CAP; /* switch caps_lock off */
+	else
+		leds|=LED_CAP; /* switch on LED */
+	if(num_lock==0)
+		leds&=~LED_NUM; /* switch LED off */
+	else
+		leds|=LED_NUM;  /* switch on LED */
+	if(scroll_lock==0)
+		leds&=~LED_SCR; /* switch LED off */
+	else
+		leds|=LED_SCR; /* switch on LED */
+	kbd_send_data(KBD_CMD_SET_LEDS);
+	kbd_send_data(leds);
+}
+	
+
+void handle_keyboard_event(unsigned char scancode)
+{
+	unsigned char keycode;
+
+	/*  Convert scancode to keycode */
+	PRINTF("scancode %x\n",scancode);
+	if(scancode==0xe0) {
+		e0=1; /* special charakters */
+		return;
+	}
+	if(e0==1) {
+		e0=0; /* delete flag */
+		if(!(	((scancode&0x7F)==0x38)|| /* the right ctrl key */
+			((scancode&0x7F)==0x1D)|| /* the right alt key */
+			((scancode&0x7F)==0x35)||	/* the right '/' key */
+			((scancode&0x7F)==0x1C)||  /* the right enter key */
+			((scancode)==0x48)|| /* arrow up */
+			((scancode)==0x50)|| /* arrow down */
+			((scancode)==0x4b)|| /* arrow left */
+			((scancode)==0x4d)))  /* arrow right */
+			/* we swallow unknown e0 codes */
+			return;
+	}
+	/* special cntrl keys */
+	switch(scancode)
+	{
+	case 0x48:
+	    kbd_put_queue(27);
+	    kbd_put_queue(91);
+	    kbd_put_queue('A');
+	    return;
+	case 0x50:
+	    kbd_put_queue(27);
+	    kbd_put_queue(91);
+	    kbd_put_queue('B');
+	    return;
+	case 0x4b:
+	    kbd_put_queue(27);
+	    kbd_put_queue(91);
+	    kbd_put_queue('D');
+	    return;
+	case 0x4D:
+	    kbd_put_queue(27);
+	    kbd_put_queue(91);
+	    kbd_put_queue('C');
+	    return;
+	case 0x58: /* F12 key */
+	    if (ctrl == 1)
+	    {
+		extern int console_changed;
+		setenv("stdin", DEVNAME);
+		setenv("stdout", "vga");
+		console_changed = 1;
+	    }
+	    return;
+	case 0x2A: 
+		case 0x36: /* shift pressed */
+			shift=1;
+			return; /* do nothing else */
+		case 0xAA: 
+		case 0xB6: /* shift released */
+			shift=0;
+			return; /* do nothing else */
+		case 0x38: /* alt pressed */
+			alt=1;
+			return; /* do nothing else */
+		case 0xB8: /* alt released */
+			alt=0;
+			return; /* do nothing else */
+		case 0x1d: /* ctrl pressed */
+			ctrl=1;
+			return; /* do nothing else */
+		case 0x9d: /* ctrl released */
+			ctrl=0;
+			return; /* do nothing else */
+		case 0x46: /* scrollock pressed */
+			scroll_lock=~scroll_lock;
+			kbd_set_leds();
+			return; /* do nothing else */
+		case 0x3A: /* capslock pressed */
+			caps_lock=~caps_lock;
+			kbd_set_leds();
+			return; 
+		case 0x45: /* numlock pressed */
+			num_lock=~num_lock;
+			kbd_set_leds();
+			return; 
+		case 0xC6: /* scroll lock released */
+		case 0xC5: /* num lock released */
+		case 0xBA: /* caps lock released */
+			return; /* just swallow */ 
+	}
+	if((scancode&0x80)==0x80) /* key released */
+		return;
+	/* now, decide which table we need */
+	if(scancode > (sizeof(kbd_plain_xlate)/sizeof(kbd_plain_xlate[0]))) { /* scancode not in list */
+		PRINTF("unkown scancode %X\n",scancode);
+		return; /* swallow it */
+	}
+	/* setup plain code first */
+	keycode=kbd_plain_xlate[scancode];
+	if(caps_lock==1) { /* caps_lock is pressed, overwrite plain code */
+		if(scancode > (sizeof(kbd_shift_xlate)/sizeof(kbd_shift_xlate[0]))) { /* scancode not in list */
+			PRINTF("unkown caps-locked scancode %X\n",scancode);
+			return; /* swallow it */
+		}
+		keycode=kbd_shift_xlate[scancode];
+		if(keycode<'A') { /* we only want the alphas capital */
+			keycode=kbd_plain_xlate[scancode];
+		}
+	}
+	if(shift==1) { /* shift overwrites caps_lock */
+		if(scancode > (sizeof(kbd_shift_xlate)/sizeof(kbd_shift_xlate[0]))) { /* scancode not in list */
+			PRINTF("unkown shifted scancode %X\n",scancode);
+			return; /* swallow it */
+		}
+		keycode=kbd_shift_xlate[scancode];
+	}
+	if(ctrl==1) { /* ctrl overwrites caps_lock and shift */
+		if(scancode > (sizeof(kbd_ctrl_xlate)/sizeof(kbd_ctrl_xlate[0]))) { /* scancode not in list */
+			PRINTF("unkown ctrl scancode %X\n",scancode);
+			return; /* swallow it */
+		}
+		keycode=kbd_ctrl_xlate[scancode];
+	}
+	/* check if valid keycode */
+	if(keycode==0xff) {
+		PRINTF("unkown scancode %X\n",scancode);
+		return; /* swallow unknown codes */
+	}
+	
+	kbd_put_queue(keycode);
+	PRINTF("%x\n",keycode);
+}
+
+/*
+ * This reads the keyboard status port, and does the
+ * appropriate action.
+ *
+ */
+unsigned char handle_kbd_event(void)
+{
+	unsigned char status = kbd_read_status();
+	unsigned int work = 10000;
+
+	while ((--work > 0) && (status & KBD_STAT_OBF)) {
+		unsigned char scancode;
+
+		scancode = kbd_read_input();
+
+		/* Error bytes must be ignored to make the
+		   Synaptics touchpads compaq use work */
+		/* Ignore error bytes */
+		if (!(status & (KBD_STAT_GTO | KBD_STAT_PERR)))
+		{
+			if (status & KBD_STAT_MOUSE_OBF)
+				; /* not supported: handle_mouse_event(scancode); */
+			else
+				handle_keyboard_event(scancode);
+		}
+		status = kbd_read_status();
+	}
+	if (!work)
+		PRINTF("pc_keyb: controller jammed (0x%02X).\n", status);
+	return status;
+}
+
+
+
+/******************************************************************************
+ * Lowlevel Part of keyboard section
+ */  
+unsigned char kbd_read_status(void)
+{
+	return(in8(CFG_ISA_IO_BASE_ADDRESS + KDB_COMMAND_PORT));
+} 
+  
+unsigned char kbd_read_input(void)
+{
+	return(in8(CFG_ISA_IO_BASE_ADDRESS + KDB_DATA_PORT));
+} 
+
+void kbd_write_command(unsigned char cmd)
+{
+	out8(CFG_ISA_IO_BASE_ADDRESS + KDB_COMMAND_PORT,cmd);
+} 
+  
+void kbd_write_output(unsigned char data)
+{
+	out8(CFG_ISA_IO_BASE_ADDRESS + KDB_DATA_PORT, data);
+} 
+ 
+int kbd_read_data(void)
+{
+	int val;
+	unsigned char status;
+
+	val=-1;
+	status = kbd_read_status();
+	if (status & KBD_STAT_OBF) {
+		val = kbd_read_input();
+		if (status & (KBD_STAT_GTO | KBD_STAT_PERR))
+			val = -2;
+	}
+	return val;
+}
+
+int kbd_wait_for_input(void)
+{
+	unsigned long timeout;
+	int val;
+	
+	timeout = KBD_TIMEOUT;
+	val=kbd_read_data();
+	while(val < 0)
+	{
+		if(timeout--==0)
+			return -1;
+		udelay(1000);
+		val=kbd_read_data();
+	}
+	return val;
+}
+
+
+int kb_wait(void)
+{
+	unsigned long timeout = KBC_TIMEOUT * 10;
+
+	do {
+		unsigned char status = handle_kbd_event();
+		if (!(status & KBD_STAT_IBF))
+			return 0; /* ok */
+		udelay(1000);
+		timeout--;
+	} while (timeout);
+	return 1;
+}
+
+void kbd_write_command_w(int data)
+{
+	if(kb_wait())
+		PRINTF("timeout in kbd_write_command_w\n");
+	kbd_write_command(data);
+}
+
+void kbd_write_output_w(int data)
+{
+	if(kb_wait())
+		PRINTF("timeout in kbd_write_output_w\n");
+	kbd_write_output(data);
+}
+
+void kbd_send_data(unsigned char data)
+{
+	unsigned char status;
+	i8259_mask_irq(KBD_INTERRUPT); /* disable interrupt */
+	kbd_write_output_w(data);
+	status = kbd_wait_for_input();
+	if (status == KBD_REPLY_ACK)
+		i8259_unmask_irq(KBD_INTERRUPT); /* enable interrupt */
+}
+
+
+char * kbd_initialize(void)
+{
+	int status;
+
+	in_pointer = 0; /* delete in Buffer */
+	out_pointer = 0;
+	/*
+	 * Test the keyboard interface.
+	 * This seems to be the only way to get it going.
+	 * If the test is successful a x55 is placed in the input buffer.
+	 */
+	kbd_write_command_w(KBD_CCMD_SELF_TEST);
+	if (kbd_wait_for_input() != 0x55) 
+		return "Kbd:   failed self test";
+	/*
+	 * Perform a keyboard interface test.  This causes the controller
+	 * to test the keyboard clock and data lines.  The results of the
+	 * test are placed in the input buffer.
+	 */
+	kbd_write_command_w(KBD_CCMD_KBD_TEST);
+	if (kbd_wait_for_input() != 0x00) 
+		return "Kbd:   interface failed self test";
+	/*
+	 * Enable the keyboard by allowing the keyboard clock to run.
+	 */
+	kbd_write_command_w(KBD_CCMD_KBD_ENABLE);
+	status = kbd_wait_for_input();
+	/*
+	 * Reset keyboard. If the read times out
+	 * then the assumption is that no keyboard is
+	 * plugged into the machine.
+	 * This defaults the keyboard to scan-code set 2.
+	 *
+	 * Set up to try again if the keyboard asks for RESEND.
+	 */
+	do {
+		kbd_write_output_w(KBD_CMD_RESET);
+		status = kbd_wait_for_input();
+		if (status == KBD_REPLY_ACK) 
+			break;
+		if (status != KBD_REPLY_RESEND)
+		{
+			PRINTF("status: %X\n",status);
+			return "Kbd:   reset failed, no ACK";
+		}
+	} while (1);
+	if (kbd_wait_for_input() != KBD_REPLY_POR)
+		return "Kbd:   reset failed, no POR";
+
+	/*
+	 * Set keyboard controller mode. During this, the keyboard should be
+	 * in the disabled state.
+	 *
+	 * Set up to try again if the keyboard asks for RESEND.
+	 */
+	do {
+		kbd_write_output_w(KBD_CMD_DISABLE);
+		status = kbd_wait_for_input();
+		if (status == KBD_REPLY_ACK)
+			break;
+		if (status != KBD_REPLY_RESEND)
+			return "Kbd:   disable keyboard: no ACK";
+	} while (1);
+
+	kbd_write_command_w(KBD_CCMD_WRITE_MODE);
+	kbd_write_output_w(KBD_MODE_KBD_INT
+			      | KBD_MODE_SYS
+			      | KBD_MODE_DISABLE_MOUSE
+			      | KBD_MODE_KCC);
+
+	/* ibm powerpc portables need this to use scan-code set 1 -- Cort */
+	kbd_write_command_w(KBD_CCMD_READ_MODE);
+	if (!(kbd_wait_for_input() & KBD_MODE_KCC)) {
+		/*
+		 * If the controller does not support conversion,
+		 * Set the keyboard to scan-code set 1.
+		 */
+		kbd_write_output_w(0xF0);
+		kbd_wait_for_input();
+		kbd_write_output_w(0x01);
+		kbd_wait_for_input();
+	}
+	kbd_write_output_w(KBD_CMD_ENABLE);
+	if (kbd_wait_for_input() != KBD_REPLY_ACK)
+		return "Kbd:   enable keyboard: no ACK";
+
+	/*
+	 * Finally, set the typematic rate to maximum.
+	 */
+	kbd_write_output_w(KBD_CMD_SET_RATE);
+	if (kbd_wait_for_input() != KBD_REPLY_ACK)
+		return "Kbd:   Set rate: no ACK";
+	kbd_write_output_w(0x00);
+	if (kbd_wait_for_input() != KBD_REPLY_ACK)
+		return "Kbd:   Set rate: no ACK";
+	return NULL;
+}
+
+void kbd_interrupt(void)
+{
+	handle_kbd_event();
+}
+
+
+
+/* eof */
+
diff --git a/board/MAI/AmigaOneG3SE/ps2kbd.h b/board/MAI/AmigaOneG3SE/ps2kbd.h
new file mode 100644
index 00000000000..95fc14d66ab
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/ps2kbd.h
@@ -0,0 +1,41 @@
+/*
+ * (C) Copyright 2002
+ * John W. Linville, linville@tuxdriver.com
+ * 
+ * Modified from code for support of MIP405 and PIP405 boards.  Previous
+ * copyright follows.
+ *
+ * (C) Copyright 2001
+ * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+#ifndef _KBD_H_
+#define _KBD_H_
+   
+extern int kbd_testc(void);
+extern int kbd_getc(void);
+extern void kbd_interrupt(void);
+extern char *kbd_initialize(void);
+
+unsigned char kbd_is_init(void);
+#define KBD_INTERRUPT 1
+#endif
diff --git a/board/MAI/AmigaOneG3SE/serial.c b/board/MAI/AmigaOneG3SE/serial.c
new file mode 100644
index 00000000000..e83fb46c735
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/serial.c
@@ -0,0 +1,247 @@
+#include <common.h>
+#include <ns16550.h>
+#include "short_types.h"
+#include "memio.h"
+#include "articiaS.h"
+
+#ifndef CFG_NS16550
+static uint32 ComPort1;
+
+uint16 SerialEcho = 1;
+
+
+#define RECEIVER_HOLDING 0
+#define TRANSMITTER_HOLDING 0
+#define INTERRUPT_ENABLE 1
+#define INTERRUPT_STATUS 2
+#define FIFO_CONTROL 2
+#define LINE_CONTROL 3
+#define MODEM_CONTROL 4
+#define LINE_STATUS 5
+#define MODEM_STATUS 6
+#define SCRATCH_PAD 7
+
+#define DIVISOR_LATCH_LSB 0
+#define DIVISOR_LATCH_MSB 1
+#define PRESCALER_DIVISION 5
+
+#define COM_WRITE_BYTE(reg, byte) out_byte((ComPort1+reg), byte)
+#define COM_READ_BYTE(reg) in_byte((ComPort1+reg))
+
+static int serial_init_done = 0;
+
+void serial_init (void)
+{
+#if 0
+	uint32 clock_divisor = 115200 / baudrate;
+	uint8 cfg;
+	uint8 a;
+	uint16 devfn = 7 << 3;
+
+	if (serial_init_done)
+		return;
+
+	/*  Enter configuration mode */
+	cfg = pci_read_cfg_byte (0, devfn, 0x85);
+	pci_write_cfg_byte (0, devfn, 0x85, cfg | 0x02);
+
+	/* Set serial port COM1 as 3F8 */
+	out_byte (0x3F0, 0xE7);
+	out_byte (0x3f1, 0xfe);
+
+	/* Set serial port COM2 as 2F8 */
+	out_byte (0x3f0, 0xe8);
+	out_byte (0x3f1, 0xeb);
+
+	/* Enable */
+	out_byte (0x3f0, 0xe2);
+	a = in_byte (0x3f1);
+	a |= 0xc;
+	out_byte (0x3f0, 0xe2);
+	out_byte (0x3f1, a);
+
+	/*  Reset the configuration mode */
+	pci_write_cfg_byte (0, devfn, 0x85, cfg);
+#endif
+
+	ComPort1 = 0x3F8;
+
+	/*  Disable interrupts */
+	COM_WRITE_BYTE (INTERRUPT_ENABLE, 0x00);
+
+	/*  Set baud rate */
+	/* COM_WRITE_BYTE(LINE_CONTROL, 0x83); */
+	/* COM_WRITE_BYTE(DIVISOR_LATCH_LSB, (uint8)(clock_divisor & 0xFF)); */
+	/* COM_WRITE_BYTE(DIVISOR_LATCH_MSB, (uint8)(clock_divisor >> 8)); */
+	/* __asm("eieio"); */
+
+	/*  Set 8-N-1 */
+	COM_WRITE_BYTE (LINE_CONTROL, 0x03);
+	__asm ("eieio");
+
+	/*  Disable FIFO */
+	COM_WRITE_BYTE (MODEM_CONTROL, 0x03);
+	COM_WRITE_BYTE (FIFO_CONTROL, 0x07);
+
+	__asm ("eieio");
+	serial_init_done = 1;
+}
+
+extern int console_changed;
+
+void serial_putc (const char sendme)
+{
+	if (sendme == '\n') {
+		while ((in_byte (0x3FD) & 0x40) == 0);
+		out_byte (0x3f8, 0x0D);
+	}
+
+	while ((in_byte (0x3FD) & 0x40) == 0);
+	out_byte (0x3f8, sendme);
+}
+
+int serial_getc (void)
+{
+#if 0
+	uint8 c;
+
+	for (;;) {
+		uint8 x = in_byte (0x3FD);
+
+		if (x & 0x01)
+			break;
+
+		if (x & 0x0C)
+			out_byte (0x3fd, 0x0c);
+	}
+
+	c = in_byte (0x3F8);
+
+	return c;
+#else
+	while ((in_byte (0x3FD) & 0x01) == 0) {
+		if (console_changed != 0) {
+			printf ("Console changed\n");
+			console_changed = 0;
+			return 0;
+		}
+	}
+	return in_byte (0x3F8);
+#endif
+}
+
+int serial_tstc (void)
+{
+	return (in_byte (0x03FD) & 0x01) != 0;
+}
+
+void serial_debug_putc (int c)
+{
+	serial_puts ("DBG");
+	serial_putc (c);
+	serial_putc (0x0d);
+	serial_putc (0x0A);
+}
+
+#else
+
+const NS16550_t Com0 = (NS16550_t) CFG_NS16550_COM1;
+const NS16550_t Com1 = (NS16550_t) CFG_NS16550_COM2;
+
+int serial_init (void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+
+	uint32 clock_divisor = 115200 / gd->baudrate;
+
+	NS16550_init (Com0, clock_divisor);
+	/* NS16550_reinit(Com1, clock_divisor); */
+	/* serial_puts("COM1: 3F8h initalized"); */
+
+	return (0);
+}
+
+#if 0
+void serial_putc (const char c)
+{
+	NS16550_putc (Com0, c);
+	if (c == '\n')
+		NS16550_putc (Com0, 0x0D);
+}
+
+int serial_getc (void)
+{
+	return (int) NS16550_getc (Com0);
+}
+
+int serial_tstc (void)
+{
+	return NS16550_tstc (Com0);
+}
+#else
+void serial_putc (const char sendme)
+{
+	if (sendme == '\n') {
+		while ((in_byte (0x3FD) & 0x40) == 0);
+		out_byte (0x3f8, 0x0D);
+	}
+
+	while ((in_byte (0x3FD) & 0x40) == 0);
+	out_byte (0x3f8, sendme);
+}
+
+
+extern int console_changed;
+
+int serial_getc (void)
+{
+#if 0
+	uint8 c;
+
+	for (;;) {
+		uint8 x = in_byte (0x3FD);
+
+		if (x & 0x01)
+			break;
+
+		if (x & 0x0C)
+			out_byte (0x3fd, 0x0c);
+	}
+
+	c = in_byte (0x3F8);
+
+	return c;
+#else
+	while ((in_byte (0x3FD) & 0x01) == 0) {
+		if (console_changed != 0) {
+			console_changed = 0;
+			return 0;
+		}
+	}
+
+	return in_byte (0x3F8);
+#endif
+}
+
+int serial_tstc (void)
+{
+	return (in_byte (0x03FD) & 0x01) != 0;
+}
+#endif
+
+#endif
+
+void serial_puts (const char *string)
+{
+	while (*string)
+		serial_putc (*string++);
+}
+
+void serial_setbrg (void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+
+	uint32 clock_divisor = 115200 / gd->baudrate;
+
+	NS16550_init (Com0, clock_divisor);
+}
diff --git a/board/MAI/AmigaOneG3SE/short_types.h b/board/MAI/AmigaOneG3SE/short_types.h
new file mode 100644
index 00000000000..22df3c92c46
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/short_types.h
@@ -0,0 +1,36 @@
+/*
+ * short type names
+ *
+ * (C) Copyright 2002
+ * Hyperion Entertainment, ThomasF@hyperion-entertainment.com 
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _SHORT_TYPES_H
+#define _SHORT_TYPES_H
+
+typedef unsigned long  uint32;
+typedef long           int32;
+typedef unsigned short uint16;
+typedef short          int16;
+typedef unsigned char  uint8;
+typedef signed char    int8;
+
+#endif
diff --git a/board/MAI/AmigaOneG3SE/smbus.c b/board/MAI/AmigaOneG3SE/smbus.c
new file mode 100644
index 00000000000..616005ea939
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/smbus.c
@@ -0,0 +1,206 @@
+#include "memio.h"
+#include "articiaS.h"
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+
+void sm_write_mode(void)
+{
+    out_byte(0xA539, 0x00);
+    out_byte(0xA53A, 0x03);
+}
+
+void sm_read_mode(void)
+{
+    out_byte(0xA53A, 0x02);
+    out_byte(0xA539, 0x02);
+}
+
+void sm_write_byte(uint8 writeme)
+{
+    int i;
+    int level;
+    
+    out_byte(0xA539, 0x00);
+
+    level = 0;
+
+    for (i=0; i<8; i++)
+    {
+	if ((writeme & 0x80) == (level<<7)) 
+        {
+	    /* Bit did not change, rewrite strobe */
+	    out_byte(0xA539, level | 0x02);
+	    out_byte(0xA539, level); 
+	}
+	else
+	{
+	    /* Bit changed, set bit, then strobe */
+	    level = (writeme & 0x80) >> 7;
+	    out_byte(0xA539, level);
+	    out_byte(0xA539, level | 0x02);
+	    out_byte(0xA539, level);
+	}
+	writeme <<= 1;
+    }
+    out_byte(0xA539, 0x00);
+}
+
+uint8 sm_read_byte(void)
+{
+    uint8 retme, r;
+    int i;
+
+    retme = 0;
+    for (i=0; i<8; i++)
+    {
+	retme <<= 1;
+	out_byte(0xA539, 0x00);
+	out_byte(0xA539, 0x02);
+	r = in_byte(0xA538) & 0x01;
+	retme |= r;
+    }
+
+    return retme;
+} 
+
+int sm_get_ack(void)
+{
+    uint8 r;
+    r = in_byte(0xA538);
+    if ((r&0x01) == 0) return TRUE;
+    else return FALSE;
+}
+
+void sm_write_ack(void)
+{
+    out_byte(0xA539, 0x00);
+    out_byte(0xA539, 0x02);
+    out_byte(0xA539, 0x00);
+}
+
+void sm_write_nack(void)
+{
+    out_byte(0xA539, 0x01);
+    out_byte(0xA539, 0x03);
+    out_byte(0xA539, 0x01);
+}
+
+void sm_send_start(void)
+{
+    out_byte(0xA539, 0x03);
+    out_byte(0xA539, 0x02);
+}
+
+void sm_send_stop(void)
+{
+    out_byte(0xA539, 0x02);
+    out_byte(0xA539, 0x03);
+}
+
+int sm_read_byte_from_device(uint8 addr, uint8 reg, uint8 *storage)
+{
+    // S Addr Wr
+    sm_write_mode();
+    sm_send_start();
+    sm_write_byte((addr<<1));
+    
+    // [A]
+    sm_read_mode();
+    if (sm_get_ack() == FALSE) return FALSE;
+
+    // Comm
+    sm_write_mode();
+    sm_write_byte(reg);
+    
+    // [A]
+    sm_read_mode();
+    if (sm_get_ack() == FALSE) return FALSE;
+
+    // S Addr Rd
+    sm_write_mode();
+    sm_send_start();
+    sm_write_byte((addr<<1)|1);
+    
+    // [A]
+    sm_read_mode();
+    if (sm_get_ack() == FALSE) return FALSE;
+
+    // [Data]
+    *storage = sm_read_byte();
+    
+    // NA
+    sm_write_mode();
+    sm_write_nack();
+    sm_send_stop();
+
+    return TRUE;
+}
+
+void sm_init(void)
+{  
+    /* Switch to PMC mode */
+    pci_write_cfg_byte(0, 0, REG_GROUP, (uint8)(REG_GROUP_SPECIAL|REG_GROUP_POWER));
+ 
+    /* Set GPIO Base */
+    pci_write_cfg_long(0, 0, 0x40, 0xa500);
+
+    /* Enable GPIO */
+    pci_write_cfg_byte(0, 0, 0x44, 0x11);
+
+    /* Set both GPIO 0 and 1 as output */
+    out_byte(0xA53A, 0x03); 
+}
+
+
+void sm_term(void)
+{  
+    /* Switch to normal mode */
+    pci_write_cfg_byte(0, 0, REG_GROUP, 0);
+}
+
+
+int sm_get_data(uint8 *DataArray, int dimm_socket)
+{
+    int j;
+
+#if 0
+    /* Switch to PMC mode */
+    pci_write_cfg_byte(0, 0, REG_GROUP, (uint8)(REG_GROUP_SPECIAL|REG_GROUP_POWER));
+ 
+    /* Set GPIO Base */
+    pci_write_cfg_long(0, 0, 0x40, 0xa500);
+
+    /* Enable GPIO */
+    pci_write_cfg_byte(0, 0, 0x44, 0x11);
+
+    /* Set both GPIO 0 and 1 as output */
+    out_byte(0xA53A, 0x03); 
+#endif
+
+    sm_init();
+    /* Start reading the rom */
+
+    j = 0;
+
+    do
+    {
+	if (sm_read_byte_from_device(dimm_socket, (uint8)j, DataArray) == FALSE)
+	{
+	    sm_term();
+	    return FALSE;
+	}
+
+	DataArray++;
+	j++;
+    } while (j < 128);
+
+    sm_term();
+    return TRUE;
+}
diff --git a/board/MAI/AmigaOneG3SE/smbus.h b/board/MAI/AmigaOneG3SE/smbus.h
new file mode 100644
index 00000000000..beeb6a06aaf
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/smbus.h
@@ -0,0 +1,22 @@
+#ifndef _SMBUS_H_
+#define _SMBUS_H_
+
+#include "short_types.h"
+
+#define SM_DIMM0_ADDR 0x51
+#define SM_DIMM1_ADDR 0x52
+
+void sm_write_mode(void);
+void sm_read_mode(void);
+void sm_write_byte(uint8 writeme);
+uint8 sm_read_byte(void);
+int sm_get_ack(void);
+void sm_write_ack(void);
+void sm_write_nack(void);
+void sm_send_start(void);
+void sm_send_stop(void);
+int sm_read_byte_from_device(uint8 addr, uint8 reg, uint8 *storage);
+int sm_get_data(uint8 *DataArray, int dimm_socket);
+void sm_init(void);
+void sm_term(void);
+#endif
diff --git a/board/MAI/AmigaOneG3SE/start.txt b/board/MAI/AmigaOneG3SE/start.txt
new file mode 100644
index 00000000000..5c7b541a2b5
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/start.txt
@@ -0,0 +1,201 @@
+
+	/*------------------------------------------------------*/
+        /*              TERON Articia / SDRAM Init              */
+        /*------------------------------------------------------*/
+
+*       XD_CTL  = 0x81000000			(0x74)
+
+*       HBUS_ACC_CTL_0 &= 0xFFFFFDFF		(0x5c)
+                       /* host bus access ctl reg 2(5e) */
+                       /* set - CPU read from memory data one clock after data is latched */
+
+*       GLOBL_INFO_0 |= 0x00004000		(0x50)
+                      /* global info register 2 (52), AGP/PCI bus 1 arbiter is addressed in Articia S */
+
+        PCI_1_SB_CONFIG_0 |= 0x00000400         (0x80d0)
+                        /* PCI1 side band config reg 2 (d2), enable read acces while write buffer not empty */
+
+        MEM_RAS_CTL_0 |= 0x3f000000		(0xcc)
+		      &= 0x3fffffff
+                      /* RAS park control reg 0(cc), park access enable is set */
+		      
+        HOST_RDBUF_CTL |= 0x10000000		(0x70)
+	               &= 0x10ffffff
+                      /* host read buffer control reg, enable prefetch for CPU read from DRAM control */
+
+        HBUS_ACC_CTL_0 |= 0x0100001f		(0x5c)
+		       &= 0xf1ffffff
+                      /* host bus access control register, enable CPU address bus pipe control	*/
+                      /* two outstanding requests,  *** changed to 2 from 3				*/
+                      /* enable line merge write control for CPU write to system memory, PCI 1	*/
+                      /* and PCI 0 bus memory; enable page merge write control for write to		*/
+                      /* PCI bus 0 & bus 1 memory							*/
+
+        SRAM_CTL |= 0x00004000			(0xc8)
+		 &= 0xffbff7ff
+                      /* DRAM detail timing control register 1 (ca), bit 3 set to 0	*/
+                      /* DRAM start access latency control - wait for one clock	*/
+                      /* ff9f changed to ffbf						*/
+    
+        DIM0_TIM_CTL_0 = 0x737d737d             (0xc9)
+                      /* DRAM timing control for dimm0 & dimm1; set wait one clock	*/
+                      /* cycle for next data access 					*/
+
+        DIM2_TIM_CTL_0 = 0x737d737d             (0xca)
+                      /* DRAM timing control for dimm2 & dimm3; set wait one clock	*/
+                      /* cycle for next data access 					*/
+
+        DIM0_BNK0_CTL_0 = BNK0_RAM_SIZ_128MB    (0x90)
+	              /* set dimm0 bank0 for 128 MB	*/
+
+        DIM0_BNK1_CTL_0 = BNK1_RAM_SIZ_128MB    (0x94)
+                      /* set dimm0 for  bank1		*/
+
+        DIM0_TIM_CTL_0 = 0xf3bf0000             (0xc9)
+                      /* dimm0 timing control register; RAS - CAS latency - 4 clock		*/
+                      /* CAS access latency - 3 wait; pre-charge latency - 3 wait		*/
+                      /* pre-charge command period control - 5 clock; wait one clock		*/
+                      /* cycle for next data access; read to write access latency control	*/
+                      /* - 2 clock cycles							*/
+
+        DRAM_GBL_CTL_0 |= 0x00000100            (0xc0)
+		       &= 0xffff01ff
+                      /* memory global control register - support buffer sdram on bank 0	*/
+
+        DRAM_ECC_CTL_0 |= 0x00260000		(0xc4)
+		       &= 0xff26ffff
+                      /* enable ECC; enable read, modify, write control	*/
+ 
+        DRAM_REF_CTL_0 = DRAM_REF_DATA          (0xb8)
+		      /* set DRAM refresh parameters *** changed to 00940100	*/
+
+        nop
+        nop
+        nop
+        nop
+        nop
+
+        DRAM_ECC_CTL_0 |= 0x20243280		(0xc4)
+                      /* turn off ecc		*/
+                      /* for SDRAM bank 0	*/
+
+        DRAM_ECC_CTL_0 |= 0x20243290            (0xc4) ?
+                      /* for SDRAM bank 1	*/
+ 
+
+/* Additional Stuff...*/
+
+        GLOBL_CTRL |= 0x20000b00		(0x54)
+
+        PCI_0_SB_CONFIG |= 0x04100007		(0xd0)
+                      /* PCI 0 Side band config reg*/
+
+        0x8000083c |= 0x00080000
+                      /* Disable VGA decode on PCI Bus 1 */
+
+
+/*End Additional Stuff..*/
+
+        /*--------------------------------------------------------------*/
+        /*              TERON serial port initialization code           */
+        /*--------------------------------------------------------------*/
+
+	0x84380080 |= 0x00030000
+                     /* enable super IO configuration VIA chip Register 85	*/
+		     /* Enable super I/O config mode */
+
+        0xfe0003f0 = 0xe2
+        bl delay1
+
+        0xfe0003f1 = 0x0f
+	bl delay1
+	            /* enable com1 & com2, parallel port disabled */ 
+	
+	0xfe0003f0 = 0xe7
+        bl delay1
+	            /* let's make com1 base as 0x3f8 */
+        
+        0xfe0003f1 = 0xfe
+        bl delay1
+
+        0xfe0003f0 = 0xe8
+        bl delay1           
+		    /* let's make com2 base as 0x2f8 */
+
+	0xfe0003f1 = 0xbe
+
+	0x84380080 &= 0xfffdffff
+                    /* closing super IO configuration VIA chip Register 85   */
+     
+
+/* -------------------------------*/
+
+        0xfe0003fb = 0x83
+	bl delay1
+                   /*latch enable word length -8 bit */         /* set mslab bit	*/
+        0xfe0003f8 = 0x0c
+	bl delay1
+                   /* set baud rate lsb for 9600 baud	*/
+        0xfe0003f9 = 0x0
+	bl delay1
+                   /* set baud rate msb for 9600 baud	*/
+        0xfe0003fb  = 0x03
+	bl delay1
+                      /* reset mslab	*/
+
+	/*--------------------------------------------------------------*/
+        /*              END TERON Serial Port Initialization Code       */
+        /*--------------------------------------------------------------*/
+
+   
+
+        /*--------------------------------------------------------------*/
+        /*      END TERON Articia / SDRAM Initialization code           */
+        /*--------------------------------------------------------------*/
+
+Proposed from Documentation:
+
+write dmem 0xfec00cf8 0x50000080
+write dmem 0xfee00cfc 0xc0305411
+
+      Writes to index 0x50-0x53. 
+      0x50: Global Information Register 0
+	    0xC0 = Little Endian CPU, Sequential order Burst
+      0x51: Global Information Register 1
+	    Read only, 0x30 = Provides PowerPC and X86 support
+      0x52: Global Information Register 2
+	    0x05 = 64/128 bit CPU bus support
+      0x53: Global Information Register 3
+	    0x80 = PCI Bus 0 grant active time is 1 clock after REQ# deasserted
+
+write dmem 0xfec00cf8 0x5c000080
+write dmem 0xfee00cfc 0xb300011F
+
+write dmem 0xfec00cf8 0xc8000080
+write dmem 0xfee00cfc 0x0020f100
+
+write dmem 0xfec00cf8 0x90000080
+write dmem 0xfee00cfc 0x007fe700
+
+write dmem 0xfec00cf8 0x9400080
+write dmem 0xfee00cfc 0x007fe700
+
+write dmem 0xfec00cf8 0xb0000080
+write dmem 0xfee00cfc 0x737d737d
+
+write dmem 0xfec00cf8 0xb4000080
+write dmem 0xfee00cfc 0x737d737d
+
+write dmem 0xfec00cf8 0xc0000080
+write dmem 0xfee00cfc 0x40005500
+
+write dmem 0xfec00cf8 0xb8000080
+write dmem 0xfee00cfc 0x00940100
+
+write dmem 0xfec00cf8 0xc4000080
+write dmem 0xfee00cfc 0x00003280
+
+write dmem 0xfec00cf8 0xc4000080
+write dmem 0xfee00cfc 0x00003290
+
+
diff --git a/board/MAI/AmigaOneG3SE/todo.txt b/board/MAI/AmigaOneG3SE/todo.txt
new file mode 100644
index 00000000000..df25e3dee0d
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/todo.txt
@@ -0,0 +1,3 @@
+- Init interrupt controller
+- init sdram
+- init ide controller
\ No newline at end of file
diff --git a/board/MAI/AmigaOneG3SE/u-boot.lds b/board/MAI/AmigaOneG3SE/u-boot.lds
new file mode 100644
index 00000000000..d36a7e1caaf
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/u-boot.lds
@@ -0,0 +1,131 @@
+/*
+ * (C) Copyright 2001
+ * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
+ *
+ * (C) Copyright 2002
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * u-boot.lds - linker script for U-Boot on the AmigaOneG3SE Board.
+ */
+
+OUTPUT_ARCH(powerpc)
+SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib);
+/* Do we need any of these for elf?
+   __DYNAMIC = 0;    */
+SECTIONS
+{
+  /* Read-only sections, merged into text segment: */
+  . = + SIZEOF_HEADERS;
+  .interp : { *(.interp) }
+  .hash          : { *(.hash)		}
+  .dynsym        : { *(.dynsym)		}
+  .dynstr        : { *(.dynstr)		}
+  .rel.text      : { *(.rel.text)		}
+  .rela.text     : { *(.rela.text) 	}
+  .rel.data      : { *(.rel.data)		}
+  .rela.data     : { *(.rela.data) 	}
+  .rel.rodata    : { *(.rel.rodata) 	}
+  .rela.rodata   : { *(.rela.rodata) 	}
+  .rel.got       : { *(.rel.got)		}
+  .rela.got      : { *(.rela.got)		}
+  .rel.ctors     : { *(.rel.ctors)	}
+  .rela.ctors    : { *(.rela.ctors)	}
+  .rel.dtors     : { *(.rel.dtors)	}
+  .rela.dtors    : { *(.rela.dtors)	}
+  .rel.bss       : { *(.rel.bss)		}
+  .rela.bss      : { *(.rela.bss)		}
+  .rel.plt       : { *(.rel.plt)		}
+  .rela.plt      : { *(.rela.plt)		}
+  .init          : { *(.init)	}
+  .plt : { *(.plt) }
+  .text      :
+  {
+    cpu/74xx_7xx/start.o	(.text)
+/* store the environment in a seperate sector in the boot flash */
+/*    . = env_offset; */
+    common/environment.o(.text) 
+
+    *(.text)
+    *(.fixup)
+    *(.got1)
+  }
+  _etext = .;
+  PROVIDE (etext = .);
+  .rodata    :
+  {
+    *(.rodata)
+    *(.rodata1)
+  }
+  .fini      : { *(.fini)    } =0
+  .ctors     : { *(.ctors)   }
+  .dtors     : { *(.dtors)   }
+
+  /* Read-write section, merged into data segment: */
+  . = (. + 0x00FF) & 0xFFFFFF00;
+  _erotext = .;
+  PROVIDE (erotext = .);
+  .reloc   :
+  {
+    *(.got) 
+    _GOT2_TABLE_ = .;
+    *(.got2)
+    _FIXUP_TABLE_ = .;
+    *(.fixup)
+  }
+  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __fixup_entries = (. - _FIXUP_TABLE_)>>2;
+
+  .data    :
+  {
+    *(.data)
+    *(.data1)
+    *(.sdata)
+    *(.sdata2)
+    *(.dynamic)
+    CONSTRUCTORS
+  }
+  _edata  =  .;
+  PROVIDE (edata = .);
+
+  __start___ex_table = .;
+  __ex_table : { *(__ex_table) }
+  __stop___ex_table = .;
+
+  . = ALIGN(256);
+  __init_begin = .;
+  .text.init : { *(.text.init) }
+  .data.init : { *(.data.init) }
+  . = ALIGN(256);
+  __init_end = .;
+
+  __bss_start = .;
+  .bss       :
+  {
+   *(.sbss) *(.scommon)
+   *(.dynbss)
+   *(.bss)
+   *(COMMON)
+  }
+  _end = ALIGN(4) /*.*/ ;
+  PROVIDE (end = ALIGN(4) /*.*/);
+}
diff --git a/board/MAI/AmigaOneG3SE/usb_uhci.c b/board/MAI/AmigaOneG3SE/usb_uhci.c
new file mode 100644
index 00000000000..fd8cb4ef33f
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/usb_uhci.c
@@ -0,0 +1,1179 @@
+/*
+ * (C) Copyright 2001
+ * Denis Peter, MPL AG Switzerland
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * Note: Part of this code has been derived from linux
+ *
+ */
+
+/**********************************************************************
+ * How it works:
+ * -------------
+ * The framelist / Transfer descriptor / Queue Heads are similar like
+ * in the linux usb_uhci.c.
+ *
+ * During initialization, the following skeleton is allocated in init_skel:
+ *
+ *         framespecific           |           common chain
+ *
+ * framelist[]
+ * [  0 ]-----> TD ---------\
+ * [  1 ]-----> TD ----------> TD ------> QH -------> QH -------> QH ---> NULL
+ *   ...        TD ---------/
+ * [1023]-----> TD --------/
+ *
+ *              ^^             ^^         ^^          ^^          ^^
+ *              7 TDs for      1 TD for   Start of    Start of    End Chain
+ *              INT (2-128ms)  1ms-INT    CTRL Chain  BULK Chain
+ *
+ *
+ * Since this is a bootloader, the isochronous transfer descriptor have been removed.
+ *
+ * Interrupt Transfers.
+ * --------------------
+ * For Interupt transfers USB_MAX_TEMP_INT_TD Transfer descriptor are available. They
+ * will be inserted after the appropriate (depending the interval setting) skeleton TD.
+ * If an interrupt has been detected the dev->irqhandler is called. The status and number
+ * of transfered bytes is stored in dev->irq_status resp. dev->irq_act_len. If the
+ * dev->irqhandler returns 0, the interrupt TD is removed and disabled. If an 1 is returned,
+ * the interrupt TD will be reactivated.
+ *
+ * Control Transfers
+ * -----------------
+ * Control Transfers are issued by filling the tmp_td with the appropriate data and connect
+ * them to the qh_cntrl queue header. Before other control/bulk transfers can be issued,
+ * the programm has to wait for completion. This does not allows asynchronous data transfer.
+ *
+ * Bulk Transfers
+ * --------------
+ * Bulk Transfers are issued by filling the tmp_td with the appropriate data and connect
+ * them to the qh_bulk queue header. Before other control/bulk transfers can be issued,
+ * the programm has to wait for completion. This does not allows asynchronous data transfer.
+ *
+ *
+ */
+
+#include <common.h>
+#include <pci.h>
+
+#ifdef CONFIG_USB_UHCI
+
+#include <usb.h>
+#include "usb_uhci.h"
+
+#define USB_MAX_TEMP_TD      128  /* number of temporary TDs for bulk and control transfers */
+#define USB_MAX_TEMP_INT_TD  32   /* number of temporary TDs for Interrupt transfers */
+
+
+//#define USB_UHCI_DEBUG
+
+#ifdef	USB_UHCI_DEBUG
+#define	USB_UHCI_PRINTF(fmt,args...)	printf (fmt ,##args)
+#else
+#define USB_UHCI_PRINTF(fmt,args...)
+#endif
+
+
+static int irqvec = -1;            /* irq vector, if -1 uhci is stopped / reseted */
+unsigned int usb_base_addr;       /* base address */
+
+static uhci_td_t td_int[8];        /* Interrupt Transfer descriptors */
+static uhci_qh_t qh_cntrl;         /* control Queue Head */
+static uhci_qh_t qh_bulk;          /*  bulk Queue Head */
+static uhci_qh_t qh_end;           /* end Queue Head */
+static uhci_td_t td_last;          /* last TD (linked with end chain) */
+
+/* temporary tds */
+static uhci_td_t tmp_td[USB_MAX_TEMP_TD];          /* temporary bulk/control td's  */
+static uhci_td_t tmp_int_td[USB_MAX_TEMP_INT_TD];  /* temporary interrupt td's  */
+
+static unsigned long framelist[1024] __attribute__ ((aligned (0x1000))); /* frame list */
+
+static struct virt_root_hub rh;   /* struct for root hub */
+
+/**********************************************************************
+ * some forward decleration
+ */
+int uhci_submit_rh_msg(struct usb_device *dev, unsigned long pipe,
+						void *buffer, int transfer_len,struct devrequest *setup);
+
+/* fill a td with the approproiate data. Link, status, info and buffer
+ * are used by the USB controller itselfes, dev is used to identify the
+ * "connected" device
+ */
+void usb_fill_td(uhci_td_t* td,unsigned long link,unsigned long status,
+					unsigned long info, unsigned long buffer, unsigned long dev)
+{
+	td->link=swap_32(link);
+	td->status=swap_32(status);
+	td->info=swap_32(info);
+	td->buffer=swap_32(buffer);
+	td->dev_ptr=dev;
+}
+
+/* fill a qh with the approproiate data. Head and element are used by the USB controller
+ * itselfes. As soon as a valid dev_ptr is filled, a td chain is connected to the qh.
+ * Please note, that after completion of the td chain, the entry element is removed /
+ * marked invalid by the USB controller.
+ */
+void usb_fill_qh(uhci_qh_t* qh,unsigned long head,unsigned long element)
+{
+	qh->head=swap_32(head);
+	qh->element=swap_32(element);
+	qh->dev_ptr=0L;
+}
+
+/* get the status of a td->status
+ */
+unsigned long usb_uhci_td_stat(unsigned long status)
+{
+	unsigned long result=0;
+	result |= (status & TD_CTRL_NAK)      ? USB_ST_NAK_REC : 0;
+	result |= (status & TD_CTRL_STALLED)  ? USB_ST_STALLED : 0;
+	result |= (status & TD_CTRL_DBUFERR)  ? USB_ST_BUF_ERR : 0;
+	result |= (status & TD_CTRL_BABBLE)   ? USB_ST_BABBLE_DET : 0;
+	result |= (status & TD_CTRL_CRCTIMEO) ? USB_ST_CRC_ERR : 0;
+	result |= (status & TD_CTRL_BITSTUFF) ? USB_ST_BIT_ERR : 0;
+	result |= (status & TD_CTRL_ACTIVE)   ? USB_ST_NOT_PROC : 0;
+	return result;
+}
+
+/* get the status and the transfered len of a td chain.
+ * called from the completion handler
+ */
+int usb_get_td_status(uhci_td_t *td,struct usb_device *dev)
+{
+	unsigned long temp,info;
+	unsigned long stat;
+	uhci_td_t *mytd=td;
+
+	if(dev->devnum==rh.devnum)
+		return 0;
+	dev->act_len=0;
+	stat=0;
+	do {
+		temp=swap_32((unsigned long)mytd->status);
+		stat=usb_uhci_td_stat(temp);
+		info=swap_32((unsigned long)mytd->info);
+		if(((info & 0xff)!= USB_PID_SETUP) &&
+				(((info >> 21) & 0x7ff)!= 0x7ff) &&
+				(temp & 0x7FF)!=0x7ff)
+		{  /* if not setup and not null data pack */
+			dev->act_len+=(temp & 0x7FF) + 1; /* the transfered len is act_len + 1 */
+		}
+		if(stat) {           /* status no ok */
+			dev->status=stat;
+			return -1;
+		}
+		temp=swap_32((unsigned long)mytd->link);
+		mytd=(uhci_td_t *)(temp & 0xfffffff0);
+	}while((temp & 0x1)==0); /* process all TDs */
+	dev->status=stat;
+	return 0; /* Ok */
+}
+
+
+/*-------------------------------------------------------------------
+ *                         LOW LEVEL STUFF
+ *          assembles QHs und TDs for control, bulk and iso
+ *-------------------------------------------------------------------*/
+
+/* Submits a control message. That is a Setup, Data and Status transfer.
+ * Routine does not wait for completion.
+ */
+int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
+										int transfer_len,struct devrequest *setup)
+{
+	unsigned long destination, status;
+	int maxsze = usb_maxpacket(dev, pipe);
+	unsigned long dataptr;
+	int len;
+	int pktsze;
+	int i=0;
+
+	if (!maxsze) {
+		USB_UHCI_PRINTF("uhci_submit_control_urb: pipesize for pipe %lx is zero\n", pipe);
+		return -1;
+	}
+	if(((pipe>>8)&0x7f)==rh.devnum) {
+		/* this is the root hub -> redirect it */
+		return uhci_submit_rh_msg(dev,pipe,buffer,transfer_len,setup);
+	}
+	USB_UHCI_PRINTF("uhci_submit_control start len %x, maxsize %x\n",transfer_len,maxsze);
+	/* The "pipe" thing contains the destination in bits 8--18 */
+	destination = (pipe & PIPE_DEVEP_MASK) | USB_PID_SETUP; /* Setup stage */
+	/* 3 errors */
+	status = (pipe & TD_CTRL_LS) | TD_CTRL_ACTIVE | (3 << 27);
+	/* (urb->transfer_flags & USB_DISABLE_SPD ? 0 : TD_CTRL_SPD); */
+	/*  Build the TD for the control request, try forever, 8 bytes of data */
+	usb_fill_td(&tmp_td[i],UHCI_PTR_TERM ,status, destination | (7 << 21),(unsigned long)setup,(unsigned long)dev);
+#if 0
+	{
+		char *sp=(char *)setup;
+		printf("SETUP to pipe %lx: %x %x %x %x %x %x %x %x\n", pipe,
+		    sp[0],sp[1],sp[2],sp[3],sp[4],sp[5],sp[6],sp[7]);
+	}
+#endif
+	dataptr = (unsigned long)buffer;
+	len=transfer_len;
+
+	/* If direction is "send", change the frame from SETUP (0x2D)
+	   to OUT (0xE1). Else change it from SETUP to IN (0x69). */
+	destination = (pipe & PIPE_DEVEP_MASK) | ((pipe & USB_DIR_IN)==0 ? USB_PID_OUT : USB_PID_IN);
+	while (len > 0) {
+		/* data stage */
+		pktsze = len;
+		i++;
+		if (pktsze > maxsze)
+			pktsze = maxsze;
+		destination ^= 1 << TD_TOKEN_TOGGLE;	/* toggle DATA0/1 */
+		usb_fill_td(&tmp_td[i],UHCI_PTR_TERM, status, destination | ((pktsze - 1) << 21),dataptr,(unsigned long)dev);	/* Status, pktsze bytes of data */
+		tmp_td[i-1].link=swap_32((unsigned long)&tmp_td[i]);
+
+		dataptr += pktsze;
+		len -= pktsze;
+	}
+
+	/*  Build the final TD for control status */
+	/* It's only IN if the pipe is out AND we aren't expecting data */
+
+	destination &= ~UHCI_PID;
+	if (((pipe & USB_DIR_IN)==0) || (transfer_len == 0))
+		destination |= USB_PID_IN;
+	else
+		destination |= USB_PID_OUT;
+	destination |= 1 << TD_TOKEN_TOGGLE;	/* End in Data1 */
+	i++;
+	status &=~TD_CTRL_SPD;
+	/* no limit on errors on final packet , 0 bytes of data */
+	usb_fill_td(&tmp_td[i],UHCI_PTR_TERM, status | TD_CTRL_IOC, destination | (UHCI_NULL_DATA_SIZE << 21),0,(unsigned long)dev);
+	tmp_td[i-1].link=swap_32((unsigned long)&tmp_td[i]);	/* queue status td */
+	/*	usb_show_td(i+1);*/
+	USB_UHCI_PRINTF("uhci_submit_control end (%d tmp_tds used)\n",i);
+	/* first mark the control QH element terminated */
+	qh_cntrl.element=0xffffffffL;
+	/* set qh active */
+	qh_cntrl.dev_ptr=(unsigned long)dev;
+	/* fill in tmp_td_chain */
+	qh_cntrl.element=swap_32((unsigned long)&tmp_td[0]);
+	return 0;
+}
+
+/*-------------------------------------------------------------------
+ * Prepare TDs for bulk transfers.
+ */
+int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,int transfer_len)
+{
+	unsigned long destination, status,info;
+	unsigned long dataptr;
+	int maxsze = usb_maxpacket(dev, pipe);
+	int len;
+	int i=0;
+
+	if(transfer_len < 0) {
+		printf("Negative transfer length in submit_bulk\n");
+		return -1;
+	}
+	if (!maxsze)
+		return -1;
+	/* The "pipe" thing contains the destination in bits 8--18. */
+	destination = (pipe & PIPE_DEVEP_MASK) | usb_packetid (pipe);
+	/* 3 errors */
+	status = (pipe & TD_CTRL_LS) | TD_CTRL_ACTIVE | (3 << 27);
+	/*	((urb->transfer_flags & USB_DISABLE_SPD) ? 0 : TD_CTRL_SPD) | (3 << 27); */
+	/* Build the TDs for the bulk request */
+	len = transfer_len;
+	dataptr = (unsigned long)buffer;
+	do {
+		int pktsze = len;
+		if (pktsze > maxsze)
+			pktsze = maxsze;
+		/* pktsze bytes of data  */
+		info = destination | (((pktsze - 1)&UHCI_NULL_DATA_SIZE) << 21) |
+			(usb_gettoggle (dev, usb_pipeendpoint (pipe), usb_pipeout (pipe)) << TD_TOKEN_TOGGLE);
+
+		if((len-pktsze)==0)
+			status |= TD_CTRL_IOC;	/* last one generates INT */
+
+		usb_fill_td(&tmp_td[i],UHCI_PTR_TERM, status, info,dataptr,(unsigned long)dev);	/* Status, pktsze bytes of data */
+		if(i>0)
+			tmp_td[i-1].link=swap_32((unsigned long)&tmp_td[i]);
+		i++;
+		dataptr += pktsze;
+		len -= pktsze;
+		usb_dotoggle (dev, usb_pipeendpoint (pipe), usb_pipeout (pipe));
+	} while (len > 0);
+	/* first mark the bulk QH element terminated */
+	qh_bulk.element=0xffffffffL;
+	/* set qh active */
+	qh_bulk.dev_ptr=(unsigned long)dev;
+	/* fill in tmp_td_chain */
+	qh_bulk.element=swap_32((unsigned long)&tmp_td[0]);
+	return 0;
+}
+
+
+/* search a free interrupt td
+ */
+uhci_td_t *uhci_alloc_int_td(void)
+{
+	int i;
+	for(i=0;i<USB_MAX_TEMP_INT_TD;i++) {
+		if(tmp_int_td[i].dev_ptr==0) /* no device assigned -> free TD */
+			return &tmp_int_td[i];
+	}
+	return NULL;
+}
+
+#if 0
+void uhci_show_temp_int_td(void)
+{
+	int i;
+	for(i=0;i<USB_MAX_TEMP_INT_TD;i++) {
+		if((tmp_int_td[i].dev_ptr&0x01)!=0x1L) /* no device assigned -> free TD */
+			printf("temp_td %d is assigned to dev %lx\n",i,tmp_int_td[i].dev_ptr);
+	}
+	printf("all others temp_tds are free\n");
+}
+#endif
+/*-------------------------------------------------------------------
+ * submits USB interrupt (ie. polling ;-)
+ */
+int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,int transfer_len, int interval)
+{
+	int nint, n;
+	unsigned long status, destination;
+	unsigned long info,tmp;
+	uhci_td_t *mytd;
+	if (interval < 0 || interval >= 256)
+		return -1;
+
+	if (interval == 0)
+		nint = 0;
+	else {
+		for (nint = 0, n = 1; nint <= 8; nint++, n += n)	/* round interval down to 2^n */
+		 {
+			if(interval < n) {
+				interval = n / 2;
+				break;
+			}
+		}
+		nint--;
+	}
+
+	USB_UHCI_PRINTF("Rounded interval to %i, chain  %i\n", interval, nint);
+	mytd=uhci_alloc_int_td();
+	if(mytd==NULL) {
+		printf("No free INT TDs found\n");
+		return -1;
+	}
+	status = (pipe & TD_CTRL_LS) | TD_CTRL_ACTIVE | TD_CTRL_IOC | (3 << 27);
+/*		(urb->transfer_flags & USB_DISABLE_SPD ? 0 : TD_CTRL_SPD) | (3 << 27);
+*/
+
+	destination =(pipe & PIPE_DEVEP_MASK) | usb_packetid (pipe) | (((transfer_len - 1) & 0x7ff) << 21);
+
+	info = destination | (usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe)) << TD_TOKEN_TOGGLE);
+	tmp = swap_32(td_int[nint].link);
+	usb_fill_td(mytd,tmp,status, info,(unsigned long)buffer,(unsigned long)dev);
+	/* Link it */
+	tmp = swap_32((unsigned long)mytd);
+	td_int[nint].link=tmp;
+
+	usb_dotoggle (dev, usb_pipeendpoint (pipe), usb_pipeout (pipe));
+
+	return 0;
+}
+
+/**********************************************************************
+ * Low Level functions
+ */
+
+
+void reset_hc(void)
+{
+
+	/* Global reset for 100ms */
+	out16r( usb_base_addr + USBPORTSC1,0x0204);
+	out16r( usb_base_addr + USBPORTSC2,0x0204);
+	out16r( usb_base_addr + USBCMD,USBCMD_GRESET | USBCMD_RS);
+	/* Turn off all interrupts */
+	out16r(usb_base_addr + USBINTR,0);
+	wait_ms(50);
+	out16r( usb_base_addr + USBCMD,0);
+	wait_ms(10);
+}
+
+void start_hc(void)
+{
+	int timeout = 1000;
+
+	while(in16r(usb_base_addr + USBCMD) & USBCMD_HCRESET) {
+		if (!--timeout) {
+			printf("USBCMD_HCRESET timed out!\n");
+			break;
+		}
+	}
+	/* Turn on all interrupts */
+	out16r(usb_base_addr + USBINTR,USBINTR_TIMEOUT | USBINTR_RESUME | USBINTR_IOC | USBINTR_SP);
+	/* Start at frame 0 */
+	out16r(usb_base_addr + USBFRNUM,0);
+	/* set Framebuffer base address */
+	out32r(usb_base_addr+USBFLBASEADD,(unsigned long)&framelist);
+	/* Run and mark it configured with a 64-byte max packet */
+	out16r(usb_base_addr + USBCMD,USBCMD_RS | USBCMD_CF | USBCMD_MAXP);
+}
+
+/* Initialize the skeleton
+ */
+void usb_init_skel(void)
+{
+	unsigned long temp;
+	int n;
+
+	for(n=0;n<USB_MAX_TEMP_INT_TD;n++)
+		tmp_int_td[n].dev_ptr=0L; /* no devices connected */
+	/* last td */
+	usb_fill_td(&td_last,UHCI_PTR_TERM,TD_CTRL_IOC ,0,0,0L);
+  /* usb_fill_td(&td_last,UHCI_PTR_TERM,0,0,0); */
+	/* End Queue Header */
+	usb_fill_qh(&qh_end,UHCI_PTR_TERM,(unsigned long)&td_last);
+	/* Bulk Queue Header */
+	temp=(unsigned long)&qh_end;
+	usb_fill_qh(&qh_bulk,temp | UHCI_PTR_QH,UHCI_PTR_TERM);
+	/* Control Queue Header */
+	temp=(unsigned long)&qh_bulk;
+	usb_fill_qh(&qh_cntrl, temp | UHCI_PTR_QH,UHCI_PTR_TERM);
+	/* 1ms Interrupt td */
+	temp=(unsigned long)&qh_cntrl;
+	usb_fill_td(&td_int[0],temp | UHCI_PTR_QH,0,0,0,0L);
+	temp=(unsigned long)&td_int[0];
+	for(n=1; n<8; n++)
+		usb_fill_td(&td_int[n],temp,0,0,0,0L);
+	for (n = 0; n < 1024; n++) {
+	/* link all framelist pointers to one of the interrupts */
+		int m, o;
+		if ((n&127)==127)
+			framelist[n]= swap_32((unsigned long)&td_int[0]);
+		else
+			for (o = 1, m = 2; m <= 128; o++, m += m)
+				if ((n & (m - 1)) == ((m - 1) / 2))
+						framelist[n]= swap_32((unsigned long)&td_int[o]);
+	}
+}
+
+/* check the common skeleton for completed transfers, and update the status
+ * of the "connected" device. Called from the IRQ routine.
+ */
+void usb_check_skel(void)
+{
+	struct usb_device *dev;
+	/* start with the control qh */
+	if(qh_cntrl.dev_ptr!=0) /* it's a device assigned check if this caused IRQ */
+	{
+		dev=(struct usb_device *)qh_cntrl.dev_ptr;
+		usb_get_td_status(&tmp_td[0],dev); /* update status */
+		if(!(dev->status & USB_ST_NOT_PROC)) { /* is not active anymore, disconnect devices */
+			qh_cntrl.dev_ptr=0;
+		}
+	}
+	/* now process the bulk */
+	if(qh_bulk.dev_ptr!=0) /* it's a device assigned check if this caused IRQ */
+	{
+		dev=(struct usb_device *)qh_bulk.dev_ptr;
+		usb_get_td_status(&tmp_td[0],dev); /* update status */
+		if(!(dev->status & USB_ST_NOT_PROC)) { /* is not active anymore, disconnect devices */
+			qh_bulk.dev_ptr=0;
+		}
+	}
+}
+
+/* check the interrupt chain, ubdate the status of the appropriate device,
+ * call the appropriate irqhandler and reactivate the TD if the irqhandler
+ * returns with 1
+ */
+void usb_check_int_chain(void)
+{
+	int i,res;
+	unsigned long link,status;
+	struct usb_device *dev;
+	uhci_td_t *td,*prevtd;
+
+	for(i=0;i<8;i++) {
+		prevtd=&td_int[i]; /* the first previous td is the skeleton td */
+		link=swap_32(td_int[i].link) & 0xfffffff0; /* next in chain */
+		td=(uhci_td_t *)link; /* assign it */
+		/* all interrupt TDs are finally linked to the td_int[0].
+ 		 * so we process all until we find the td_int[0].
+		 * if int0 chain points to a QH, we're also done
+	   */
+		while(((i>0) && (link != (unsigned long)&td_int[0])) ||
+					((i==0) && !(swap_32(td->link) &  UHCI_PTR_QH)))
+		{
+			/* check if a device is assigned with this td */
+			status=swap_32(td->status);
+			if((td->dev_ptr!=0L) && !(status & TD_CTRL_ACTIVE)) {
+				/* td is not active and a device is assigned -> call irqhandler */
+				dev=(struct usb_device *)td->dev_ptr;
+				dev->irq_act_len=((status & 0x7FF)==0x7FF) ? 0 : (status & 0x7FF) + 1; /* transfered length */
+				dev->irq_status=usb_uhci_td_stat(status); /* get status */
+				res=dev->irq_handle(dev); /* call irqhandler */
+				if(res==1) {
+					/* reactivate */
+					status|=TD_CTRL_ACTIVE;
+					td->status=swap_32(status);
+					prevtd=td; /* previous td = this td */
+				}
+				else {
+					prevtd->link=td->link; /* link previous td directly to the nex td -> unlinked */
+					/* remove device pointer */
+					td->dev_ptr=0L;
+				}
+			} /* if we call the irq handler */
+			link=swap_32(td->link) & 0xfffffff0; /* next in chain */
+			td=(uhci_td_t *)link; /* assign it */
+		} /* process all td in this int chain */
+	} /* next interrupt chain */
+}
+
+
+/* usb interrupt service routine.
+ */
+void handle_usb_interrupt(void)
+{
+	unsigned short status;
+
+	/*
+	 * Read the interrupt status, and write it back to clear the
+	 * interrupt cause
+	 */
+
+	status = in16r(usb_base_addr + USBSTS);
+
+	if (!status)		/* shared interrupt, not mine */
+		return;
+	if (status != 1) {
+		/* remove host controller halted state */
+		if ((status&0x20) && ((in16r(usb_base_addr+USBCMD) && USBCMD_RS)==0)) {
+			out16r(usb_base_addr + USBCMD, USBCMD_RS | in16r(usb_base_addr + USBCMD));
+		}
+	}
+	usb_check_int_chain(); /* call interrupt handlers for int tds */
+	usb_check_skel(); /* call completion handler for common transfer routines */
+	out16r(usb_base_addr+USBSTS,status);
+}
+
+
+/* init uhci
+ */
+int usb_lowlevel_init(void)
+{
+	unsigned char temp;
+	int	busdevfunc;
+/*
+ * HJF - configure IRQ and base from variables optionally.
+ */
+	char *s;
+
+
+	busdevfunc=pci_find_device(USB_UHCI_VEND_ID,USB_UHCI_DEV_ID,0); /* get PCI Device ID */
+	if(busdevfunc==-1) {
+		printf("Error USB UHCI (%04X,%04X) not found\n",USB_UHCI_VEND_ID,USB_UHCI_DEV_ID);
+		return -1;
+	}
+	
+#if 1
+	s = getenv("usb_irq");
+	if (s)
+	{
+	    temp = atoi(s);
+	    pci_write_config_byte(busdevfunc, PCI_INTERRUPT_LINE, temp);
+	}
+	else
+#endif
+	    pci_read_config_byte(busdevfunc,PCI_INTERRUPT_LINE,&temp);
+
+	s = getenv("usb_base");
+	if (s)
+	{
+	    unsigned long temp2;
+	    temp2 = atoi(s);
+	    pci_write_config_dword(busdevfunc, PCI_BASE_ADDRESS_4, temp2|0x01);
+	}
+
+	irqvec = temp;
+	irq_free_handler(irqvec);
+	USB_UHCI_PRINTF("Interrupt Line = %d\n",irqvec);
+	pci_read_config_byte(busdevfunc,PCI_INTERRUPT_PIN,&temp);
+	USB_UHCI_PRINTF("Interrupt Pin = %ld\n",temp);
+	pci_read_config_dword(busdevfunc,PCI_BASE_ADDRESS_4,&usb_base_addr);
+	USB_UHCI_PRINTF("IO Base Address = 0x%lx\n",usb_base_addr);
+	usb_base_addr&=0xFFFFFFF0;
+	usb_base_addr+=CFG_ISA_IO_BASE_ADDRESS;
+	rh.devnum = 0;
+	usb_init_skel();
+	reset_hc();
+	start_hc();
+	irq_install_handler(irqvec, (interrupt_handler_t *)handle_usb_interrupt, NULL);
+	irq_install_handler(0, (interrupt_handler_t *)handle_usb_interrupt, NULL);
+
+	return 0;
+}
+
+/* stop uhci
+ */
+int usb_lowlevel_stop(void)
+{
+	if(irqvec==-1)
+		return 1;
+	irq_free_handler(irqvec);
+	irq_free_handler(0);
+	reset_hc();
+	irqvec=-1;
+	return 0;
+}
+
+/*******************************************************************************************
+ * Virtual Root Hub
+ * Since the uhci does not have a real HUB, we simulate one ;-)
+ */
+#undef	USB_RH_DEBUG
+
+#ifdef	USB_RH_DEBUG
+#define	USB_RH_PRINTF(fmt,args...)	printf (fmt ,##args)
+static void usb_display_wValue(unsigned short wValue,unsigned short wIndex);
+static void usb_display_Req(unsigned short req);
+#else
+#define USB_RH_PRINTF(fmt,args...)
+static void usb_display_wValue(unsigned short wValue,unsigned short wIndex) {}
+static void usb_display_Req(unsigned short req) {}
+#endif
+
+static unsigned char root_hub_dev_des[] =
+{
+	0x12,			/*  __u8  bLength; */
+	0x01,			/*  __u8  bDescriptorType; Device */
+	0x00,			/*  __u16 bcdUSB; v1.0 */
+	0x01,
+	0x09,			/*  __u8  bDeviceClass; HUB_CLASSCODE */
+	0x00,			/*  __u8  bDeviceSubClass; */
+	0x00,			/*  __u8  bDeviceProtocol; */
+	0x08,			/*  __u8  bMaxPacketSize0; 8 Bytes */
+	0x00,			/*  __u16 idVendor; */
+	0x00,
+	0x00,			/*  __u16 idProduct; */
+	0x00,
+	0x00,			/*  __u16 bcdDevice; */
+	0x00,
+	0x01,			/*  __u8  iManufacturer; */
+	0x00,			/*  __u8  iProduct; */
+	0x00,			/*  __u8  iSerialNumber; */
+	0x01			/*  __u8  bNumConfigurations; */
+};
+
+
+/* Configuration descriptor */
+static unsigned char root_hub_config_des[] =
+{
+	0x09,			/*  __u8  bLength; */
+	0x02,			/*  __u8  bDescriptorType; Configuration */
+	0x19,			/*  __u16 wTotalLength; */
+	0x00,
+	0x01,			/*  __u8  bNumInterfaces; */
+	0x01,			/*  __u8  bConfigurationValue; */
+	0x00,			/*  __u8  iConfiguration; */
+	0x40,			/*  __u8  bmAttributes;
+				   Bit 7: Bus-powered, 6: Self-powered, 5 Remote-wakwup, 4..0: resvd */
+	0x00,			/*  __u8  MaxPower; */
+
+     /* interface */
+	0x09,			/*  __u8  if_bLength; */
+	0x04,			/*  __u8  if_bDescriptorType; Interface */
+	0x00,			/*  __u8  if_bInterfaceNumber; */
+	0x00,			/*  __u8  if_bAlternateSetting; */
+	0x01,			/*  __u8  if_bNumEndpoints; */
+	0x09,			/*  __u8  if_bInterfaceClass; HUB_CLASSCODE */
+	0x00,			/*  __u8  if_bInterfaceSubClass; */
+	0x00,			/*  __u8  if_bInterfaceProtocol; */
+	0x00,			/*  __u8  if_iInterface; */
+
+     /* endpoint */
+	0x07,			/*  __u8  ep_bLength; */
+	0x05,			/*  __u8  ep_bDescriptorType; Endpoint */
+	0x81,			/*  __u8  ep_bEndpointAddress; IN Endpoint 1 */
+	0x03,			/*  __u8  ep_bmAttributes; Interrupt */
+	0x08,			/*  __u16 ep_wMaxPacketSize; 8 Bytes */
+	0x00,
+	0xff			/*  __u8  ep_bInterval; 255 ms */
+};
+
+
+static unsigned char root_hub_hub_des[] =
+{
+	0x09,			/*  __u8  bLength; */
+	0x29,			/*  __u8  bDescriptorType; Hub-descriptor */
+	0x02,			/*  __u8  bNbrPorts; */
+	0x00,			/* __u16  wHubCharacteristics; */
+	0x00,
+	0x01,			/*  __u8  bPwrOn2pwrGood; 2ms */
+	0x00,			/*  __u8  bHubContrCurrent; 0 mA */
+	0x00,			/*  __u8  DeviceRemovable; *** 7 Ports max *** */
+	0xff			/*  __u8  PortPwrCtrlMask; *** 7 ports max *** */
+};
+
+static unsigned char root_hub_str_index0[] =
+{
+	0x04,			/*  __u8  bLength; */
+	0x03,			/*  __u8  bDescriptorType; String-descriptor */
+	0x09,			/*  __u8  lang ID */
+	0x04,			/*  __u8  lang ID */
+};
+
+static unsigned char root_hub_str_index1[] =
+{
+	28,			/*  __u8  bLength; */
+	0x03,			/*  __u8  bDescriptorType; String-descriptor */
+	'U',			/*  __u8  Unicode */
+	0,				/*  __u8  Unicode */
+	'H',			/*  __u8  Unicode */
+	0,				/*  __u8  Unicode */
+	'C',			/*  __u8  Unicode */
+	0,				/*  __u8  Unicode */
+	'I',			/*  __u8  Unicode */
+	0,				/*  __u8  Unicode */
+	' ',			/*  __u8  Unicode */
+	0,				/*  __u8  Unicode */
+	'R',			/*  __u8  Unicode */
+	0,				/*  __u8  Unicode */
+	'o',			/*  __u8  Unicode */
+	0,				/*  __u8  Unicode */
+	'o',			/*  __u8  Unicode */
+	0,				/*  __u8  Unicode */
+	't',			/*  __u8  Unicode */
+	0,				/*  __u8  Unicode */
+	' ',			/*  __u8  Unicode */
+	0,				/*  __u8  Unicode */
+	'H',			/*  __u8  Unicode */
+	0,				/*  __u8  Unicode */
+	'u',			/*  __u8  Unicode */
+	0,				/*  __u8  Unicode */
+	'b',			/*  __u8  Unicode */
+	0,				/*  __u8  Unicode */
+};
+
+
+/*
+ * Root Hub Control Pipe (interrupt Pipes are not supported)
+ */
+
+
+int uhci_submit_rh_msg(struct usb_device *dev, unsigned long pipe, void *buffer,int transfer_len,struct devrequest *cmd)
+{
+	void *data = buffer;
+	int leni = transfer_len;
+	int len = 0;
+	int status = 0;
+	int stat = 0;
+	int i;
+
+	unsigned short cstatus;
+
+	unsigned short bmRType_bReq;
+	unsigned short wValue;
+	unsigned short wIndex;
+	unsigned short wLength;
+
+	if ((pipe & PIPE_INTERRUPT) == PIPE_INTERRUPT) {
+		printf("Root-Hub submit IRQ: NOT implemented\n");
+#if 0
+		uhci->rh.urb = urb;
+		uhci->rh.send = 1;
+		uhci->rh.interval = urb->interval;
+		rh_init_int_timer (urb);
+#endif
+		return 0;
+	}
+	bmRType_bReq = cmd->requesttype | cmd->request << 8;
+	wValue = swap_16(cmd->value);
+	wIndex = swap_16(cmd->index);
+	wLength = swap_16(cmd->length);
+	usb_display_Req(bmRType_bReq);
+	for (i = 0; i < 8; i++)
+		rh.c_p_r[i] = 0;
+	USB_RH_PRINTF("Root-Hub: adr: %2x cmd(%1x): %02x%02x %04x %04x %04x\n",
+	     dev->devnum, 8, cmd->requesttype,cmd->request, wValue, wIndex, wLength);
+
+	switch (bmRType_bReq) {
+		/* Request Destination:
+		   without flags: Device,
+		   RH_INTERFACE: interface,
+		   RH_ENDPOINT: endpoint,
+		   RH_CLASS means HUB here,
+		   RH_OTHER | RH_CLASS  almost ever means HUB_PORT here
+		 */
+
+	case RH_GET_STATUS:
+		*(unsigned short *) data = swap_16(1);
+		len=2;
+		break;
+	case RH_GET_STATUS | RH_INTERFACE:
+		*(unsigned short *) data = swap_16(0);
+		len=2;
+		break;
+	case RH_GET_STATUS | RH_ENDPOINT:
+		*(unsigned short *) data = swap_16(0);
+		len=2;
+		break;
+	case RH_GET_STATUS | RH_CLASS:
+		*(unsigned long *) data = swap_32(0);
+		len=4;
+		break;	/* hub power ** */
+	case RH_GET_STATUS | RH_OTHER | RH_CLASS:
+
+		status = in16r(usb_base_addr + USBPORTSC1 + 2 * (wIndex - 1));
+		cstatus = ((status & USBPORTSC_CSC) >> (1 - 0)) |
+			((status & USBPORTSC_PEC) >> (3 - 1)) |
+			(rh.c_p_r[wIndex - 1] << (0 + 4));
+		status = (status & USBPORTSC_CCS) |
+			((status & USBPORTSC_PE) >> (2 - 1)) |
+			((status & USBPORTSC_SUSP) >> (12 - 2)) |
+			((status & USBPORTSC_PR) >> (9 - 4)) |
+			(1 << 8) |	/* power on ** */
+			((status & USBPORTSC_LSDA) << (-8 + 9));
+
+		*(unsigned short *) data = swap_16(status);
+		*(unsigned short *) (data + 2) = swap_16(cstatus);
+		len=4;
+		break;
+	case RH_CLEAR_FEATURE | RH_ENDPOINT:
+		switch (wValue) {
+		case (RH_ENDPOINT_STALL):
+			len=0;
+			break;
+		}
+		break;
+
+	case RH_CLEAR_FEATURE | RH_CLASS:
+		switch (wValue) {
+		case (RH_C_HUB_OVER_CURRENT):
+			len=0;	/* hub power over current ** */
+			break;
+		}
+		break;
+
+	case RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS:
+		usb_display_wValue(wValue,wIndex);
+		switch (wValue) {
+		case (RH_PORT_ENABLE):
+			status = in16r(usb_base_addr+USBPORTSC1+2*(wIndex-1));
+			status = (status & 0xfff5) & ~USBPORTSC_PE;
+			out16r(usb_base_addr+USBPORTSC1+2*(wIndex-1),status);
+			len=0;
+			break;
+		case (RH_PORT_SUSPEND):
+			status = in16r(usb_base_addr+USBPORTSC1+2*(wIndex-1));
+			status = (status & 0xfff5) & ~USBPORTSC_SUSP;
+			out16r(usb_base_addr+USBPORTSC1+2*(wIndex-1),status);
+			len=0;
+			break;
+		case (RH_PORT_POWER):
+			len=0;	/* port power ** */
+			break;
+		case (RH_C_PORT_CONNECTION):
+			status = in16r(usb_base_addr+USBPORTSC1+2*(wIndex-1));
+			status = (status & 0xfff5) | USBPORTSC_CSC;
+			out16r(usb_base_addr+USBPORTSC1+2*(wIndex-1),status);
+			len=0;
+			break;
+		case (RH_C_PORT_ENABLE):
+			status = in16r(usb_base_addr+USBPORTSC1+2*(wIndex-1));
+			status = (status & 0xfff5) | USBPORTSC_PEC;
+			out16r(usb_base_addr+USBPORTSC1+2*(wIndex-1),status);
+			len=0;
+			break;
+		case (RH_C_PORT_SUSPEND):
+/*** WR_RH_PORTSTAT(RH_PS_PSSC); */
+			len=0;
+			break;
+		case (RH_C_PORT_OVER_CURRENT):
+			len=0;
+			break;
+		case (RH_C_PORT_RESET):
+			rh.c_p_r[wIndex - 1] = 0;
+			len=0;
+			break;
+		}
+		break;
+	case RH_SET_FEATURE | RH_OTHER | RH_CLASS:
+		usb_display_wValue(wValue,wIndex);
+		switch (wValue) {
+		case (RH_PORT_SUSPEND):
+			status = in16r(usb_base_addr+USBPORTSC1+2*(wIndex-1));
+			status = (status & 0xfff5) | USBPORTSC_SUSP;
+			out16r(usb_base_addr+USBPORTSC1+2*(wIndex-1),status);
+			len=0;
+			break;
+		case (RH_PORT_RESET):
+			status = in16r(usb_base_addr+USBPORTSC1+2*(wIndex-1));
+			status = (status & 0xfff5) | USBPORTSC_PR;
+			out16r(usb_base_addr+USBPORTSC1+2*(wIndex-1),status);
+			wait_ms(10);
+			status = (status & 0xfff5) & ~USBPORTSC_PR;
+			out16r(usb_base_addr+USBPORTSC1+2*(wIndex-1),status);
+			udelay(10);
+			status = (status & 0xfff5) | USBPORTSC_PE;
+			out16r(usb_base_addr+USBPORTSC1+2*(wIndex-1),status);
+			wait_ms(10);
+			status = (status & 0xfff5) | 0xa;
+			out16r(usb_base_addr+USBPORTSC1+2*(wIndex-1),status);
+			len=0;
+			break;
+		case (RH_PORT_POWER):
+			len=0;	/* port power ** */
+			break;
+		case (RH_PORT_ENABLE):
+			status = in16r(usb_base_addr+USBPORTSC1+2*(wIndex-1));
+			status = (status & 0xfff5) | USBPORTSC_PE;
+			out16r(usb_base_addr+USBPORTSC1+2*(wIndex-1),status);
+			len=0;
+			break;
+		}
+		break;
+
+	case RH_SET_ADDRESS:
+		rh.devnum = wValue;
+		len=0;
+		break;
+	case RH_GET_DESCRIPTOR:
+		switch ((wValue & 0xff00) >> 8) {
+		case (0x01):	/* device descriptor */
+			i=sizeof(root_hub_config_des);
+			status=i > wLength ? wLength : i;
+			len = leni > status ? status : leni;
+			memcpy (data, root_hub_dev_des, len);
+			break;
+		case (0x02):	/* configuration descriptor */
+			i=sizeof(root_hub_config_des);
+			status=i > wLength ? wLength : i;
+			len = leni > status ? status : leni;
+			memcpy (data, root_hub_config_des, len);
+			break;
+		case (0x03):	/*string descriptors */
+			if(wValue==0x0300) {
+				i=sizeof(root_hub_str_index0);
+				status = i > wLength ? wLength : i;
+				len = leni > status ? status : leni;
+				memcpy (data, root_hub_str_index0, len);
+				break;
+			}
+			if(wValue==0x0301) {
+				i=sizeof(root_hub_str_index1);
+				status = i > wLength ? wLength : i;
+				len = leni > status ? status : leni;
+				memcpy (data, root_hub_str_index1, len);
+				break;
+			}
+			stat = USB_ST_STALLED;
+		}
+		break;
+
+	case RH_GET_DESCRIPTOR | RH_CLASS:
+		root_hub_hub_des[2] = 2;
+		i=sizeof(root_hub_hub_des);
+		status= i > wLength ? wLength : i;
+		len = leni > status ? status : leni;
+		memcpy (data, root_hub_hub_des, len);
+		break;
+	case RH_GET_CONFIGURATION:
+		*(unsigned char *) data = 0x01;
+		len = 1;
+		break;
+	case RH_SET_CONFIGURATION:
+		len=0;
+		break;
+	default:
+		stat = USB_ST_STALLED;
+	}
+	USB_RH_PRINTF("Root-Hub stat %lx port1: %x port2: %x\n\n",stat,
+	     in16r(usb_base_addr + USBPORTSC1), in16r(usb_base_addr + USBPORTSC2));
+	dev->act_len=len;
+	dev->status=stat;
+	return stat;
+
+}
+
+/********************************************************************************
+ * Some Debug Routines
+ */
+
+#ifdef	USB_RH_DEBUG
+
+static void usb_display_Req(unsigned short req)
+{
+	USB_RH_PRINTF("- Root-Hub Request: ");
+	switch (req) {
+	case RH_GET_STATUS:
+		USB_RH_PRINTF("Get Status ");
+		break;
+	case RH_GET_STATUS | RH_INTERFACE:
+		USB_RH_PRINTF("Get Status Interface ");
+		break;
+	case RH_GET_STATUS | RH_ENDPOINT:
+		USB_RH_PRINTF("Get Status Endpoint ");
+		break;
+	case RH_GET_STATUS | RH_CLASS:
+		USB_RH_PRINTF("Get Status Class");
+		break;	/* hub power ** */
+	case RH_GET_STATUS | RH_OTHER | RH_CLASS:
+		USB_RH_PRINTF("Get Status Class Others");
+		break;
+	case RH_CLEAR_FEATURE | RH_ENDPOINT:
+		USB_RH_PRINTF("Clear Feature Endpoint ");
+		break;
+	case RH_CLEAR_FEATURE | RH_CLASS:
+		USB_RH_PRINTF("Clear Feature Class ");
+		break;
+	case RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS:
+		USB_RH_PRINTF("Clear Feature Other Class ");
+		break;
+	case RH_SET_FEATURE | RH_OTHER | RH_CLASS:
+		USB_RH_PRINTF("Set Feature Other Class ");
+		break;
+	case RH_SET_ADDRESS:
+		USB_RH_PRINTF("Set Address ");
+		break;
+	case RH_GET_DESCRIPTOR:
+		USB_RH_PRINTF("Get Descriptor ");
+		break;
+	case RH_GET_DESCRIPTOR | RH_CLASS:
+		USB_RH_PRINTF("Get Descriptor Class ");
+		break;
+	case RH_GET_CONFIGURATION:
+		USB_RH_PRINTF("Get Configuration ");
+		break;
+	case RH_SET_CONFIGURATION:
+		USB_RH_PRINTF("Get Configuration ");
+		break;
+	default:
+		USB_RH_PRINTF("****UNKNOWN**** 0x%04X ",req);
+	}
+	USB_RH_PRINTF("\n");
+
+}
+
+static void usb_display_wValue(unsigned short wValue,unsigned short wIndex)
+{
+	switch (wValue) {
+		case (RH_PORT_ENABLE):
+			USB_RH_PRINTF("Root-Hub: Enable Port %d\n",wIndex);
+			break;
+		case (RH_PORT_SUSPEND):
+			USB_RH_PRINTF("Root-Hub: Suspend Port %d\n",wIndex);
+			break;
+		case (RH_PORT_POWER):
+			USB_RH_PRINTF("Root-Hub: Port Power %d\n",wIndex);
+			break;
+		case (RH_C_PORT_CONNECTION):
+			USB_RH_PRINTF("Root-Hub: C Port Connection Port %d\n",wIndex);
+			break;
+		case (RH_C_PORT_ENABLE):
+			USB_RH_PRINTF("Root-Hub: C Port Enable Port %d\n",wIndex);
+			break;
+		case (RH_C_PORT_SUSPEND):
+			USB_RH_PRINTF("Root-Hub: C Port Suspend Port %d\n",wIndex);
+			break;
+		case (RH_C_PORT_OVER_CURRENT):
+			USB_RH_PRINTF("Root-Hub: C Port Over Current Port %d\n",wIndex);
+			break;
+		case (RH_C_PORT_RESET):
+			USB_RH_PRINTF("Root-Hub: C Port reset Port %d\n",wIndex);
+			break;
+		default:
+			USB_RH_PRINTF("Root-Hub: unknown %x %x\n",wValue,wIndex);
+			break;
+	}
+}
+
+#endif
+
+
+
+#ifdef	USB_UHCI_DEBUG
+
+static int usb_display_td(uhci_td_t *td)
+{
+	unsigned long tmp;
+	int valid;
+
+	printf("TD at %p:\n",td);
+
+	tmp=swap_32(td->link);
+	printf("Link points to 0x%08lX, %s first, %s, %s\n",tmp&0xfffffff0,
+		((tmp & 0x4)==0x4) ? "Depth" : "Breath",
+		((tmp & 0x2)==0x2) ? "QH" : "TD",
+		((tmp & 0x1)==0x1) ? "invalid" : "valid");
+	valid=((tmp & 0x1)==0x0);
+	tmp=swap_32(td->status);
+	printf("     %s %ld Errors %s %s %s \n     %s %s %s %s %s %s\n     Len 0x%lX\n",
+		(((tmp>>29)&0x1)==0x1) ? "SPD Enable" : "SPD Disable",
+		((tmp>>28)&0x3),
+		(((tmp>>26)&0x1)==0x1) ? "Low Speed" : "Full Speed",
+		(((tmp>>25)&0x1)==0x1) ? "ISO " : "",
+		(((tmp>>24)&0x1)==0x1) ? "IOC " : "",
+		(((tmp>>23)&0x1)==0x1) ? "Active " : "Inactive ",
+		(((tmp>>22)&0x1)==0x1) ? "Stalled" : "",
+		(((tmp>>21)&0x1)==0x1) ? "Data Buffer Error" : "",
+		(((tmp>>20)&0x1)==0x1) ? "Babble" : "",
+		(((tmp>>19)&0x1)==0x1) ? "NAK" : "",
+		(((tmp>>18)&0x1)==0x1) ? "Bitstuff Error" : "",
+		(tmp&0x7ff));
+	tmp=swap_32(td->info);
+	printf("     MaxLen 0x%lX\n",((tmp>>21)&0x7FF));
+	printf("     %s Endpoint 0x%lX Dev Addr 0x%lX PID 0x%lX\n",((tmp>>19)&0x1)==0x1 ? "TOGGLE" : "",
+		((tmp>>15)&0xF),((tmp>>8)&0x7F),tmp&0xFF);
+	tmp=swap_32(td->buffer);
+	printf("     Buffer 0x%08lX\n",tmp);
+	printf("     DEV %08lX\n",td->dev_ptr);
+	return valid;
+}
+
+
+void usb_show_td(int max)
+{
+	int i;
+	if(max>0) {
+		for(i=0;i<max;i++) {
+			usb_display_td(&tmp_td[i]);
+		}
+	}
+	else {
+		i=0;
+		do {
+			printf("tmp_td[%d]\n",i);
+		}while(usb_display_td(&tmp_td[i++]));
+	}
+}
+
+
+#endif
+#endif /* CONFIG_USB_UHCI */
+
+/* EOF */
diff --git a/board/MAI/AmigaOneG3SE/usb_uhci.h b/board/MAI/AmigaOneG3SE/usb_uhci.h
new file mode 100644
index 00000000000..7fda60b6a15
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/usb_uhci.h
@@ -0,0 +1,194 @@
+/*
+ * (C) Copyright 2001
+ * Denis Peter, MPL AG Switzerland
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * Note: Part of this code has been derived from linux
+ *
+ */
+#ifndef _USB_UHCI_H_
+#define _USB_UHCI_H_
+
+#undef USB_UHCI_VEND_ID
+#define USB_UHCI_VEND_ID PCI_VENDOR_ID_VIA
+#undef USB_UHCI_DEV_ID
+#define USB_UHCI_DEV_ID 0x3038
+
+/* Command register */
+#define USBCMD		0
+#define   USBCMD_RS       0x0001	/* Run/Stop */
+#define   USBCMD_HCRESET  0x0002	/* Host reset */
+#define   USBCMD_GRESET   0x0004	/* Global reset */
+#define   USBCMD_EGSM     0x0008	/* Global Suspend Mode */
+#define   USBCMD_FGR      0x0010	/* Force Global Resume */
+#define   USBCMD_SWDBG    0x0020	/* SW Debug mode */
+#define   USBCMD_CF       0x0040	/* Config Flag (sw only) */
+#define   USBCMD_MAXP     0x0080	/* Max Packet (0 = 32, 1 = 64) */
+
+/* Status register */
+#define USBSTS		2
+#define   USBSTS_USBINT   0x0001	/* Interrupt due to IOC */
+#define   USBSTS_ERROR    0x0002	/* Interrupt due to error */
+#define   USBSTS_RD       0x0004	/* Resume Detect */
+#define   USBSTS_HSE      0x0008	/* Host System Error - basically PCI problems */
+#define   USBSTS_HCPE     0x0010	/* Host Controller Process Error - the scripts were buggy */
+#define   USBSTS_HCH      0x0020	/* HC Halted */
+
+/* Interrupt enable register */
+#define USBINTR		4
+#define   USBINTR_TIMEOUT 0x0001	/* Timeout/CRC error enable */
+#define   USBINTR_RESUME  0x0002	/* Resume interrupt enable */
+#define   USBINTR_IOC     0x0004	/* Interrupt On Complete enable */
+#define   USBINTR_SP      0x0008	/* Short packet interrupt enable */
+
+#define USBFRNUM      6
+#define USBFLBASEADD  8
+#define USBSOF        12
+
+/* USB port status and control registers */
+#define USBPORTSC1	16
+#define USBPORTSC2	18
+#define   USBPORTSC_CCS   0x0001	/* Current Connect Status ("device present") */
+#define   USBPORTSC_CSC   0x0002	/* Connect Status Change */
+#define   USBPORTSC_PE    0x0004	/* Port Enable */
+#define   USBPORTSC_PEC   0x0008	/* Port Enable Change */
+#define   USBPORTSC_LS    0x0030	/* Line Status */
+#define   USBPORTSC_RD    0x0040	/* Resume Detect */
+#define   USBPORTSC_LSDA  0x0100	/* Low Speed Device Attached */
+#define   USBPORTSC_PR    0x0200	/* Port Reset */
+#define   USBPORTSC_SUSP  0x1000	/* Suspend */
+
+/* Legacy support register */
+#define USBLEGSUP 0xc0
+#define USBLEGSUP_DEFAULT 0x2000	/* only PIRQ enable set */
+
+#define UHCI_NULL_DATA_SIZE 0x7ff	/* for UHCI controller TD */
+#define UHCI_PID            0xff	/* PID MASK */
+
+#define UHCI_PTR_BITS       0x000F
+#define UHCI_PTR_TERM       0x0001
+#define UHCI_PTR_QH         0x0002
+#define UHCI_PTR_DEPTH      0x0004
+
+/* for TD <status>: */
+#define TD_CTRL_SPD         (1 << 29)	/* Short Packet Detect */
+#define TD_CTRL_C_ERR_MASK  (3 << 27)	/* Error Counter bits */
+#define TD_CTRL_LS          (1 << 26)	/* Low Speed Device */
+#define TD_CTRL_IOS         (1 << 25)	/* Isochronous Select */
+#define TD_CTRL_IOC         (1 << 24)	/* Interrupt on Complete */
+#define TD_CTRL_ACTIVE      (1 << 23)	/* TD Active */
+#define TD_CTRL_STALLED     (1 << 22)	/* TD Stalled */
+#define TD_CTRL_DBUFERR     (1 << 21)	/* Data Buffer Error */
+#define TD_CTRL_BABBLE      (1 << 20)	/* Babble Detected */
+#define TD_CTRL_NAK         (1 << 19)	/* NAK Received */
+#define TD_CTRL_CRCTIMEO    (1 << 18)	/* CRC/Time Out Error */
+#define TD_CTRL_BITSTUFF    (1 << 17)	/* Bit Stuff Error */
+#define TD_CTRL_ACTLEN_MASK 0x7ff	/* actual length, encoded as n - 1 */
+
+#define TD_CTRL_ANY_ERROR	(TD_CTRL_STALLED | TD_CTRL_DBUFERR | \
+				 TD_CTRL_BABBLE | TD_CTRL_CRCTIME | TD_CTRL_BITSTUFF)
+
+#define TD_TOKEN_TOGGLE		19
+
+/* ------------------------------------------------------------------------------------
+   Virtual Root HUB
+   ------------------------------------------------------------------------------------ */
+/* destination of request */
+#define RH_INTERFACE               0x01
+#define RH_ENDPOINT                0x02
+#define RH_OTHER                   0x03
+
+#define RH_CLASS                   0x20
+#define RH_VENDOR                  0x40
+
+/* Requests: bRequest << 8 | bmRequestType */
+#define RH_GET_STATUS           0x0080
+#define RH_CLEAR_FEATURE        0x0100
+#define RH_SET_FEATURE          0x0300
+#define RH_SET_ADDRESS          0x0500
+#define RH_GET_DESCRIPTOR       0x0680
+#define RH_SET_DESCRIPTOR       0x0700
+#define RH_GET_CONFIGURATION    0x0880
+#define RH_SET_CONFIGURATION    0x0900
+#define RH_GET_STATE            0x0280
+#define RH_GET_INTERFACE        0x0A80
+#define RH_SET_INTERFACE        0x0B00
+#define RH_SYNC_FRAME           0x0C80
+/* Our Vendor Specific Request */
+#define RH_SET_EP               0x2000
+
+/* Hub port features */
+#define RH_PORT_CONNECTION         0x00
+#define RH_PORT_ENABLE             0x01
+#define RH_PORT_SUSPEND            0x02
+#define RH_PORT_OVER_CURRENT       0x03
+#define RH_PORT_RESET              0x04
+#define RH_PORT_POWER              0x08
+#define RH_PORT_LOW_SPEED          0x09
+#define RH_C_PORT_CONNECTION       0x10
+#define RH_C_PORT_ENABLE           0x11
+#define RH_C_PORT_SUSPEND          0x12
+#define RH_C_PORT_OVER_CURRENT     0x13
+#define RH_C_PORT_RESET            0x14
+
+/* Hub features */
+#define RH_C_HUB_LOCAL_POWER       0x00
+#define RH_C_HUB_OVER_CURRENT      0x01
+
+#define RH_DEVICE_REMOTE_WAKEUP    0x00
+#define RH_ENDPOINT_STALL          0x01
+
+/* Our Vendor Specific feature */
+#define RH_REMOVE_EP               0x00
+
+
+#define RH_ACK                     0x01
+#define RH_REQ_ERR                 -1
+#define RH_NACK                    0x00
+
+
+/* Transfer descriptor structure */
+typedef struct {
+	unsigned long link;     /* next td/qh (LE)*/
+	unsigned long status;   /* status of the td */
+	unsigned long info;     /* Max Lenght / Endpoint / device address and PID */
+	unsigned long buffer;   /* pointer to data buffer (LE) */
+	unsigned long dev_ptr;  /* pointer to the assigned device (BE) */
+	unsigned long res[3];   /* reserved (TDs must be 8Byte aligned) */
+} uhci_td_t, *puhci_td_t;
+
+/* Queue Header structure */
+typedef struct {
+	unsigned long head;       /* Next QH (LE)*/
+	unsigned long element;		/* Queue element pointer (LE) */
+	unsigned long res[5];     /* reserved */
+	unsigned long dev_ptr;    /* if 0 no tds have been assigned to this qh */
+} uhci_qh_t, *puhci_qh_t;
+
+struct virt_root_hub {
+	int devnum;		            /* Address of Root Hub endpoint */
+	int numports;             /* number of ports */
+	int c_p_r[8];             /* C_PORT_RESET */
+};
+
+
+#endif /* _USB_UHCI_H_ */
+
+
diff --git a/board/MAI/AmigaOneG3SE/via686.c b/board/MAI/AmigaOneG3SE/via686.c
new file mode 100644
index 00000000000..0483ca9fbdf
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/via686.c
@@ -0,0 +1,299 @@
+/*
+ * (C) Copyright 2002
+ * Hyperion Entertainment, Hans-JoergF@hyperion-entertainment.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#include <common.h>
+#include <pci.h>
+#include <ata.h>
+#include "memio.h"
+#include "articiaS.h"
+#include "via686.h"
+#include "i8259.h"
+
+#undef VIA_DEBUG
+
+#ifdef  VIA_DEBUG
+#define PRINTF(fmt,args...)     printf (fmt ,##args)
+#else
+#define PRINTF(fmt,args...)
+#endif
+
+
+/*  Setup the ISA-to-PCI host bridge */
+void via_isa_init(pci_dev_t dev, struct pci_config_table *table)
+{
+    char regval;
+    if (PCI_FUNC(dev) == 0)
+    {
+	PRINTF("... PCI-to-ISA bridge, dev=0x%X\n", dev);
+
+	/*  Enable I/O Recovery time */
+	pci_write_config_byte(dev, 0x40, 0x08);
+
+	/*  Enable ISA refresh */
+	pci_write_config_byte(dev, 0x41, 0x41); /*  was 01 */
+
+	/*  Enable ISA line buffer */
+	pci_write_config_byte(dev, 0x45, 0x80);
+
+	/*  Gate INTR, and flush line buffer */
+	pci_write_config_byte(dev, 0x46, 0x60);
+
+	/*  Enable EISA ports 4D0/4D1. Do we need this ? */
+	pci_write_config_byte(dev, 0x47, 0xe6); /*  was 20 */
+
+	/*  512 K PCI Decode */
+	pci_write_config_byte(dev, 0x48, 0x01);
+
+	/*  Wait for PGNT before grant to ISA Master/DMA */
+	/*  ports 0-FF to SDBus */
+	/*  IRQ 14 and 15 for ide 0/1 */
+	pci_write_config_byte(dev, 0x4a, 0x04); /*  Was c4 */
+
+	/*  Plug'n'Play */
+	/*  Parallel DRQ 3, Floppy DRQ 2 (default) */
+	pci_write_config_byte(dev, 0x50, 0x0e);
+
+	/*  IRQ Routing for Floppy and Parallel port */
+	/*  IRQ 6 for floppy, IRQ 7 for parallel port */
+	pci_write_config_byte(dev, 0x51, 0x76);
+
+	/*  IRQ Routing for serial ports (take IRQ 3 and 4) */
+	pci_write_config_byte(dev, 0x52, 0x34);
+
+	/*  All IRQ's level triggered. */
+	pci_write_config_byte(dev, 0x54, 0x00);
+
+	/*  PCI IRQ's all at IRQ 9 */
+	pci_write_config_byte(dev, 0x55, 0x90);
+	pci_write_config_byte(dev, 0x56, 0x99);
+	pci_write_config_byte(dev, 0x57, 0x90);
+
+	/*  Enable Keyboard */
+	pci_read_config_byte(dev, 0x5A, &regval);
+	regval |= 0x01;
+	pci_write_config_byte(dev, 0x5A, regval);
+
+	pci_write_config_byte(dev, 0x80, 0);
+	pci_write_config_byte(dev, 0x85, 0x01);
+
+/* 	pci_write_config_byte(dev, 0x77, 0x00); */
+    }
+}
+
+/*
+ * Initialize PNP irq routing
+ */
+
+void via_init_irq_routing(uint8 irq_map[])
+{
+    char *s;
+    uint8 level_edge_bits = 0xf;
+
+    /* Set irq routings */
+    pci_write_cfg_byte(0, 7<<3, 0x55, irq_map[0]<<4);
+    pci_write_cfg_byte(0, 7<<3, 0x56, irq_map[1] | irq_map[2]<<4);
+    pci_write_cfg_byte(0, 7<<3, 0x57, irq_map[3]<<4);
+
+    /*
+     * Gather level/edge bits
+     * Default is to assume level triggered
+     */
+
+    s = getenv("pci_irqa_select");
+    if (s && strcmp(s, "level") == 0)
+	level_edge_bits &= ~0x01;
+
+    s = getenv("pci_irqb_select");
+    if (s && strcmp(s, "level") == 0)
+	level_edge_bits &= ~0x02;
+
+    s = getenv("pci_irqc_select");
+    if (s && strcmp(s, "level") == 0)
+	level_edge_bits &= ~0x04;
+
+    s = getenv("pci_irqd_select");
+    if (s && strcmp(s, "level") == 0)
+	level_edge_bits &= ~0x08;
+
+    PRINTF("IRQ map\n");
+    PRINTF("%d: %s\n", irq_map[0], level_edge_bits&0x1 ? "edge" : "level");
+    PRINTF("%d: %s\n", irq_map[1], level_edge_bits&0x2 ? "edge" : "level");
+    PRINTF("%d: %s\n", irq_map[2], level_edge_bits&0x4 ? "edge" : "level");
+    PRINTF("%d: %s\n", irq_map[3], level_edge_bits&0x8 ? "edge" : "level");
+    pci_write_cfg_byte(0, 7<<3, 0x54, level_edge_bits);
+
+    PRINTF("%02x %02x %02x %02x\n", pci_read_cfg_byte(0, 7<<3, 0x54),
+	   pci_read_cfg_byte(0, 7<<3, 0x55), pci_read_cfg_byte(0, 7<<3, 0x56),
+	   pci_read_cfg_byte(0, 7<<3, 0x57));
+}
+
+
+/*  Setup the IDE controller. This doesn't seem to work yet. I/O to an IDE controller port */
+/*  always return the last character output on the serial port (!) */
+/*  This function is called by the pnp-library when it encounters 0:7:1 */
+void via_cfgfunc_ide_init(struct pci_controller *host, pci_dev_t dev, struct pci_config_table *table)
+{
+    PRINTF("... IDE controller, dev=0x%X\n", dev);
+
+    /*  Enable both IDE channels. */
+    pci_write_config_byte(dev, 0x40, 0x03);
+    /*  udelay(10000); */
+    /*  udelay(10000); */
+
+    /*  Enable IO Space */
+    pci_write_config_word(dev, 0x04, 0x03);
+
+    /*  Set to compatibility mode */
+    pci_write_config_byte(dev, 0x09, 0x8A); /*  WAS: 0x8f); */
+
+    /*  Set to legacy interrupt mode */
+    pci_write_config_byte(dev, 0x3d, 0x00); /* WAS: 0x01); */
+
+}
+
+
+/*  Set the base address of the floppy controller to 0x3F0 */
+void via_fdc_init(pci_dev_t dev)
+{
+    unsigned char c;
+    /*  Enable Configuration mode */
+    pci_read_config_byte(dev, 0x85, &c);
+    c |= 0x02;
+    pci_write_config_byte(dev, 0x85, c);
+
+    /*  Set floppy controller port to 0x3F0. */
+    SIO_WRITE_CONFIG(0xE3, (0x3F<<2));
+
+    /*  Enable floppy controller */
+    SIO_READ_CONFIG(0xE2, c);
+    c |= 0x10;
+    SIO_WRITE_CONFIG(0xE2, c);
+
+    /*  Switch of configuration mode */
+    pci_read_config_byte(dev, 0x85, &c);
+    c &= ~0x02;
+    pci_write_config_byte(dev, 0x85, c);
+}
+
+/*  Init function 0 of the via southbridge. Called by the pnp-library */
+void via_cfgfunc_via686(struct pci_controller *host, pci_dev_t dev, struct pci_config_table *table)
+{
+    if (PCI_FUNC(dev) == 0)
+    {
+	/* FIXME: Try to generate a PCI reset */
+	/* unsigned char c; */
+	/* pci_read_config_byte(dev, 0x47, &c); */
+	/* pci_write_config_byte(dev, 0x47, c | 0x01); */
+
+	via_isa_init(dev, table);
+	via_fdc_init(dev);
+    }
+}
+
+__asm         ("    .globl via_calibrate_time_base \n"
+	       "via_calibrate_time_base: 	   \n"
+               "   lis     9, 0xfe00		   \n"
+               "   li      0, 0x00		   \n"
+	       "   mttbu   0			   \n"
+	       "   mttbl   0			   \n"
+	       "ctb_loop:			   \n"
+               "   lbz     0, 0x61(9)		   \n"
+               "   eieio			   \n"
+               "   andi.   0, 0, 0x20		   \n"
+               "   beq     ctb_loop		   \n"
+               "ctb_done:			   \n"
+               "   mftb    3			   \n"
+               "   blr");
+
+extern unsigned long via_calibrate_time_base(void);
+
+void via_calibrate_bus_freq(void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+
+    unsigned long tb;
+
+    /* This is 20 microseconds */
+    #define CALIBRATE_TIME 28636
+
+
+    /* Enable the timer (and disable speaker) */
+    unsigned char c;
+    c = in_byte(0x61);
+    out_byte(0x61, ((c & ~0x02) | 0x01));
+
+    /* Set timer 2 to low/high writing */
+    out_byte(0x43, 0xb0);
+    out_byte(0x42, CALIBRATE_TIME & 0xff);
+    out_byte(0x42, CALIBRATE_TIME >>8);
+
+    /* Read the time base */
+    tb = via_calibrate_time_base();
+
+    if (tb >= 700000)
+	gd->bus_clk = 133333333;
+    else
+	gd->bus_clk = 100000000;
+
+}
+
+
+void ide_led(uchar led, uchar status)
+{
+/*     unsigned char c = in_byte(0x92); */
+
+/*     if (!status) */
+/* 	out_byte(0x92, c | 0xC0); */
+/*     else */
+/* 	out_byte(0x92, c & ~0xC0); */
+}
+
+
+void via_init_afterscan(void)
+{
+    /* Modify IDE controller setup */
+    pci_write_cfg_byte(0, 7<<3|1, PCI_LATENCY_TIMER, 0x20);
+    pci_write_cfg_byte(0, 7<<3|1, PCI_COMMAND, PCI_COMMAND_IO|PCI_COMMAND_MEMORY|PCI_COMMAND_MASTER);
+    pci_write_cfg_byte(0, 7<<3|1, PCI_INTERRUPT_LINE, 0xff);
+    pci_write_cfg_byte(0, 7<<3|1, 0x40, 0x0b);   /* FIXME: Might depend on drives connected */
+    pci_write_cfg_byte(0, 7<<3|1, 0x41, 0x42);   /* FIXME: Might depend on drives connected */
+    pci_write_cfg_byte(0, 7<<3|1, 0x43, 0x05);
+    pci_write_cfg_byte(0, 7<<3|1, 0x44, 0x18);
+    pci_write_cfg_byte(0, 7<<3|1, 0x45, 0x10);
+    pci_write_cfg_byte(0, 7<<3|1, 0x4e, 0x22);   /* FIXME: Not documented, but set in PC bios */
+    pci_write_cfg_byte(0, 7<<3|1, 0x4f, 0x20);   /* FIXME: Not documented */
+
+    /* Modify some values in the USB controller */
+    pci_write_cfg_byte(0, 7<<3|2, 0x05, 0x17);
+    pci_write_cfg_byte(0, 7<<3|2, 0x06, 0x01);
+    pci_write_cfg_byte(0, 7<<3|2, 0x41, 0x12);
+    pci_write_cfg_byte(0, 7<<3|2, 0x42, 0x03);
+    pci_write_cfg_byte(0, 7<<3|2, PCI_LATENCY_TIMER, 0x40);
+
+    pci_write_cfg_byte(0, 7<<3|3, 0x05, 0x17);
+    pci_write_cfg_byte(0, 7<<3|3, 0x06, 0x01);
+    pci_write_cfg_byte(0, 7<<3|3, 0x41, 0x12);
+    pci_write_cfg_byte(0, 7<<3|3, 0x42, 0x03);
+    pci_write_cfg_byte(0, 7<<3|3, PCI_LATENCY_TIMER, 0x40);
+
+
+}
diff --git a/board/MAI/AmigaOneG3SE/via686.h b/board/MAI/AmigaOneG3SE/via686.h
new file mode 100644
index 00000000000..2a06a05e16d
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/via686.h
@@ -0,0 +1,29 @@
+#ifndef VIA686_H_
+#define VIA686_H_
+
+
+#define CMOS_ADDR         0x70
+#define CMOS_DATA         0x71
+
+#define I8259_MASTER_CONTROL 0x20
+#define I8259_MASTER_MASK    0x21
+
+#define I8259_SLAVE_CONTROL  0xA0
+#define I8259_SLAVE_MASK     0xA1
+
+#define SIO_CONFIG_ADDR 0x3F0
+#define SIO_CONFIG_DATA 0x3F1
+
+#define SIO_WRITE_CONFIG(addr, byte) \
+   out_byte(SIO_CONFIG_ADDR, addr);  \
+   out_byte(SIO_CONFIG_DATA, byte);
+
+#define SIO_READ_CONFIG(addr, byte) \
+   out_byte(SIO_CONFIG_ADDR, addr); \
+   byte = in_byte(SIO_CONFIG_DATA);
+
+void via_init(void);
+
+void via_calibrate_bus_freq(void);
+
+#endif
diff --git a/board/MAI/AmigaOneG3SE/video.c b/board/MAI/AmigaOneG3SE/video.c
new file mode 100644
index 00000000000..d0e366c2ed5
--- /dev/null
+++ b/board/MAI/AmigaOneG3SE/video.c
@@ -0,0 +1,539 @@
+/*
+ * (C) Copyright 2002
+ * Hyperion Entertainment, Hans-JoergF@hyperion-entertainment.com 
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <devices.h>
+#include "memio.h"
+#include <part.h>
+
+unsigned char *cursor_position;
+unsigned int cursor_row;
+unsigned int cursor_col;
+
+unsigned char current_attr;
+
+unsigned int video_numrows = 25;
+unsigned int video_numcols = 80;
+unsigned int video_scrolls = 0;
+
+#define VIDEO_BASE (unsigned char *)0xFD0B8000
+#define VIDEO_ROWS video_numrows
+#define VIDEO_COLS video_numcols
+#define VIDEO_PITCH (2 * video_numcols)
+#define VIDEO_SIZE (video_numrows * video_numcols * 2)
+#define VIDEO_NAME "vga"
+
+void video_test(void);
+void video_putc(char ch);
+void video_puts(char *string);
+void video_scroll(int rows);
+void video_banner(void);
+int  video_init(void);
+int  video_start(void);
+int  video_rows(void);
+int  video_cols(void);
+
+char *prompt_string = "=>";
+
+void video_set_color(unsigned char attr)
+{
+    unsigned char *fb = (unsigned char *)VIDEO_BASE;
+    int i;
+
+    current_attr = video_get_attr();
+
+    for (i=0; i<VIDEO_SIZE; i+=2)
+    {
+	*(fb+i+1) = current_attr;
+    }
+}
+
+unsigned char video_get_attr(void)
+{
+    char *s;
+    unsigned char attr;
+
+    attr = 0x0f;
+
+    s = getenv("vga_fg_color");
+    if (s)
+    {
+	attr = atoi(s);
+    }
+
+    s = getenv("vga_bg_color");
+    if (s)
+    {
+	attr |= atoi(s)<<4;
+    }
+
+    return attr;
+}
+
+int video_inited = 0;
+
+int drv_video_init(void)
+{
+    int error, devices = 1 ;
+    device_t vgadev ;
+    if (video_inited) return 1;
+    video_inited = 1;
+    video_init();
+    memset (&vgadev, 0, sizeof(vgadev));
+    
+    strcpy(vgadev.name, VIDEO_NAME);
+    vgadev.flags =  DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
+    vgadev.putc = video_putc;
+    vgadev.puts = video_puts;
+    vgadev.getc = NULL;
+    vgadev.tstc = NULL;
+    vgadev.start = video_start;
+    
+    error = device_register (&vgadev);
+
+    if (error == 0)
+    {
+	char *s = getenv("stdout");
+	if (s && strcmp(s, VIDEO_NAME)==0)
+	{
+	    if (overwrite_console()) return 1;
+	    error = console_assign(stdout, VIDEO_NAME);
+	    if (error == 0) return 1;
+	    else return error;
+	}
+	return 1;
+    }
+
+    return error;
+}
+
+int video_init(void)
+{
+    cursor_position = VIDEO_BASE; // Color text display base
+    cursor_row = 0;
+    cursor_col = 0;
+    current_attr = video_get_attr(); // Currently selected value for attribute.
+//    video_test();
+    video_set_color(current_attr);
+
+    return 0;
+}
+
+void video_set_cursor(int line, int column)
+{
+    unsigned short offset = line*video_numcols + column;
+    cursor_position = VIDEO_BASE +  line*VIDEO_PITCH + column*2;
+    out_byte(0x3D4, 0x0E);
+    out_byte(0x3D5, offset/256);
+    out_byte(0x3D4, 0x0F);
+    out_byte(0x3D5, offset%256);
+}
+
+void video_write_char(int character)
+{
+    *cursor_position = character;
+    *(cursor_position+1) = current_attr;
+}
+
+void video_test(void)
+{
+
+}
+
+void video_putc(char ch)
+{
+    switch(ch)
+    {
+    case '\n':
+	cursor_col = 0;
+	cursor_row += 1;
+	break;
+    case '\r':
+	cursor_col = 0;
+	break;
+    case '\b':
+	if (cursor_col) cursor_col--;
+	else return;
+	break;
+    case '\t':
+	cursor_col = (cursor_col/8+1)*8;
+	break;
+    default:
+	video_write_char(ch);
+	cursor_col++;
+	if (cursor_col > VIDEO_COLS-1)
+	{
+	    cursor_row++;
+	    cursor_col=0;
+	}
+    }
+
+    if (cursor_row > VIDEO_ROWS-1)
+	video_scroll(1);
+    video_set_cursor(cursor_row, cursor_col);
+}
+
+void video_scroll(int rows)
+{
+    unsigned short clear = ((unsigned short)current_attr) | (' '<<8);
+    unsigned short* addr16 = &((unsigned short *)VIDEO_BASE)[(VIDEO_ROWS-rows)*VIDEO_COLS];
+    int i;
+    char *s;
+
+    s = getenv("vga_askscroll");
+    video_scrolls += rows;
+
+    if (video_scrolls >= video_numrows)
+    {
+	if (s && strcmp(s, "yes"))
+	{
+	    while (-1 == tstc());
+	}
+
+	video_scrolls = 0;
+    }
+
+
+    memcpy(VIDEO_BASE, VIDEO_BASE+rows*(VIDEO_COLS*2), (VIDEO_ROWS-rows)*(VIDEO_COLS*2));
+    for (i = 0 ; i < rows * VIDEO_COLS ; i++)
+	addr16[i] = clear;
+    cursor_row-=rows;
+    cursor_col=0;
+}
+
+void video_puts(char *string)
+{
+    while (*string)
+    {
+	video_putc(*string);
+	string++;
+    }
+}
+
+int video_start(void)
+{
+    return 0;
+}
+
+unsigned char video_single_box[] =
+{
+    218, 196, 191,
+    179,      179,
+    192, 196, 217
+};
+
+unsigned char video_double_box[] =
+{
+    201, 205, 187,
+    186,      186,
+    200, 205, 188
+};
+
+unsigned char video_single_title[] =
+{
+    195, 196, 180, 180, 195
+};
+
+unsigned char video_double_title[] =
+{
+    204, 205, 185, 181, 198
+};
+
+#define SINGLE_BOX 0
+#define DOUBLE_BOX 1
+
+unsigned char *video_addr(int x, int y)
+{
+    return VIDEO_BASE + 2*(VIDEO_COLS*y) + 2*x;
+}
+
+void video_bios_print_string(char *s, int x, int y, int attr, int count)
+{
+    int cattr = current_attr;
+    if (attr != -1) current_attr = attr;
+    video_set_cursor(x,y);
+    while (count)
+    {
+	char c = *s++;
+	if (attr == -1) current_attr = *s++;
+	video_putc(c);
+	count--;
+    }
+}
+
+void video_draw_box(int style, int attr, char *title, int separate, int x, int y, int w, int h)
+{
+    unsigned char *fb, *fb2; 
+    unsigned char *st = (style == SINGLE_BOX)?video_single_box : video_double_box;
+    unsigned char *ti = (style == SINGLE_BOX)?video_single_title : video_double_title;
+    int i;
+
+    fb = video_addr(x,y);
+    *(fb) = st[0];
+    *(fb+1) = attr;
+    fb += 2;
+
+    fb2 = video_addr(x,y+h-1);
+    *(fb2) = st[5];
+    *(fb2+1) = attr;
+    fb2 += 2;
+
+    for (i=0; i<w-2;i++)
+    {
+	*fb = st[1];
+	fb++;
+	*fb = attr;
+	fb++;
+
+	*fb2 = st[6];
+	fb2++;
+	*fb2 = attr;
+	fb2++;
+
+    }
+    *fb = st[2];
+    *(fb+1) = attr;
+
+    *fb2 = st[7];
+    *(fb2+1) = attr;
+
+    fb  = video_addr(x, y+1);
+    fb2 = video_addr(x+w-1, y+1);
+    for (i=0; i<h-2; i++)
+    {
+	*fb = st[3];
+	*(fb+1) = attr; fb += 2*VIDEO_COLS;
+
+	*fb2 = st[4]; 
+	*(fb2+1) = attr; fb2 += 2*VIDEO_COLS;
+    }
+    
+    // Draw title
+    if (title)
+    {
+	if (separate == 0)
+	{
+	    fb = video_addr(x+1, y);
+	    *fb = ti[3];
+	    fb += 2;
+	    *fb = ' ';
+	    fb += 2;
+	    while (*title)
+	    {
+		*fb = *title;
+		fb ++;
+		*fb = attr;
+		fb++; title++;
+	    }
+	    *fb = ' ';
+	    fb += 2;
+	    *fb = ti[4];
+	}
+	else
+	{
+	    fb = video_addr(x, y+2);
+	    *fb = ti[0];
+	    fb += 2;
+	    for (i=0; i<w-2; i++)
+	    {
+		*fb = ti[1];
+		*(fb+1) = attr;
+		fb += 2;
+	    }
+	    *fb = ti[2];
+	    *(fb+1) = attr;
+	    fb = video_addr(x+1, y+1);
+	    for (i=0; i<w-2; i++)
+	    {
+		*fb = ' ';
+		*(fb+1) = attr;
+		fb += 2;
+	    }
+	    fb = video_addr(x+2, y+1);
+	    
+	    while (*title)
+	    {
+		*fb = *title;
+		*(fb+1) = attr;
+		fb += 2;
+		title++;
+	    }
+	}
+    }
+
+}
+
+void video_draw_text(int x, int y, int attr, char *text)
+{
+    unsigned char *fb = video_addr(x,y);
+    while (*text)
+    {
+	*fb++ = *text++;
+	*fb++ = attr;
+    }
+}
+
+void video_save_rect(int x, int y, int w, int h, void *save_area, int clearchar, int clearattr)
+{
+    unsigned char *save = (unsigned char *)save_area;
+    unsigned char *fb = video_addr(x,y);
+    int i,j;
+    for (i=0; i<h; i++)
+    {
+	unsigned char *fbb = fb;
+	for (j=0; j<w; j++)
+	{
+	    *save ++ = *fb;
+	    if (clearchar > 0) *fb = clearchar;
+	    fb ++;
+	    *save ++ = *fb;
+	    if (clearattr > 0) *fb = clearattr;
+	}
+	fb = fbb + 2*VIDEO_COLS;
+    }
+}
+
+void video_restore_rect(int x, int y, int w, int h, void *save_area)
+{   
+    unsigned char *save = (unsigned char *)save_area;
+    unsigned char *fb = video_addr(x,y);
+    int i,j;
+    for (i=0; i<h; i++)
+    {
+	unsigned char *fbb = fb;
+	for (j=0; j<w; j++)
+	{
+	    *fb ++ = *save ++;
+	    *fb ++ = *save ++;
+	}
+	fb = fbb + 2*VIDEO_COLS;
+    }
+
+}
+
+int video_rows(void)
+{
+    return VIDEO_ROWS;
+}
+
+int video_cols(void)
+{
+    return VIDEO_COLS;
+}
+
+void video_size(int cols, int rows)
+{
+    video_numrows = rows;
+    video_numcols = cols;
+}
+
+void video_clear(void)
+{
+    unsigned short *fbb = (unsigned short *)0xFD0B8000;
+    int i,j;
+    unsigned short val = 0x2000 | current_attr;
+
+    for (i=0; i<video_rows(); i++)
+    {
+	for (j=0; j<video_cols(); j++)
+	{
+	    *fbb++ = val;
+	}
+    }
+    video_set_cursor(0,0);
+    cursor_row = 0;
+    cursor_col = 0;
+}
+
+#ifdef EASTEREGG
+int video_easteregg_active = 0;
+
+void video_easteregg(void)
+{
+    video_easteregg_active = 1;
+}
+#endif
+
+extern bd_t *bd_global;
+extern block_dev_desc_t * ide_get_dev(int dev);
+extern char version_string[];
+
+void video_banner(void)
+{
+    block_dev_desc_t *ide;
+    int i;
+    char *s;
+    int maxdev;
+    
+
+    if (video_inited == 0) return;
+#ifdef EASTEREGG
+    if (video_easteregg_active)
+    {
+	prompt_string="";
+	video_clear();
+	printf("\n");
+	printf("    **** COMMODORE 64 BASIC X2 ****\n\n");
+	printf(" 64K RAM SYSTEM  38911 BASIC BYTES FREE\n\n");
+	printf("READY\n");
+    }
+    else
+    {
+#endif
+	s = getenv("ide_maxbus");
+	if (s)
+	    maxdev = atoi(s) * 2;
+	else
+	    maxdev = 4;
+
+	s = getenv("stdout");
+	if (s && strcmp(s, "serial") == 0)
+	    return;
+
+	video_clear();
+	printf("%s\n\nCPU: ", version_string);
+	checkcpu();
+	printf("DRAM: %ld MB\n", bd_global->bi_memsize/(1024*1024));
+	printf("FSB: %ld MHz\n", bd_global->bi_busfreq/1000000);
+
+	printf("\n---- Disk summary ----\n");
+	for (i = 0; i < maxdev; i++)
+	{
+	    ide = ide_get_dev(i);
+	    printf("Device %d: ", i);
+	    dev_print(ide);
+	}
+
+/*
+    video_draw_box(SINGLE_BOX, 0x0F, "Test 1", 0, 0,18, 72, 4);
+    video_draw_box(DOUBLE_BOX, 0x0F, "Test 2", 1, 4,10, 50, 6);
+    video_draw_box(DOUBLE_BOX, 0x0F, "Test 3", 0, 40, 3, 20, 5);
+
+    video_draw_text(1, 4, 0x2F, "Highlighted options");
+    video_draw_text(1, 5, 0x0F, "Non-selected option");
+    video_draw_text(1, 6, 0x07, "disabled option");
+*/
+#ifdef EASTEREGG
+    }
+#endif
+}
diff --git a/board/MAI/bios_emulator/bios.c b/board/MAI/bios_emulator/bios.c
new file mode 100644
index 00000000000..4707bd9a8c4
--- /dev/null
+++ b/board/MAI/bios_emulator/bios.c
@@ -0,0 +1,335 @@
+/*
+ * 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
new file mode 100644
index 00000000000..b765ed54c98
--- /dev/null
+++ b/board/MAI/bios_emulator/glue.c
@@ -0,0 +1,528 @@
+#include <common.h>
+#include <pci.h>
+#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<image_size /*rom_size*/; j++)
+	{
+	    *to++ = *from++;
+	}
+    }
+
+    PRINTF("Copy is done\n");
+
+    /*  Unmap the ROM and restore the BAR */
+    pci_write_config_dword(dev, PCI_ROM_ADDRESS, 0);
+    pci_write_config_dword(dev, i, bar_backup);
+
+    /*  FIXME: */
+    bat_map(2, 0x80000000, 256*1024*1024);
+    show_bat_mapping();
+
+    /*
+     * Since most cards can probably only do 16 bit IO addressing, we
+     * correct their IO base into an appropriate value.
+     * This should do for most.
+     */
+    for (i = PCI_BASE_ADDRESS_0; i <= PCI_BASE_ADDRESS_5; i += 4)
+    {
+	unsigned long value;
+	pci_read_config_dword(dev, i, &value);
+	if (value & 0x01) /*  IO */
+	{
+	    did_correct = 1;
+	    pci_write_config_dword(dev, i, 0x1001);
+	    break;
+	}
+
+	if (value & PCI_BASE_ADDRESS_MEM_PREFETCH)
+	{
+	    prefetch_idx = i;
+	    prefetch_addr = value & PCI_BASE_ADDRESS_MEM_MASK;
+	    prefetch_size = get_bar_size(dev, i);
+	}
+    }
+
+    if (1) /* did_correct) */
+    {
+	extern pci_dev_t pci_find_bridge_for_bus(struct pci_controller *hose, int busnr);
+	int busnr = PCI_BUS(dev);
+	if (busnr)
+	{
+	    pci_dev_t bridge;
+	    PRINTF("Need to correct bridge device for IO range change\n");
+	    bridge = pci_find_bridge_for_bus(NULL, busnr);
+	    if (bridge == PCI_ANY_ID)
+	    {
+		PRINTF("Didn't find bridge. Hope that's OK\n");
+	    }
+	    else
+	    {
+		/*
+		 * Set upper I/O base/limit to 0
+		 */
+		pci_write_config_byte(bridge, 0x30, 0x00);
+		pci_write_config_byte(bridge, 0x31, 0x00);
+		pci_write_config_byte(bridge, 0x32, 0x00);
+		pci_write_config_byte(bridge, 0x33, 0x00);
+		if (did_correct)
+		{
+		    /*
+		     * set lower I/O base to 1000
+		     * That is, bits 0:3 are set to 0001 by default.
+		     * bits 7:4 contain I/O address bits 15:12
+		     * all others are assumed 0.
+		     */
+		    pci_write_config_byte(bridge, 0x1C, 0x11);
+		    /*
+		     * Set lower I/O limit to 1FFF
+		     * That is, bits 0:3 are reserved and always 0000
+		     * Bits 7:4 contain I/O address bits 15:12
+		     * All others are assumed F.
+		     */
+		    pci_write_config_byte(bridge, 0x1D, 0x10);
+		    pci_write_config_byte(bridge, 0x0D, 0x20);
+		    PRINTF("Corrected bridge resource range of bridge at %02x:%02x:%02x\n",
+			   PCI_BUS(bridge), PCI_DEV(bridge), PCI_FUNC(bridge));
+
+		}
+		else
+		{
+		    /*
+		     * This card doesn't have I/O, we disable I/O forwarding
+		     */
+		    pci_write_config_byte(bridge, 0x1C, 0x11);
+		    pci_write_config_byte(bridge, 0x1D, 0x00);
+		    pci_write_config_byte(bridge, PCI_INTERRUPT_LINE, 0);
+		    pci_write_config_byte(bridge, PCI_INTERRUPT_PIN, 0);
+		    pci_write_config_dword(bridge, PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_IO);
+		    PRINTF("Disabled bridge resource range of bridge at %02x:%02x:%02x\n",
+			   PCI_BUS(bridge), PCI_DEV(bridge), PCI_FUNC(bridge));
+
+		}
+	    }
+	    /*
+	     * Correct the prefetchable memory base, which is not set correctly by
+	     * the U-Boot autoconfig stuff
+	     */
+	    if (prefetch_idx)
+	    {
+/* 		PRINTF("Setting prefetchable range to %x, %x (%x and %x)\n", */
+/* 		       prefetch_addr, prefetch_addr+prefetch_size, */
+/* 		       prefetch_addr>>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)
+{
+#ifdef DEBUG
+    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);
+#endif
+}
+
+
+
+void remove_init_data(void)
+{
+    char *s;
+    u32 batl = ((CFG_SDRAM_BASE+0x100000) | BATL_PP_RW);
+    u32 batu =((CFG_SDRAM_BASE+0x100000) | BATU_BL_256M | BATU_VS | BATU_VP);
+#if 0	/* already done in board_init_r() */
+    void *data = (void *)(CFG_INIT_RAM_ADDR+CFG_INIT_DATA_OFFSET);
+    unsigned char data2[CFG_INIT_DATA_SIZE];
+
+    /*  Make a copy of the data */
+    memcpy(data2, data, CFG_INIT_DATA_SIZE);
+#endif /* 0 */
+
+    /*  Invalidate and disable data cache */
+    invalidate_l1_data_cache();
+    dcache_disable();
+
+#if 0
+    /*  Copy to the real RAM address */
+    memcpy(data, data2, CFG_INIT_DATA_SIZE);
+#endif
+
+    /*printf("Before ICache enable\n");
+      show_bat_mapping();*/
+
+    __asm volatile ("isync        \n"
+		    "mtdbatu 2,%2 \n"
+		    "mtdbatl 2,%2 \n"
+	            "mtdbatu 1,%0 \n"
+		    "mtdbatl 1,%1 \n"
+		    "sync         \n"
+		    "isync        \n"
+		    : : "r" (batu), "r" (batl), "r" (0));
+
+    /* show_bat_mapping(); */
+    s = getenv("x86_cache");
+
+    if (!s || (s && strcmp(s, "on")==0))
+    {
+	icache_enable();
+	dcache_enable();
+    }
+
+}
diff --git a/board/MAI/bios_emulator/glue.h b/board/MAI/bios_emulator/glue.h
new file mode 100644
index 00000000000..585efe12869
--- /dev/null
+++ b/board/MAI/bios_emulator/glue.h
@@ -0,0 +1,57 @@
+#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-linux/glibc/dmake b/board/MAI/bios_emulator/scitech/bin-linux/glibc/dmake
new file mode 100644
index 0000000000000000000000000000000000000000..4d6ccb3f46ee6c0e2ca1e75884595e043b3ec097
GIT binary patch
literal 70812
zcmd?SeRx#W)i-=5nMo!vVS)sV8Z>H9P*9?v1c(j^6CxiHnUJ7{uWIm+B1AX`K?n?;
zq~>slO<QcOwN;93ZELM<wW37~A5GAkTBO=i<yLB`-EpX;f<vk)^Zb76oJj)qe%|ML
zulN1yf$L=NwLjNhd+oK?Ui)J<hG&+0JRU9eFHK9=2<3m(>mLVq^k64$oK~Ruw2|5{
zZK#%kaK?>`A`QML;OFPV=f#(f?@fM)<2M9;evD&jPKod!j^BA%9*rOKYdKDQF5uj6
z`TYELrfHf!Op|&U4^XQZ=+P>^?ep_%0nCqhv5sq(E&al^%kCbtZ0T}y%{8l5TyveK
zl_7i%zW)Cv0w7+6Zs3h@$Kqq!+4u_Z@n12%;rPxYfPWM4O%k7`-2itozDyTp+o$52
z?!qCsx8WP*!gR*tE5ete1KV>oz7hCH*IV%MUy0*r16;Slb+2{ZAlzyAO7UHW?^b+%
zeEfG4zASt*@D0V6i|-127vUR&?-G3ccfRAu-*VS~q3h=LiyQ3vN4oA+{o>Fi+RZLZ
z`ltR4bUpd0fd4~xX1{co!jJ9)-)UMlzKikkU!~({SGw-G&S*Da);SSV`oWjOe?dPu
z;Q9x-ZrF9nSHhbvOy_#ne@(xzlsDC{gbVPIp5#+F+F<RUN!B~_(LR{`)n4cGlPAv8
z1_~|TM0(P4FhYpO*jBG!mw3PQ>G6lWe)1f7az4KNHm{$3PWWzowSbSh@KU%VAM^Q1
zGnQw<U61_iOQvtcHyQ92xa6ZIe6@gIL_-+Q@PqyE`3B&9-|f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*+%|iE%g+gX3-z+xjC6|JZmo9LMDS|Ep=45~KdH
z%Ux%|kuI+T?sdRjaY+o2dGODNhwnrw1Lq7gk`uH!b|k{=ayQ1oaYOggl!OUmwGB5M
z2UiNX(vN_<IS!6GLM7l%BFz3{etbTShcqUB)XB=>Cw3>^?eh4`_T?EH{u1sG;0^)q
z!8k@`9RI$AC$4%L;hImwS9<|>1{2_q@pH~PJsfoymTCVDrzdD%w?FV}m-T-D>-PGA

literal 0
HcmV?d00001

diff --git a/board/MAI/bios_emulator/scitech/bin-linux/glibc/k_cp b/board/MAI/bios_emulator/scitech/bin-linux/glibc/k_cp
new file mode 100644
index 0000000000000000000000000000000000000000..d3729496cea1d2f1343461ba075008530d59f976
GIT binary patch
literal 37612
zcmeHw3wTu3x%N&nfdLW{5ELugQNe=6+(;l0uz?URmCH!DwFSo^nPCPdnRI3kgjR6U
zA(df_(o@^RIh7-bw)C{e(sLB!1sg6UXg!vywN$L4rFEx?$WabPjO2gcZ|^;`Cu0Bh
zzdV2c=jqO~v%Yt&Z++`q-&*TiYwx{g?>npK&(6rmP|PD!$x?`-+imtzgnNT}N~z*d
z1}Ni{Ym}=HDhks|qu{~W4w`2+P8-fFoacBVjpt>cc`}W%lcga|!TJ0b6@@4BEBSi*
zDd1DD+Uz`EMuCqGQlwm_XM!!~R-A9z>^%1Z^Q2xZgQp#Z*qd#3o(^E1W?Esuzq&9`
zcT>RM5NRq12MbE{G>8`6<}6$aN-swU{Hrof;$i%UgXIm!Nqu-w{^dBQ5#XR5%;N?S
zBXQ>9oQiV{P99g`{G3pV@)?BJ<D{(y8*!tIaDovspq>t#rX5FvF2*?tCy#PHKx?HA
zw%2$APDw>8FsmFl8etj2fjBF0USq_~L^#x-Z!$tN$OCaDPPW~(X5=NpD=rbos4w6w
z!dZ#aJjQ}3z&Y8B=od}|z7FTjIA`=rBP=xHaxRfJ!ic-t2<-@`Tlj{6{;YvNZ;2;~
zZt@o&X4^1>11H<thcQLH*=Hzw@4YrV%V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QwZsaI0l%u7{*z<GD?9D1s?#C3SJR2W<);le
zSa2rZOg4*e+Cd`LK<iz>u!}o(x#+Iz*DZA$%v<D~Pc4vnX@egYm^aISSaZ*qExlZ=
yMQZ<<oD!{i>Edc4VGe*9jg3|4VC<QchF{m!nTrT)Smlq3#5v;{g^ne?ZT<)N&u!EI

literal 0
HcmV?d00001

diff --git a/board/MAI/bios_emulator/scitech/bin-linux/glibc/k_echo b/board/MAI/bios_emulator/scitech/bin-linux/glibc/k_echo
new file mode 100644
index 0000000000000000000000000000000000000000..6f65d4119a12bcc011f6216c0ee6880b21728553
GIT binary patch
literal 11924
zcmeHNeT-aJb-(Lf;{{Co0ZvT_)g-aYE?v*}&dz#q@%Kk@>?C#~LY%zLzIn6r;+c8V
zd2e=YsK|s3Esk+Ysu0@z1DLczRIO5)7DS}V;Ls`xmE2OL`G+c112~OaHByv<Kx}`%
zbKiY)XT45SRq9{8tGoAi?>YC}bI(2ZW8S?F>^r=FXlO{8uu2Up<}NLcj24mZy+u=s
zDy810#?<@O4M>$Dt=Iz(;ss#F)rcdA!-%glg2wo6U`Em?J82Cxg?K$GGP1r}uj!kS
z+5GvDQN}AM9zi9xOZqA#CqO>|8sk@yXC$3%Fph$M^udu)#uW05hL&mgvzbP9Tf=X4
zPo={ko!2yo7TpdUxf4jYBLM%{r*|My_ce&33sQ!+BT}bPM7BX*=?l`80%e$x0@#B1
zB<wwobR*)gA~I}1WPTFyA<)kwy&3UVL<U2@3wZ6PM@HH926dhCkUj?f)o6(I7Z4-l
zBc!Z<4w2zHMADVx%r%3S6GoLz<TwiEY0@kuB3Gk!$8SY7aMt{mA9+Mouj9@6VdQn3
zTBp+V9KTfy5)S1YItqzZzvXm8uZnUCi`!^c{1!^ytbRisIDBaL9w(p9B`8Z}Y3pH$
zL-?=#b%<^uF@<!4@4t(q@C9IoA^hEdlspXUg}zFCS!dNp;X`kOt@a{agF!sV6vjNv
z6oY*mQw;ENrr^8t%ny%UX5D)py!bN=!s0V2=Az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j}$%{xR^IccH(JyqP~K_`_F_e-iX@;aBP}
zkT?2nRPR#HAaBe64)SLHY{2|^5&0Xf_J4r9{Vw$i@}|A@Xz!=Un~);l!Hs7%T%=!h
zPcGN%ZYK((ZmkA}HeT&I&feok?{E$uI(8h-R`rEqgbzCfP^y75*9c~D;Uxz<r_w!z
z(tQV={derTb)U0)-+@C%P>IdyAMGlbz29@AbXn=wtny1<REp`fpu-=s0lsbG80k2B
zthVj;<UAR-Cp`O(>_tnlvL>U|(7BV2=hg#s%GrDOkzKbQ+M^s#POkXDdG!<9ojc9T
z*sOADZKuAV@H-AiUMR8BliUG*oMk)Y#KD%ISb*cVxV%NxCHQvgx9m#nZ_KQp0oz1*
v5Da~_Q4SnFx_j4Q=ji_Z$Mzj}j_=xicprN1webFT;AbFp?Mq$u{`kKDglLYA

literal 0
HcmV?d00001

diff --git a/board/MAI/bios_emulator/scitech/bin-linux/glibc/k_rm b/board/MAI/bios_emulator/scitech/bin-linux/glibc/k_rm
new file mode 100644
index 0000000000000000000000000000000000000000..7de503024bbda1121f4090bd5d1e9f14f78a2bee
GIT binary patch
literal 38300
zcmeIb4SZD9wKjedCNMx^0)k>i9Y3(37?O}c5NLrAJ}SsaAlNJ1AtW=Lz$7!BIm1T_
zIyj^<3{hHbulHVU`OsVMy|$OOiuhFnQa&uTRINp&6~9kRs#Gba8p;28);?$EOvHQJ
z_y4}Xx4-w-11Ebud#}Cs+H0@9_CDwAIp>z@IWux{ay0wM)%s{e@vSa*Il_?<l~S&G
zw7%L%?PBdhgqp^*@;G>Kwt?oEhtq|#56)9Ok;d~}&^(#OveUI8O~W~7uBP#1eyvEQ
zF9lxuJC~d13#jm+{+iUw^jxrQsloY%%gyrvV4jqVb?|hf688p|o2Lhur=2z?*tl#=
zu;H3uV{>dxaWqt1rqWQf$Tsu(g`iYDLf}u8brQ2JJXqfloRo(L%O8ew5&;hC!9K18
zaX!uhoY&$Ufzv*|Xc5B^UV(Ec&H+~37p!o!6*3r%^D>;&<E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^ejJ6x{q2F|+{6j`nJiW!P-g0u0qE4zF3*
zv>$}=`Fw%Th#CmPE%zz|J4Bk7Lob*UW8ycbd*{xEdoVDQLXMbhR?Cc8)yS%ObG`V5
z3>hGnjJ1r-BL)KxTcJgxX#O<sbg|}oYv#pF==0$Twbinwy2fU*!h$j*m}*0NVA|LW
zgWq&0Uhp)YW!TKc#x_{-^;mhZAoOh2`~`5@X$j|IdKZcCARJ?_mkLmER<AX{Ls_z+
zG`>fPEu2~}9{;mGOW7>lY*a(rv8mWuKK*bb-Vg)t*yM~4U>|0dTf^YMe3#9V?P*Kd
zxJVNwF{LgJ?Tp4y^&Ia4=@#K}mLxXZYw|-`$YQw+*f+Mgi{n7NIE^_lCVvB_6^#>C
zugu7)hoT1GR^_aRoKB3gdRbBxdO~@BRewYM>ITgF=#{9yzA4Mgf?*kU1xAD1V_}!H
zhE!%Hrk!O1$Jh;WNU+nDqE=!>g8?4Je$(cx>Bi@0Ut=fJoO#ox&hgEgF$1sg@hzA-
zZB8{-w{Q*4#=vhjs8{_sV<C<;3~Ogjm4yQ9<f0&rp)9o0nF)OjBX!2WV|~W5<pozP
z4W4wG(~lxb)-qHa7fH^7Sh?TGatSjc{;$RS&Gq&)mz8Myi$HeYm1+&K-n~KhlGT4Q
zgQm?SdvBL$AslQpl<Ge_Yyz?~&nY_nUfnYK6*&E@F$fJ#!<)>e^UXX+#2RRoFBJ80
zhc6f54ZW;W>0tIe?;J{j%nO?vp@G@cEr>Pv)EQ#zMm<t{&*Uu8DVHj)CKly5m>LdO
f!N6#lEDgWLYp@p)*x<?^A&I}nH4CjeyKnwKM6-2g

literal 0
HcmV?d00001

diff --git a/board/MAI/bios_emulator/scitech/bin-linux/glibc/makedep b/board/MAI/bios_emulator/scitech/bin-linux/glibc/makedep
new file mode 100644
index 0000000000000000000000000000000000000000..5451b2202499abaebd300b404406f7f4fb395c14
GIT binary patch
literal 58623
zcmeIb4SZD9wKsecCNN-dq6WpUI<}xdB_tt0AVC8me6%1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ZrGiJ`O
z!TALInX_q_44SMD&O1|4f$|9Tb7sgoigj{Pn#NEa8tW`XKLJ;>ik=*H?aZ<td0OsF
zgl)Gqo~|g_Z|S5%%{MNGqoN3yHfA~}4J66>kV@yO^ptWCBg>`D?g)G(5@>6*=l`rs
z+usGVyT3$hiexPYP$%7ER^L;t8B5FFHY%!XZ)rBH{yKdi24&N)Q*^qkhUIj3=y9kO
z-dxV=GNT*npBV}nv-oj&WMb90${z~*WyMGraf+dXA9OKqp>IB=LE*)1&CtZWSqkFh
zXU1$9H%23JPhIMeqf<VMU2P;x*EyrTy&6VJ>n1lm@C$Eht+KF(p3gbTOoUTRdb8|4
F`k%T@u1Ej?

literal 0
HcmV?d00001

diff --git a/board/MAI/bios_emulator/scitech/bin-linux/glibc/nasm b/board/MAI/bios_emulator/scitech/bin-linux/glibc/nasm
new file mode 100644
index 0000000000000000000000000000000000000000..fbd335261cbac7c89678d8c6326b5bd02c0ce976
GIT binary patch
literal 263498
zcmdSCe|%KcnLmE#N0I>sW`Lj(1B~)R5JaM&1QMP6n1Dj+Kuo|N5v)ST6cyoK)JnqO
zO=@ng)6MSI)^2M{mbPnKKP|gkHU5GG*bFM&4QMM0ZPQBIJ6_sGjbR9p`Mlrf-bp5)
z+kJgL-_IZ4z|6hp*K?lpoaa2}InQ~{nH`~(6%L0(O8+?}m&8!>lWxyKJOheLBrTKz
zQnoZ(nkMDrDM?IQ7)2g@I`Ga<7Cvr#SfY;~r13Km@BA>0u!m|xn#A&oQ{so^CBKy}
z;<9o)9r)xQlO&_TA?jti6WQifx}<r(&hhZG2Vs7Q7wh21gGxL*-5!1d2=kLpyL!`o
zU%YzLy;p6z?*ZkJ`CA{He~py}&;qw*U#P~LRgZYV*GznnO}Z4H9DFXrhkw(phjgX=
zT!7~Ud@jZ(4<FXazj^pvE#9mzFCO#p$;GDtA0Iwr@wo(_^xssxjKSv$J7PATbMPT8
zN#nWr%)saK{scWgFA?!W{g9EzlktB3>o`PA!sjA<CgU?2pUl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Z@x@B*t_TI#fK@$ElG!
z?O?-0<5Oj)#jI+g%A~7M@-ufrh{Fp%7YdIVtY1hC(kIyI+!qFl7#We4%EhWmQM*uQ
zmC1B`YU*rW2&6-OVRo#l4#MpSvktT0n0`_gezX>DVHo*in6ygDqjZ&|ETylS*ZR|^
zX_X&s^|y6}`QO({|C;u$)s5}_+}rbFuD`Ewb$biHIOK+=%2$E$X0SXK)i!;OM-?+T
zS9y!G+Mst-TW+B)H0@Dcx>IC)=9gmWgJY>>bwh>QnJk8|p42@`xW6gWP1Ip@U!w9*
z**NgDjJs$OicdMyz8BPrpP)TQMN(f`63gjKVI7t#n!R*$9gbg$aSOsj%F4)NNlb=`
WB~Vy|^!JajPKdptUrI2ic>foFDc4;9

literal 0
HcmV?d00001

diff --git a/board/MAI/bios_emulator/scitech/bin-linux/glibc/ndisasm b/board/MAI/bios_emulator/scitech/bin-linux/glibc/ndisasm
new file mode 100644
index 0000000000000000000000000000000000000000..dd14a7ae41def58b20bca94a5d01a22f5d6ab70c
GIT binary patch
literal 100192
zcmeFad3;pW{r`XOWC8;OCSb5ZK?el|S!5Fdw}3=(!A20ZDq@xi6Ub&VgJ=yT4iU#O
znpSPqN|kDDt+rZg5v^zfD!5dGOAU*HiaO(9MWv8xG{5KjoO>rXL$LMp`FwwWnMYpl
zv%JsyectDNmV55GcV?F7o_mIAnuh)7GSUo5oqVI)Gl?*8q2^68d`7x4!pJrT8a>Dt
z-lST}fP0Ax(t#VKfj0&41cwk82v4+WjYQxHwyiP@fyf(~n!la&_A%)m!O}H`k@JM1
z>J`3=V$aPrjpsf{_XrwE3&bv|<M`5&g5yhz#*~(nhn9}5t{6MPFou&q4h#Z4ffqRc
zGDwJCvF%WcaSUN!D}ET^P%AFM7~rwehg;!Mgrk9K2VoXC8XOCb1LA{WpbzK|#80Vz
zV^cC{u5kny1$sGnBOUP(j`;Cb+-HSH5{h4>{R6E$I}l$D0sX*_zyKhB**Z|Pw<De!
z9h{nBrIY<j+6TmU(oY1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&H%4-fH@h`a<FbZ^s+!tG%a&B}sbXmoT;6V0w?$QDpZvs(Gf$hv=aA~QmCdzP
zi=wL9_`BD&3)>`th=><2Yi)C3m)0(o469B%tBN<cR9_V}CrL=A$(!nyYTjzMRV|ix
z)k$@YNn;k*HZA52yu2@W4XLkQ+AQzNYe<Q=#r}Ku*t<NjR@F9MR^QUp=rV0<TGmX>
zlAye&Z&+E?TEDcpp_T$xH2xS6i_{l)Wb^WtdK#s9#yzyWo{tt%zpGplk?vhsQ&T0M
zGLkAJXTH16Ckpu((MlVa&_>?Pi;q)D%*8rP+CTM;RY`*`T_#^fU))+-dx`sCuxQ!h
zX1)<mKQ3(HqX;3Ao`E;kENrQ%;xkKaV=EuMXcHf7s^coE7T345Qk*2E=i)sB61P=)
z{eX`>*7zjx<y7O%hJ`IH5wnIVvbd?44=+_!e1BfEVVDWVSk*U1i`!}&8luJ34Na{K
zrw*<*oZi=NCy_XxWGWI=KDlbN#c{VcG&L@XNT2WY%j8UkqE$Q0J}tG>O1%r2gYxk#
z>E+~uaXb_aHT9RtC&)GiH2HiLx18Ros&1%V*vPOYAN6G1l4@J)nrL@&%<PUoP`eL+
zRUa=uYvzpds<Y<IId}HFs(CYJmd~!D6mw!xD|yBPe%Zo?WwrX*IGK|)Hoko1(`92*
z6|-WYd_<0ttfdRIb!{#3u`n4NI%r`$aD2k0v%UWD2Bn2h<9tFyPcF!|riP~FGR@;p
chAvWLeA&ct;|o9jQB}2MX;Wj;=PUyJAEWSTp#T5?

literal 0
HcmV?d00001

diff --git a/board/MAI/bios_emulator/scitech/bin-linux/glibc/trans b/board/MAI/bios_emulator/scitech/bin-linux/glibc/trans
new file mode 100644
index 0000000000000000000000000000000000000000..a1aea4f4ad2199bdc7a0067bc2845fc31f9447b7
GIT binary patch
literal 9244
zcmcgyeRNdSwLc*f7>2+^43Q$%i<%M?Murb12nq=Stb9ZQi1HDJ$%Gr2%%n5-VsIr8
zyqUr<j?GeOYpd@`)mL3lTdQcPfCiEhY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)jkQ<rvVk9-LrBex22s~}f|KFTqdGjjI~kYm0#L5}Bua@5brEeA~>c%FFP
z=HNbSBIr!x+-wg3GIBx41tHgzaUNr|N2nYi$9vo^IGvv{l9mAy+`NoEdB2N$Ib6y0
zwT#N<v>fBYS~V7Of8a#vmT@5po;24d|3?J(b{QKK&8Tbzosr|qU=QRN*G$XEHK8LT
zCs+q@uXrW7ode`pZ=8?|W{d&T9^nxHV@&^8SNXpxEub^=5!3#jG^QLsW#r+0Qp*%I
s_5s*_2FR?PJmu<1q+4d}S@75@**L!ITjW>|IcHx}gm|%!>7VO=0UA7%;s5{u

literal 0
HcmV?d00001

diff --git a/board/MAI/bios_emulator/scitech/bin-linux/libc/dmake b/board/MAI/bios_emulator/scitech/bin-linux/libc/dmake
new file mode 100644
index 0000000000000000000000000000000000000000..f198f294431a80eefc3705e4bdeb593064da5b19
GIT binary patch
literal 71264
zcmd?SeSB2awLg3&nMo!vVS)q<8Z=^1P*9?v1c(j^6Cy7X84{v|7c0R-L_l&5q8J!D
zNzLI9J8iY4t+t}}*7n+#T5Y3M3@=Tvm$sDJUVN!irFO@`mI{WbDf4{4>zqjf_TK0D
zJfG+J>j$5cz1MzSd+oK?UVH7A*%F>x?(ulE)W0+>T_e;J_xdNn%^T*#P0|W9pEgz-
zuH|YO2xr`+DAM429DaU2d|rI%_+I0OIDW(6=f^mf=9CBz;`rS**rV}del5p|uLWHD
zZJ(dtOKF<+z-UeCWjsJFp6$`%kNN!kS^)DSUaaHl)vLa6_39N9R<BxPZoH~t?NvpZ
zR)+8e_y+!)3?Luh5H}E2XjkAnAK!d@qww+H7<?gox%l|+8hkg1Pt#DecAe|L94>Ji
zf$t_aYzEw0@MXI&or(Ca#5aKe{*fM+;Tw+c0(`UZ@n6_+9J;_i&4n*@-Sgnyh;ItM
zAikUNmEhyQnfMCu4Z;_|HyGb|d?WEq$5)7N;J*t240QvtT=yc^CGGf+v@I5&rp<9(
zI@h}XQrFFNUG_)nANi#`1)Ssh0au<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SoZdFSS94<bAVAfxfsG`v
zf;-pw{pzK^$IzTzzApSLuVMyuV$Rxy_&zLRv>~DV+m4-1NYtTz)<fxI&TZJ!sHyC%
z^*YT-^Ez7YpZmKIVB~qq*_R=oU&b$Gsr|<|{#}ZPvYT*}<0gLB;Dd6Sf0XZh=HQ_$
zCmiK_IRJDdWE}J2FXcS@7t<1s<3R^HAjbjw&n~wB0rb_#D9ZZ@3>cMoXWHp_m>>IY
zDIOb+<3ll!;J86J#@lc!@y@(C{&0NKF+efi{v#a!uEk@+<pM4ja4#`4>yL1Jn()|g
z6Bz#{P`O#JT0j;Izj%DkhU0jcZJxf|bru}!I}32L0C(l3_^|$%2miY9@SP~F!PTv6
z;O8{gjzpMUkN!9~?v>twt0zuZ-@!Pz+W>dlC%|ougX8#o2jF-<)c&*SGJ*ionD|j2
z8l9G)?ZUf_7k`PzZPqX0vT%GW>#PLrz^CwG{n@yF9^Y}*(+D@8M6&+uxUb?H&Z*>&
Z@s$~;ha>N>O#5#LPDl6HANaNN`@g`nu(<#L

literal 0
HcmV?d00001

diff --git a/board/MAI/bios_emulator/scitech/bin-linux/libc/nasm b/board/MAI/bios_emulator/scitech/bin-linux/libc/nasm
new file mode 100644
index 0000000000000000000000000000000000000000..e312a0b2394252ac0e86a67af467f76a7d4522a7
GIT binary patch
literal 168228
zcmeFa4R}=5xi7vanMsB)FcSzNXn-I=K|Ul3N`PR#2B?4yge10#_yM?0Q4#hAt0WBW
zOv%pf==4-uy{Dd<Vq5yJ_mrOFNBqL@A%kAqMx>S&s!=)Zo^E;?HHHvV=Kg+b?@1<z
zZSTF$bDsb6+?zam*4Mk<^{#il>s@QTYwfjn1eY&%xm;56FHK697<$HVd*{GC8A%gK
zbEE>vBTbdYNI6mlVwg531Q<L|!q3Np$Bic)&oMqo<1-q5K1?I-fzpsB;fZy+BtFb9
z1?==A2p`#$;pH>qCzAAZrzFZ{Iw@MGr%CI^WqSEU5#~d>SjH6_@4W4bjq7G^yz_4L
zzFAxDnN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@vLSF-zU-l4wGo$JY^VesDzJ%z<Ia)*jX3kf50?$SjIwNSc+g-e&_
zFXQcHg`Rw7>%ZINSwOBcd2VQ79g^>~k~PEJq)s;ZoFZ$K#L0TqPPvv!S&w9spOHd7
z<H(vNak7rN+3^x2b&^X;S<mE}mbMZn>s}klWxX>ub9X#%$n%TD$-36ShbLLrq-`7|
zpR8|_V8+Qh*h!qMj}j;KX538nCAX}zvJR)v$htmCoNN!lj7uXfjX19iBD_hQ_&UtE
zde-}T4!(4`yc62YeDir}#>u*$v0naazwXV9%L~UzSDD0R61U-zTjLgo<K*}ni+E-_
z8>O}Fx;3uI66fRRhObmUZgp>Fzbh<p^~BYGOx!w4octU*NL*cay5O8h&JB<`mhs8Y
zYWL=7t(<+cKPhD#W#LldI*IEf&dcWub2G=foj1B?m003xEpM2+Rm5@XgPYV>ZoPe+
UTszXIxn(>Rt<{(>D9wET0h#s^00000

literal 0
HcmV?d00001

diff --git a/board/MAI/bios_emulator/scitech/bin-linux/libc/ndisasm b/board/MAI/bios_emulator/scitech/bin-linux/libc/ndisasm
new file mode 100644
index 0000000000000000000000000000000000000000..9fe81a3a3e9c01568eb6ca707c052e726e74dc7b
GIT binary patch
literal 66888
zcmeFad3aPs-UVE@(}4y89UvemYO^WGB0)gHX2Pz527`d(0$J%`Hj-`@hb7Q7(6rIa
zylyitqvJ9<uA`#3fC-=h$0gv#CZM8r49=in2m$TyoVs<B;@Zype$V&U_dIj;)UB#h
z=U2a4Zr!@KJI%^T(<U2+A*{n8;sjGKhn%iq%ygLCFyRsLqMzs@l0++HlN(l!GQh)#
z6Y+o(hyy+*z!9AhC&<y7X%P`{#7+4^5Y&rAlb3m?zyU|^5n|K5Le@*(fnuAYz@70f
zq7rF>ezA^A3-YrrEyx*EkYD6qGPtaGaIz46nGbXa=u105KVY`muO5nU;oMQhFT&ZQ
z;yeumTC21h=Zk?0fB`^1fX5}kg}`|L>u(SA2HFDM0JcLv2I&bE?+_!8S%U%gvvsiT
z`f)B2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yk$~<`p5yeX!Q-A)
z?PR@K+GT0C^>Kcq4n2j7{9fv^zQn(|+=&a!?>*IsLXVrFuG{%}5BT}k+I+rsyDu5-
zg0u^MK)bIR?c}`@rrj*(^dbF;w;+2g^ON^!g?1(CdORs*9&@UccCiva1DLJ+f2{PO
t=lX3<=(S5s+DWcHbnJajaH;x-#G4<`PVOBUQy()24p>Y2H<Y@+{{*y0Q$GLz

literal 0
HcmV?d00001

diff --git a/board/MAI/bios_emulator/scitech/bin-linux/libc/trans b/board/MAI/bios_emulator/scitech/bin-linux/libc/trans
new file mode 100644
index 0000000000000000000000000000000000000000..e536c0466d5983df247985d520f83960f9e231c7
GIT binary patch
literal 8984
zcmbta4R}=5nLZ&C7(!rz21KNKQ6fQQWcX2nM1hcimY+xxq$0#&GQ$l{X5!4f7%YM4
z%`6$l=+vJrcD0L-_^f>%wC=7ywEk=aO2FNAsmr$P!ft7oZf~AR*NE(xlIY#{J$EKd
zDYku{y?MU*zVCcL=R4o|&bdD)JF8Yy=jG*z>@`B<3v#WU4(D9p<JZ}exk3>IqD)K>
zC1NC+D4W|39l&1DgaUvAkPkRPfQ)b@XaZ&QJ=_~)0<iUKLJ(*#ifwr-_}14PPQoM@
zyf9J7ekmV8y=wul!yb?XNnl*;<JMr)rdxxJGlNYbz11BJyFEgbqP-08$F6K#6QG1{
z#8rSX8G~`a*JNlS`eT1n0aE}>(`djX!1VxLP8%U(LSQ&zI$%_$Z9K3XM}{Z5F^49}
zA!aY;kC)7mO$ww$OwQ1kLpNj^rvYC9xEkOB6asj0o_LM5k<49Dh9**S=v-3fgt^Bx
zUVLhCe0wlYS^g#v{eNNeS75}m!0+3W<qO4a;5o0HtMQ^pECQaCsW--XFTjNVI^gm6
z+W_3U%eH538v*Nb_=mtd!82d9j{uf_KkI+IcpUt~9R6wWuR{Mvz|{W^U?9ieUhq!D
z10?72Z-D3L$X^4$4sss~hW2j)CP7{X%=q2~By-~L0Y4x5PXJT@p8(6Dzc$1F6!>J0
z|DS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*Xeo
zUjoMAZ01^kn`bnDRe+6v5P<z>VHxNm0MG95DPEr0;K)gsIHTpc<Gv1u6CYQ_w8tGz
zeEJtb81gKz7{D`AUVOONgS~tNFyHa;DIRA$_F3wD_$6Ho%yXqO0M9j@fZ=OdW#s~;
zY}u;%8Om(;?e5v`IYRtFo9EALn=|a2W1Qu2&w}Out4+A0+nQ0Vz&N&%Sj|%M1gAx~
zRWA;d+>P5pP_?lZ5$=dT=*D4-O|%3x;g*M0Zb`~B8Mi#Qa!11QXvS^-`m}HaMvXSw
z9EKe{dz+hl!gl8iH#hr3Xh!+_htv3{2%cp#C!8mFP7j<tV+JW@#5Vvq_taw@n7|8R
z$a&_)`XI~zuokGt`j`fy9Y7iTA!eO0|FoqZ>uDbZtfTCeCCkyk^K|O5UW!q8tQXp{
zhUkxVvjmXUV|~qs9_x;JlxOw64w}AMzpU?m5R_*x>hZc4kkuQ2-T?I4vq3>dJ;K@?
zJ^rsmE1ccJ0cNhOzX!l){qd|~-=xd;yD6i`@p50-5514FPBJneu_Z%ud^{E5|4HO@
zD`TTxOO76&tvaE1x$!=dqnCtU@+<Uq<mhpI?}46*w(OP7i-88_nDNOy42SYbklCRS
zGma-Rn0ovykc3`Gb`wEcc1+&_os)h+y&AM-udIw`_&BbV7v*QZLXWj0W3yGoESy2^
K&Co<yfBy%l#Cq`n

literal 0
HcmV?d00001

diff --git a/board/MAI/bios_emulator/scitech/bin/bc31-d16.bat b/board/MAI/bios_emulator/scitech/bin/bc31-d16.bat
new file mode 100644
index 00000000000..776d13820f0
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc31-d16.bat
@@ -0,0 +1,28 @@
+@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
new file mode 100644
index 00000000000..d2939f458a6
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc45-c32.bat
@@ -0,0 +1,37 @@
+@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
new file mode 100644
index 00000000000..246517d1034
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc45-d16.bat
@@ -0,0 +1,32 @@
+@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
new file mode 100644
index 00000000000..cbb2c795101
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc45-d32.bat
@@ -0,0 +1,33 @@
+@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
new file mode 100644
index 00000000000..14d7c05b141
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc45-snp.bat
@@ -0,0 +1,32 @@
+@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
new file mode 100644
index 00000000000..50bd3cb5d83
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc45-tnt.bat
@@ -0,0 +1,46 @@
+@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
new file mode 100644
index 00000000000..4b59fa422e0
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc45-vxd.bat
@@ -0,0 +1,32 @@
+@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
new file mode 100644
index 00000000000..4d799b47b63
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc45-w16.bat
@@ -0,0 +1,32 @@
+@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
new file mode 100644
index 00000000000..a6c199fe9ae
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc45-w32.bat
@@ -0,0 +1,37 @@
+@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
new file mode 100644
index 00000000000..6a0fde2c9e5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc50-c32.bat
@@ -0,0 +1,40 @@
+@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
new file mode 100644
index 00000000000..23b50389de5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc50-d16.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..0521f93cec9
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc50-d32.bat
@@ -0,0 +1,35 @@
+@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
new file mode 100644
index 00000000000..e3241ffae39
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc50-smx.bat
@@ -0,0 +1,35 @@
+@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
new file mode 100644
index 00000000000..ab3acd23c4d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc50-snp.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..4dcc3723be8
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc50-tnt.bat
@@ -0,0 +1,48 @@
+@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
new file mode 100644
index 00000000000..2356911aba9
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc50-vxd.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..cd79d86b8f2
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc50-w16.bat
@@ -0,0 +1,34 @@
+ @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
new file mode 100644
index 00000000000..8b8cec94363
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc50-w32.bat
@@ -0,0 +1,40 @@
+@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
new file mode 100644
index 00000000000..ebfeb2eb640
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bc50-x11.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..6e094288167
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bcb5-c32.bat
@@ -0,0 +1,40 @@
+@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
new file mode 100644
index 00000000000..aa13e7dd20c
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bcb5-d16.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..d0017d4ccbb
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bcb5-d32.bat
@@ -0,0 +1,35 @@
+@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
new file mode 100644
index 00000000000..2b969a93bad
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bcb5-smx.bat
@@ -0,0 +1,35 @@
+@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
new file mode 100644
index 00000000000..d7b8ff20a86
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bcb5-snp.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..1de3601a595
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bcb5-tnt.bat
@@ -0,0 +1,48 @@
+@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
new file mode 100644
index 00000000000..28de58c3f07
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bcb5-vxd.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..c30d0040810
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bcb5-w16.bat
@@ -0,0 +1,34 @@
+ @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
new file mode 100644
index 00000000000..18760e1128d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bcb5-w32.bat
@@ -0,0 +1,40 @@
+@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
new file mode 100644
index 00000000000..198c1a24256
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/bcb5-x11.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..ff1973dc815
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/build
@@ -0,0 +1,22 @@
+#! /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
new file mode 100644
index 00000000000..ee29093631e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/build.bat
@@ -0,0 +1,4 @@
+@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
new file mode 100644
index 00000000000..2b325293abf
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/build_db.bat
@@ -0,0 +1,4 @@
+@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
new file mode 100644
index 00000000000..5a619b4459e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/build_it.bat
@@ -0,0 +1,432 @@
+@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
new file mode 100644
index 00000000000..b64f4d7463f
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/cddrv.bat
@@ -0,0 +1,6 @@
+@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
new file mode 100644
index 00000000000..b22023d54cc
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/cdit
@@ -0,0 +1,10 @@
+#! /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
new file mode 100644
index 00000000000..950b6480711
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/cdit.bat
@@ -0,0 +1,5 @@
+@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
new file mode 100644
index 00000000000..5a2c3d816aa
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/djgpp.env
@@ -0,0 +1,46 @@
+#= 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
new file mode 100644
index 00000000000..9b792c93e42
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/djgpp_db.env
@@ -0,0 +1,46 @@
+#= 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
new file mode 100644
index 00000000000..2e1506c2ce6
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/findint3.bat
@@ -0,0 +1 @@
+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
new file mode 100644
index 00000000000..61ffd935070
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/gcc-beos.sh
@@ -0,0 +1,16 @@
+#! /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
new file mode 100644
index 00000000000..3816a5dca76
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/gcc-freebsd.sh
@@ -0,0 +1,16 @@
+#! /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
new file mode 100644
index 00000000000..27a4c490652
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/gcc-linux.sh
@@ -0,0 +1,19 @@
+#! /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
new file mode 100644
index 00000000000..13c47836999
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/gcc2-c32.bat
@@ -0,0 +1,26 @@
+@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
new file mode 100644
index 00000000000..97cb8bda133
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/gcc2-dos.bat
@@ -0,0 +1,28 @@
+@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
new file mode 100644
index 00000000000..ceb2ab84e91
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/gcc2-linux.bat
@@ -0,0 +1,26 @@
+@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
new file mode 100644
index 00000000000..bdb31aaf5d9
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/gcc2-w32.bat
@@ -0,0 +1,26 @@
+@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
new file mode 100644
index 00000000000..631673483c1
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/makelib.bat
@@ -0,0 +1,97 @@
+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
new file mode 100644
index 00000000000..fd1804b70f5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/meltobjs.sh
@@ -0,0 +1,23 @@
+#! /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
new file mode 100644
index 00000000000..07c0d78505f
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/ntddk.bat
@@ -0,0 +1,42 @@
+@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
new file mode 100644
index 00000000000..843c4d9fb31
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/qnx4.sh
@@ -0,0 +1,18 @@
+#! /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
new file mode 100644
index 00000000000..c114f9e3372
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/qnxnto.sh
@@ -0,0 +1,21 @@
+#! /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
new file mode 100644
index 00000000000..0a272d6a462
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/set-vars-beos.sh
@@ -0,0 +1,42 @@
+#! /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
new file mode 100644
index 00000000000..c920748a7fe
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/set-vars-freebsd.sh
@@ -0,0 +1,37 @@
+#! /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
new file mode 100644
index 00000000000..35cbf1dc160
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/set-vars-linux.sh
@@ -0,0 +1,43 @@
+#! /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
new file mode 100644
index 00000000000..1d73109ea4f
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/set-vars-qnx.sh
@@ -0,0 +1,37 @@
+#! /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
new file mode 100644
index 00000000000..2a2101d4b41
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/set-vars.bat
@@ -0,0 +1,110 @@
+@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
new file mode 100644
index 00000000000..71f7d8e10dc
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc40-c32.bat
@@ -0,0 +1,36 @@
+@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
new file mode 100644
index 00000000000..9817493e370
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc40-d16.bat
@@ -0,0 +1,27 @@
+@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
new file mode 100644
index 00000000000..62e35214e93
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc40-drv9x.bat
@@ -0,0 +1,21 @@
+@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
new file mode 100644
index 00000000000..83b67802dfa
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc40-drvnt.bat
@@ -0,0 +1,18 @@
+@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
new file mode 100644
index 00000000000..7997044f82d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc40-snp.bat
@@ -0,0 +1,31 @@
+@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
new file mode 100644
index 00000000000..b0fc93675b4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc40-tnt.bat
@@ -0,0 +1,42 @@
+@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
new file mode 100644
index 00000000000..2849a20e756
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc40-w16.bat
@@ -0,0 +1,26 @@
+@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
new file mode 100644
index 00000000000..d93a6246e35
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc40-w32.bat
@@ -0,0 +1,37 @@
+@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
new file mode 100644
index 00000000000..a420a54eabc
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc40-x11.bat
@@ -0,0 +1,20 @@
+@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
new file mode 100644
index 00000000000..62d27b9bc7f
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc50-c32.bat
@@ -0,0 +1,39 @@
+@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
new file mode 100644
index 00000000000..c789c5037d1
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc50-d16.bat
@@ -0,0 +1,26 @@
+@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
new file mode 100644
index 00000000000..27a4a1439f5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc50-drv9x.bat
@@ -0,0 +1,21 @@
+@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
new file mode 100644
index 00000000000..17b2f25cc7d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc50-drvnt.bat
@@ -0,0 +1,17 @@
+@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
new file mode 100644
index 00000000000..afb2fb186a0
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc50-rtt.bat
@@ -0,0 +1,30 @@
+@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
new file mode 100644
index 00000000000..22d2e13c260
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc50-snp.bat
@@ -0,0 +1,33 @@
+@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
new file mode 100644
index 00000000000..6b09199054c
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc50-tnt.bat
@@ -0,0 +1,42 @@
+@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
new file mode 100644
index 00000000000..52ab495a3b1
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc50-w16.bat
@@ -0,0 +1,27 @@
+@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
new file mode 100644
index 00000000000..07bc5e51df9
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc50-w32.bat
@@ -0,0 +1,39 @@
+@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
new file mode 100644
index 00000000000..fe286bd95d8
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc50-x11.bat
@@ -0,0 +1,20 @@
+@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
new file mode 100644
index 00000000000..e98417d6135
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc60-c32.bat
@@ -0,0 +1,39 @@
+@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
new file mode 100644
index 00000000000..10855e06cb9
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc60-d16.bat
@@ -0,0 +1,26 @@
+@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
new file mode 100644
index 00000000000..27a4a1439f5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc60-drv9x.bat
@@ -0,0 +1,21 @@
+@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
new file mode 100644
index 00000000000..17b2f25cc7d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc60-drvnt.bat
@@ -0,0 +1,17 @@
+@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
new file mode 100644
index 00000000000..f3042932707
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc60-drvw2k.bat
@@ -0,0 +1,17 @@
+@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
new file mode 100644
index 00000000000..5348ef95216
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc60-snp.bat
@@ -0,0 +1,33 @@
+@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
new file mode 100644
index 00000000000..1d8b5e30384
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc60-tnt.bat
@@ -0,0 +1,42 @@
+@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
new file mode 100644
index 00000000000..70175c37abd
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc60-w16.bat
@@ -0,0 +1,27 @@
+@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
new file mode 100644
index 00000000000..2f8e7ab9b8a
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc60-w32.bat
@@ -0,0 +1,39 @@
+@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
new file mode 100644
index 00000000000..57b23d2048b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/vc60-x11.bat
@@ -0,0 +1,20 @@
+@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
new file mode 100644
index 00000000000..92858d162eb
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/w2kddk.bat
@@ -0,0 +1,42 @@
+@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
new file mode 100644
index 00000000000..2d738f376f1
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10-c32.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..5c53a90a174
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10-d16.bat
@@ -0,0 +1,30 @@
+@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
new file mode 100644
index 00000000000..a5c72105265
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10-d32.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..579dece3b0a
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10-o16.bat
@@ -0,0 +1,31 @@
+@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
new file mode 100644
index 00000000000..3404b42a01b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10-o32.bat
@@ -0,0 +1,31 @@
+@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
new file mode 100644
index 00000000000..57057de361d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10-p32.bat
@@ -0,0 +1,31 @@
+@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
new file mode 100644
index 00000000000..46f8659ce67
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10-qnx.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..1fde624f1f6
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10-snp.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..d12f042fa15
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10-tnt.bat
@@ -0,0 +1,46 @@
+@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
new file mode 100644
index 00000000000..e8ba871bb93
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10-w16.bat
@@ -0,0 +1,32 @@
+@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
new file mode 100644
index 00000000000..839bdde9c00
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10-w32.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..fc783d81437
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10-x11.bat
@@ -0,0 +1,24 @@
+@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
new file mode 100644
index 00000000000..6e0c24d5e7b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10ac32.bat
@@ -0,0 +1,33 @@
+@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
new file mode 100644
index 00000000000..f9ecb672734
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10ad16.bat
@@ -0,0 +1,29 @@
+@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
new file mode 100644
index 00000000000..d52b79a82c0
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10ad32.bat
@@ -0,0 +1,32 @@
+@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
new file mode 100644
index 00000000000..ba7351d0d86
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10ao16.bat
@@ -0,0 +1,30 @@
+@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
new file mode 100644
index 00000000000..f3caa595917
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10ao32.bat
@@ -0,0 +1,30 @@
+@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
new file mode 100644
index 00000000000..8d21c62eac0
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10ap32.bat
@@ -0,0 +1,30 @@
+@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
new file mode 100644
index 00000000000..28f857c80dc
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10asnp.bat
@@ -0,0 +1,33 @@
+@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
new file mode 100644
index 00000000000..a2b32193e49
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10atnt.bat
@@ -0,0 +1,45 @@
+@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
new file mode 100644
index 00000000000..94011cc337c
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10aw16.bat
@@ -0,0 +1,31 @@
+@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
new file mode 100644
index 00000000000..1e14dbc9f24
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc10aw32.bat
@@ -0,0 +1,33 @@
+@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
new file mode 100644
index 00000000000..e75312927c8
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc11-c32.bat
@@ -0,0 +1,40 @@
+@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
new file mode 100644
index 00000000000..4338adaef9e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc11-d16.bat
@@ -0,0 +1,30 @@
+@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
new file mode 100644
index 00000000000..e5a54d4bb4b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc11-d32.bat
@@ -0,0 +1,33 @@
+@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
new file mode 100644
index 00000000000..d46754a3c0c
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc11-o16.bat
@@ -0,0 +1,31 @@
+@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
new file mode 100644
index 00000000000..37f5dc7617f
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc11-o32.bat
@@ -0,0 +1,31 @@
+@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
new file mode 100644
index 00000000000..348cbbda81d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc11-p32.bat
@@ -0,0 +1,31 @@
+@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
new file mode 100644
index 00000000000..1fd60feea81
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc11-qnx.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..6d2ac5783dd
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc11-snp.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..44dbf24847e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc11-tnt.bat
@@ -0,0 +1,46 @@
+@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
new file mode 100644
index 00000000000..e65c70e1782
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc11-w16.bat
@@ -0,0 +1,31 @@
+@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
new file mode 100644
index 00000000000..764cdbd111d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc11-w32.bat
@@ -0,0 +1,40 @@
+@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
new file mode 100644
index 00000000000..c2569a3eb9c
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/wc11-x11.bat
@@ -0,0 +1,34 @@
+@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
new file mode 100644
index 00000000000..3c7f017cb53
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/bin/win32sdk.bat
@@ -0,0 +1,20 @@
+@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
new file mode 100644
index 00000000000..e38ff3157f0
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/include/biosemu.h
@@ -0,0 +1,155 @@
+/****************************************************************************
+*
+*                        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
new file mode 100644
index 00000000000..0de45172d6e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/include/event.h
@@ -0,0 +1,696 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..b29812c928c
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/include/mtrr.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..e2d58b0848e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/include/pcilib.h
@@ -0,0 +1,414 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..60a7c254570
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/include/pm_help.h
@@ -0,0 +1,167 @@
+/****************************************************************************
+*
+*                   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 <vtoolsc.h>
+#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
new file mode 100644
index 00000000000..088c19e5317
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/include/pm_wctl.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..3affe67d63e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/include/pmapi.h
@@ -0,0 +1,1149 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#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 <drvlib/os/os.h> */
+
+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
new file mode 100644
index 00000000000..d6c5cdb740f
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/include/pmimp.h
@@ -0,0 +1,194 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..7d76dad50c7
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/include/pmint.h
@@ -0,0 +1,211 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..1dbfface0dc
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/include/scitech.h
@@ -0,0 +1,712 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>          /* 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 <vtoolsc.h>
+#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 <mvdm.h>
+
+/* 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 <SupportDefs.h>
+#else
+#ifdef __LINUX__
+#include <sys/types.h>
+#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
new file mode 100644
index 00000000000..27a2fc06e89
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/include/scitech.mac
@@ -0,0 +1,1321 @@
+;****************************************************************************
+;*
+;*  ========================================================================
+;*
+;*    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  <LocalSize>,<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  <LocalSize>,<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&reg&, val32
+else
+        add     reg, val16
+endif
+ENDM
+
+MACRO   _sub    reg, val16, val32
+ifdef flatmodel
+        sub     e&reg&, 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&,reg
+endif
+ENDM
+
+MACRO   sgnhi   reg
+ifdef   flatmodel
+        movsx   e&reg&,reg
+endif
+ENDM
+
+; Macro to load an extended register with an integer value in either mode
+
+MACRO   loadint reg,val
+ifdef flatmodel
+        mov     e&reg&,val
+else
+        xor     e&reg&,e&reg&
+        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
new file mode 100644
index 00000000000..1d87d4e57fc
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/include/x86emu.h
@@ -0,0 +1,194 @@
+/****************************************************************************
+*
+*                       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
new file mode 100644
index 00000000000..777b03cd718
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/include/x86emu/fpu_regs.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+*
+*                       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
new file mode 100644
index 00000000000..c6ce88462aa
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/include/x86emu/regs.h
@@ -0,0 +1,331 @@
+/****************************************************************************
+*
+*                       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
new file mode 100644
index 00000000000..0a17c547ee1
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/include/x86emu/types.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+*
+*                       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 <sys/types.h>
+
+/*---------------------- 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/readme.txt b/board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/glibc/readme.txt
new file mode 100644
index 00000000000..0d87effa998
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/glibc/readme.txt
@@ -0,0 +1 @@
+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
new file mode 100644
index 00000000000..0d87effa998
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/lib/debug/linux/gcc/libc/readme.txt
@@ -0,0 +1 @@
+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
new file mode 100644
index 00000000000..0d87effa998
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/lib/release/linux/gcc/glibc/readme.txt
@@ -0,0 +1 @@
+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
new file mode 100644
index 00000000000..0d87effa998
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/lib/release/linux/gcc/libc/readme.txt
@@ -0,0 +1 @@
+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
new file mode 100644
index 00000000000..aa4fe76a40e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/bc16.mk
@@ -0,0 +1,137 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..133d80edf73
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/bc3.mk
@@ -0,0 +1,102 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..246de1dfc5e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/bc32.mk
@@ -0,0 +1,201 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..23aeb7cde40
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/bcos2.mk
@@ -0,0 +1,137 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..0f29a1521ec
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/cl16.mk
@@ -0,0 +1,132 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..52157f91f4e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/cl386.mk
@@ -0,0 +1,120 @@
+#############################################################################
+#
+#                                       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
new file mode 100644
index 00000000000..da2364f6445
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/common.mk
@@ -0,0 +1,181 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..f569790a3c3
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/emx.mk
@@ -0,0 +1,194 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..0d62fdf1a89
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/gcc_beos.mk
@@ -0,0 +1,161 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..65589c83a3a
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/gcc_dos.mk
@@ -0,0 +1,112 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..0cb4b8530b5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/gcc_freebsd.mk
@@ -0,0 +1,174 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..361ed4a2a73
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/gcc_linux.mk
@@ -0,0 +1,181 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..1709d884c36
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/gcc_win32.mk
@@ -0,0 +1,136 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..f0b065a47c4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/hc32.mk
@@ -0,0 +1,113 @@
+#############################################################################
+#
+#					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/makedefs.prj b/board/MAI/bios_emulator/scitech/makedefs/makedefs.prj
new file mode 100644
index 0000000000000000000000000000000000000000..edd8809e29703910feeca27a5c3d465461aff1de
GIT binary patch
literal 9025
zcmeI2`Bx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{>&gCl7Lo)Mv1
z@jN&7K`-p5uOiXHwL~S>Y6+jn($^n=gV0CcV4_9PitwC|uR8a`01QI1kcx0Gw+1U#
z$hhLFVu!#7L-Z9ZTKKp`CDv*QpUBeJ55ou?rf+7^B58$R8}U`=BXAUs@uGyWbG6a_
z87X2%ZAQ&bC33Fumhp6EJpZa-A0DT{ZNT-o4tL;oya#)*8@<?to!EhUaS!gsUAPlH
z*p6-3iY@3y7dmkpI?#^IXv4sqG~rg<f>zv&jo5$|tVbE^(2Sd~7B^xIuElDs!b+^b
zax6m=8nF~hu$cZ^d^Hx~DlEhTT#5O(0u7jl%W)YkCs>M0XpO-lT!^`tg9|Vl=i@xg
z3Myt|2CbJ!r_~d)aTd<RG@OCcF_l(bOv7YMq7@kl%E}Bst=G6ot2b`Y@{jAZ7~~qQ
P4!J5$=pF3&XR^NlFRrwm

literal 0
HcmV?d00001

diff --git a/board/MAI/bios_emulator/scitech/makedefs/qnx4.mk b/board/MAI/bios_emulator/scitech/makedefs/qnx4.mk
new file mode 100644
index 00000000000..56dfa4de561
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/qnx4.mk
@@ -0,0 +1,165 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..5168ed269bc
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/qnxnto.mk
@@ -0,0 +1,157 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..67ae9101b13
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/bc16.mk
@@ -0,0 +1,69 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..d4d071c0d80
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/bc3.mk
@@ -0,0 +1,43 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..e3ce25bded3
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/bc32.mk
@@ -0,0 +1,151 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..f473fecf499
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/bcos2.mk
@@ -0,0 +1,70 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..6489a3ee430
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/cl16.mk
@@ -0,0 +1,67 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..f50b2749e41
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/cl386.mk
@@ -0,0 +1,69 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..9f917bbdd98
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/dj32.mk
@@ -0,0 +1,47 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..26d223ad41a
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/emx.mk
@@ -0,0 +1,91 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..4b59328267e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_beos.mk
@@ -0,0 +1,48 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..9b4d2362169
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_freebsd.mk
@@ -0,0 +1,47 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..56719ed7654
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_linux.mk
@@ -0,0 +1,94 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..36b24b1a7c4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/gcc_win32.mk
@@ -0,0 +1,91 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..011e9ab3a4c
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/hc32.mk
@@ -0,0 +1,51 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..55dc0355009
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/qnx4.mk
@@ -0,0 +1,94 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..c43ad1f642c
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/qnxnto.mk
@@ -0,0 +1,55 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..b33bcd86a0a
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/sc16.mk
@@ -0,0 +1,63 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..2231906d66a
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/sc32.mk
@@ -0,0 +1,69 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..588028f7347
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/va32.mk
@@ -0,0 +1,82 @@
+#############################################################################
+#
+#                                       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
new file mode 100644
index 00000000000..0c149b758f7
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/va365.mk
@@ -0,0 +1,79 @@
+#############################################################################
+#
+#                                       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
new file mode 100644
index 00000000000..6ffc270c01f
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/vc16.mk
@@ -0,0 +1,70 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..97f1a0c1627
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/vc32.mk
@@ -0,0 +1,122 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..d1ca9176efd
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/wc16.mk
@@ -0,0 +1,79 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..68bfd83bea2
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/rules/wc32.mk
@@ -0,0 +1,265 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..099ad45527b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/sc16.mk
@@ -0,0 +1,128 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..9ca757088ae
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/sc32.mk
@@ -0,0 +1,178 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..1d67a975e85
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/startup.mk
@@ -0,0 +1,162 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..fbca523922a
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/va32.mk
@@ -0,0 +1,163 @@
+#############################################################################
+#
+#                                       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
new file mode 100644
index 00000000000..3a2eccbbce9
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/va365.mk
@@ -0,0 +1,151 @@
+#############################################################################
+#
+#  					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
new file mode 100644
index 00000000000..913bf9c3e4d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/vc16.mk
@@ -0,0 +1,128 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..11c9071fb82
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/vc32.mk
@@ -0,0 +1,226 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..e316f4c7609
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/wc16.mk
@@ -0,0 +1,141 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..ff035117be1
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/makedefs/wc32.mk
@@ -0,0 +1,354 @@
+#############################################################################
+#
+#					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
new file mode 100644
index 00000000000..7f7ea999393
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/biosemu/besys.c
@@ -0,0 +1,408 @@
+/****************************************************************************
+*
+*                        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
new file mode 100644
index 00000000000..3fb4c3608a4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/biosemu/bios.c
@@ -0,0 +1,250 @@
+/****************************************************************************
+*
+*                        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
new file mode 100644
index 00000000000..ed2717c218e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/biosemu/biosemu.c
@@ -0,0 +1,445 @@
+/****************************************************************************
+*
+*                        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 <string.h>
+#include <stdlib.h>
+
+/*------------------------- 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
new file mode 100644
index 00000000000..23edebc95ce
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/biosemu/biosemui.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+*
+*                        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 <biosemu.h>
+
+/*---------------------- 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
new file mode 100644
index 00000000000..80730b2997f
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/biosemu/makefile
@@ -0,0 +1,99 @@
+#############################################################################
+#
+#                        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
new file mode 100644
index 00000000000..91410030762
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/biosemu/makefile.cross
@@ -0,0 +1,10 @@
+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
new file mode 100644
index 00000000000..96fa5a0e0f2
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/biosemu/warmboot.c
@@ -0,0 +1,569 @@
+/****************************************************************************
+*
+*                        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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#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,&regs,&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
new file mode 100644
index 00000000000..61a9024ab3d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/_aa_imp.asm
@@ -0,0 +1,51 @@
+;****************************************************************************
+;*
+;*                     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
new file mode 100644
index 00000000000..5317600438e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/_ga_imp.asm
@@ -0,0 +1,136 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..0194a62f98d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/_gatimer.asm
@@ -0,0 +1,248 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..d4b11790afe
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/_pm_imp.asm
@@ -0,0 +1,195 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..ba8645945be
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/aabeos.c
@@ -0,0 +1,92 @@
+/****************************************************************************
+*
+*                   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 <sys/time.h>
+
+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
new file mode 100644
index 00000000000..e994f938eb2
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/aados.c
@@ -0,0 +1,64 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*-------------------------- 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
new file mode 100644
index 00000000000..84bf7b3d8f7
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/aalib.c
@@ -0,0 +1,225 @@
+/****************************************************************************
+*
+*                     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 <stdio.h>
+#include <stdlib.h>
+#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
new file mode 100644
index 00000000000..4385b23e4f6
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/aalinux.c
@@ -0,0 +1,94 @@
+/****************************************************************************
+*
+*                   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 <sys/time.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;
+}
+
+/****************************************************************************
+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
new file mode 100644
index 00000000000..486b96a9c09
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/aaos2.c
@@ -0,0 +1,124 @@
+/****************************************************************************
+*
+*                   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 <os2.h>
+
+/*---------------------------- 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
new file mode 100644
index 00000000000..2e26c9afa6f
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/aaqnx.c
@@ -0,0 +1,95 @@
+/****************************************************************************
+*
+*                   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 <time.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;
+}
+
+/****************************************************************************
+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
new file mode 100644
index 00000000000..17a06b531c7
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/aartt.c
@@ -0,0 +1,89 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..56cbd5b888e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/aasmx.c
@@ -0,0 +1,83 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..295533db39c
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/aavxd.c
@@ -0,0 +1,90 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..f63f004f99d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/aawin32.c
@@ -0,0 +1,264 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define STRICT
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+/*------------------------- 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
new file mode 100644
index 00000000000..df8f932fb16
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/agplib.c
@@ -0,0 +1,220 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..7eb368fd3aa
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/center.c
@@ -0,0 +1,123 @@
+/****************************************************************************
+*
+*                  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
new file mode 100644
index 00000000000..872fae9194f
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/cmdline.c
@@ -0,0 +1,428 @@
+/****************************************************************************
+*
+*  ========================================================================
+*
+*    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 <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#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<arg>  %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
new file mode 100644
index 00000000000..1d8a5432169
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/gabeos.c
@@ -0,0 +1,146 @@
+/****************************************************************************
+*
+*                   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 <sys/time.h>
+
+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
new file mode 100644
index 00000000000..4c90e805d73
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/gados.c
@@ -0,0 +1,136 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.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:
+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
new file mode 100644
index 00000000000..7c1fbe312d4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/galib.c
@@ -0,0 +1,269 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#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
new file mode 100644
index 00000000000..cbd9d7f4e56
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/galinux.c
@@ -0,0 +1,148 @@
+/****************************************************************************
+*
+*                   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 <sys/time.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)
+{
+    // 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
new file mode 100644
index 00000000000..d9944c56ae5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/gantdrv.c
@@ -0,0 +1,137 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..822e93ca612
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/gaos2.c
@@ -0,0 +1,248 @@
+/****************************************************************************
+*
+*                   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 <os2.h>
+
+/*--------------------------- 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
new file mode 100644
index 00000000000..0846cccef08
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/gaqnx.c
@@ -0,0 +1,149 @@
+/****************************************************************************
+*
+*                   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 <time.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)
+{
+    // 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
new file mode 100644
index 00000000000..003e1e7dbe7
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/gartt.c
@@ -0,0 +1,139 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..62e68dc13e1
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/gasmx.c
@@ -0,0 +1,133 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..62173cc8d07
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/gavxd.c
@@ -0,0 +1,137 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..a2a4150953b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/gawin32.c
@@ -0,0 +1,256 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define STRICT
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+/*------------------------- 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
new file mode 100644
index 00000000000..5a03ac58855
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/gtfcalc.c
@@ -0,0 +1,436 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+#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 <xPixels> <yPixels> <freq> [[Hz] [KHz] [MHz]] [I]\n");
+        printf("\n");
+        printf("where <xPixels> is the horizontal resolution of the mode, <yPixels> is the\n");
+        printf("vertical resolution of the mode. The <freq> 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
new file mode 100644
index 00000000000..0eacd120bf2
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/libcimp.c
@@ -0,0 +1,828 @@
+/****************************************************************************
+*
+*                       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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <malloc.h>
+#include <time.h>
+#include <signal.h>
+#include <fcntl.h>
+#if defined(__GNUC__) || defined(__UNIX__)
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#else
+#include <io.h>
+#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 <windows.h>
+#endif
+#ifdef  __MSDOS__
+#include <dos.h>
+#endif
+#ifdef  __OS2__
+#define INCL_DOS
+#define INCL_DOSERRORS
+#define INCL_SUB
+#include <os2.h>
+#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
+
+/* <stdlib.h> 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);
+
+/* <libc/file.h> 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);
+
+/* <stdio.h> stub functions */
+int     _CDECL stub_remove(const char *_filename);
+int     _CDECL stub_rename(const char *_old, const char *_new);
+
+/* <time.h> stub functions */
+time_t  _CDECL stub_time(time_t *_tod);
+
+/* <signal.h> stub functions */
+int     _CDECL stub_raise(int);
+void *  _CDECL stub_signal(int, void *);
+
+/* <drvlib/attrib.h> functions */
+#define stub_OS_setfileattr    _OS_setfileattr
+#define stub_OS_getcurrentdate _OS_getcurrentdate
+
+LIBC_imports    _VARAPI ___imports = {
+    sizeof(LIBC_imports),
+
+    /* <stdlib.h> exports */
+    stub_abort,
+    stub_atexit,
+    stub_calloc,
+    stub_exit,
+    stub_free,
+    stub_getenv,
+    stub_malloc,
+    stub_realloc,
+    stub_system,
+    stub_putenv,
+
+    /* <libc/file.h> exports */
+    stub_open,
+    stub_access,
+    stub_close,
+    stub_lseek,
+    stub_read,
+    stub_unlink,
+    stub_write,
+    stub_isatty,
+
+    /* <stdio.h> exports */
+    stub_remove,
+    stub_rename,
+
+    /* <signal.h> functions */
+    stub_raise,
+    stub_signal,
+
+    /* <time.h> exports */
+    stub_time,
+
+    /* <drvlib/attrib.h> exports */
+    stub_OS_setfileattr,
+    stub_OS_getcurrentdate,
+    };
+
+/*---------------------- Stub function implementation ---------------------*/
+
+/* <stdlib.h> 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
+
+/* <libc/file.h> 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; }
+
+/* <stdio.h> 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
+
+/* <libc/file.h> 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;
+}
+
+/* <stdio.h> 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);
+}
+
+/* <libc/file.h> 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);
+}
+
+/* <stdio.h> 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
+
+/* <libc/file.h> 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); }
+
+/* <stdio.h> 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
new file mode 100644
index 00000000000..5aac0381b33
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/makefile
@@ -0,0 +1,18 @@
+#############################################################################
+#
+#                   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
new file mode 100644
index 00000000000..b9bec4aebbc
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/peloader.c
@@ -0,0 +1,587 @@
+/****************************************************************************
+*
+*                       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 <windows.h>
+#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(&secthdr, 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(&secthdr, 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
new file mode 100644
index 00000000000..2be57e2bd34
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/common/vesavbe.c
@@ -0,0 +1,1214 @@
+/****************************************************************************
+*
+*           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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#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(&regs, 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(&regs, 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,&regs,&regs);
+        }
+    else {
+        if (state->VBEVersion < 0x300 && (mode & vbeRefreshCtrl))
+            return false;
+        regs.x.ax = 0x4F02;
+        regs.x.bx = (ushort)mode;
+        if ((mode & vbeRefreshCtrl) && crtc)
+            VBE_callESDI(&regs, crtc, sizeof(*crtc));
+        else
+            PM_int86(0x10,&regs,&regs);
+        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,&regs,&regs);
+    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,&regs,&regs);
+    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,&regs,&regs);
+    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,&regs,&regs);
+    *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,&regs,&regs);
+    *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,&regs,&regs);
+    *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,&regs,&regs);
+    *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,&regs,&regs);
+    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,&regs,&regs);
+    *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,&regs,&regs);
+        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,&regs,&regs);
+        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,&regs,&regs);
+        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,&regs,&regs);
+        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,&regs,&regs);
+        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,&regs,&regs);
+        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,&regs,&regs);
+    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,&regs,&regs);
+    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(&regs, 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,&regs,&regs,&sregs);
+        if (regs.x.ax != VBE_SUCCESS)
+            return;
+        if (VBE_shared)
+            state->pmInfo = PM_mallocShared(regs.x.cx);
+        else
+            state->pmInfo = PM_malloc(regs.x.cx);
+        if (state->pmInfo == NULL)
+            return;
+        state->pmInfo32 = state->pmInfo;
+        pmLen = regs.x.cx;
+
+        /* Relocate the block into our local data segment */
+        code = PM_mapRealPointer(sregs.es,regs.x.di);
+        memcpy(state->pmInfo,code,pmLen);
+
+        /* Now do a sanity check on the information we recieve to ensure
+         * that is is correct. Some BIOS return totally bogus information
+         * in here (Matrox is one)! Under DOS this works OK, but under OS/2
+         * we are screwed.
+         */
+        if (state->pmInfo->setWindow >= pmLen ||
+            state->pmInfo->setDisplayStart >= pmLen ||
+            state->pmInfo->setPalette >= pmLen ||
+            state->pmInfo->IOPrivInfo >= pmLen) {
+            if (VBE_shared)
+                PM_freeShared(state->pmInfo);
+            else
+                PM_free(state->pmInfo);
+            state->pmInfo32 = state->pmInfo = NULL;
+            return;
+            }
+
+        /* Read the IO priveledge info and determine if we need to
+         * pass a selector to MMIO registers to the bank switch code.
+         * Since we no longer support selector allocation, we no longer
+         * support this mechanism so we disable the protected mode
+         * interface in this case.
+         */
+        if (state->pmInfo->IOPrivInfo && !state->MMIOSel) {
+            ushort *p = (ushort*)((uchar*)state->pmInfo + state->pmInfo->IOPrivInfo);
+            while (*p != 0xFFFF)
+                p++;
+            p++;
+            if (*p != 0xFFFF)
+                VBE_freePMCode();
+            }
+        }
+}
+
+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
new file mode 100644
index 00000000000..c8f825e25ba
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/beos/cpuinfo.c
@@ -0,0 +1,80 @@
+/****************************************************************************
+*
+*                         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 <OS.h>
+
+/*----------------------------- 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
new file mode 100644
index 00000000000..4c32ce7434d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/beos/event.c
@@ -0,0 +1,199 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..ab423d4be6d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/beos/oshdr.h
@@ -0,0 +1,32 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..c57d82ab688
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/beos/pm.c
@@ -0,0 +1,539 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+// 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
new file mode 100644
index 00000000000..579ef2c95c4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/beos/vflat.c
@@ -0,0 +1,49 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..a5637a5ecf6
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/beos/ztimer.c
@@ -0,0 +1,111 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..9aa871423e9
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/codepage/us_eng.c
@@ -0,0 +1,285 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..b100b8ad42e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/common.c
@@ -0,0 +1,480 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#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
new file mode 100644
index 00000000000..60ebed713ff
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/common/_cpuinfo.asm
@@ -0,0 +1,600 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..2b6e1e8b561
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/common/_dma.asm
@@ -0,0 +1,246 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..fdec1b58d8a
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/common/_int64.asm
@@ -0,0 +1,309 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..0ff1ecf55d3
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/common/_joy.asm
@@ -0,0 +1,230 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..1e0a6966ce9
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/common/_mtrr.asm
@@ -0,0 +1,272 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..5b8dbcc73a4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/common/_pcihelp.asm
@@ -0,0 +1,358 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..23f7e1e1458
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/common/agp.c
@@ -0,0 +1,190 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..79b4040ac1a
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/common/keyboard.c
@@ -0,0 +1,450 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..83ef22113c1
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/common/malloc.c
@@ -0,0 +1,205 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..d6ced6eadce
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/common/mtrr.c
@@ -0,0 +1,867 @@
+/****************************************************************************
+*
+*                   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,&ltype);
+        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,&ltype);
+        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,&ltype);
+        if (lsize < 1)
+            return 7;
+        }
+    else {
+        /* Check ARR0-6 registers */
+        for (i = 0; i < 7; i++) {
+            getMTRR(i,&lbase,&lsize,&ltype);
+            if (lsize < 1)
+                return i;
+            }
+        /* Try ARR7 but its size must be at least 256K */
+        getMTRR(7,&lbase,&lsize,&ltype);
+        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,&ltype);
+                        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,&ltype);
+        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,&ltype);
+        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
new file mode 100644
index 00000000000..8dd6dd13e3a
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/common/pcilib.c
@@ -0,0 +1,747 @@
+/****************************************************************************
+*
+*                   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 <string.h>
+#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
new file mode 100644
index 00000000000..04aa47002bc
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/common/unixio.c
@@ -0,0 +1,306 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dirent.h>
+
+/*----------------------------- 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
new file mode 100644
index 00000000000..3be14e81ebc
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/common/vgastate.c
@@ -0,0 +1,377 @@
+/****************************************************************************
+*
+*                   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 <string.h>
+#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(&regs[PAL]);
+
+    /* Save the VGA character generator RAM */
+    vga_saveFont(&regs[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(&regs[FONT]);
+
+    /* Restore the VGA palette values */
+    vga_restorepalette(&regs[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
new file mode 100644
index 00000000000..e2446a43973
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/cpuinfo.c
@@ -0,0 +1,808 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <string.h>
+#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
new file mode 100644
index 00000000000..d86e3e6a0d6
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/debug.c
@@ -0,0 +1,107 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#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
new file mode 100644
index 00000000000..36dcaab67b4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/dos/_event.asm
@@ -0,0 +1,194 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..a4a9c7916ed
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/dos/_lztimer.asm
@@ -0,0 +1,438 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..42b5cf3692e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/dos/_pm.asm
@@ -0,0 +1,656 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..5c741f346c2
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/dos/_pmdos.asm
@@ -0,0 +1,1105 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..34985a9d8bf
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/dos/_vflat.asm
@@ -0,0 +1,652 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..ee117c78e95
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/dos/cpuinfo.c
@@ -0,0 +1,72 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..12ecb298bc3
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/dos/event.c
@@ -0,0 +1,494 @@
+/****************************************************************************
+*
+*                   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,&regs,&regs);
+}
+#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,&regs,&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,&regs,&regs,&sregs);
+
+    /* Check that interrupt vector 0x33 is not a zero, and that the first
+     * instruction in the interrupt vector is not an IRET instruction
+     */
+    p = PM_mapRealPointer(sregs.es, regs.x.bx);
+    retval = ((sregs.es != 0) || (regs.x.bx != 0)) && (PM_getByte(p) != 207);
+    return retval;
+}
+
+/****************************************************************************
+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,&regs,&regs);
+        regs.x.ax = 8;  /* Mouse function 8 - Set vertical min and max   */
+        regs.x.cx = 0;
+        regs.x.dx = yRes;
+        PM_int86(0x33,&regs,&regs);
+        _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,&regs,&regs);
+        _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
new file mode 100644
index 00000000000..35e8e00f724
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/dos/oshdr.h
@@ -0,0 +1,29 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..71acd6894e1
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/dos/pm.c
@@ -0,0 +1,2243 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dos.h>
+#include <conio.h>
+#ifdef  __GNUC__
+#include <unistd.h>
+#include <sys/nearptr.h>
+#include <sys/stat.h>
+#else
+#include <direct.h>
+#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,&regs,&regs,&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,&regs,&regs,&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,&regs,&regs,&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,&regs,&regs);
+        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,&regs,&regs);
+            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(&regs,0,sizeof(regs));
+        regs.eax = API_NUM(PMHELP_ENABLELFBCOMB);
+        regs.ebx = base;
+        regs.ecx = size;
+        regs.edx = type;
+        _PM_VxDCall(&regs,_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, &regs, &regs, &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, &regs, &regs, &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,&regs,&regs);
+    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,&regs,&regs);
+        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,&regs,&regs);
+        }
+    (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,&regs,&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,&regs,&regs);
+    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(&regs,0,sizeof(regs));
+        regs.eax = API_NUM(PMHELP_ALLOCLOCKED);
+        regs.ebx = size;
+        regs.ecx = (ulong)physAddr;
+        regs.edx = contiguous | (below16Meg << 8);
+        _PM_VxDCall(&regs,_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(&regs,0,sizeof(regs));
+        regs.eax = API_NUM(PMHELP_FREELOCKED);
+        regs.ebx = (ulong)p;
+        regs.ecx = size;
+        regs.edx = contiguous;
+        _PM_VxDCall(&regs,_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(&regs,0,sizeof(regs));
+        regs.eax = API_NUM(PMHELP_ALLOCPAGE);
+        regs.ebx = locked;
+        _PM_VxDCall(&regs,_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(&regs,0,sizeof(regs));
+        regs.eax = API_NUM(PMHELP_FREEPAGE);
+        regs.ebx = (ulong)p;
+        _PM_VxDCall(&regs,_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,&regs,&regs);
+    *physical = *total = regs.x.bx * 16UL;
+}
+
+#endif
+
+/*-------------------------------------------------------------------------*/
+/* Phar Lap TNT DOS Extender support.                                      */
+/*-------------------------------------------------------------------------*/
+
+#ifdef TNT
+
+#include <pldos32.h>
+#include <pharlap.h>
+#include <hw386.h>
+
+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(&regs,0,sizeof(regs));
+        regs.eax = API_NUM(PMHELP_MAPPHYS);
+        regs.ebx = base;
+        regs.ecx = limit;
+        regs.edx = isCached;
+        _PM_VxDCall(&regs,_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 <x32.h>
+
+#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,&regs,&regs,&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,&regs,&regs,&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(&regs,0,sizeof(regs));
+        regs.eax = API_NUM(PMHELP_MAPPHYS);
+        regs.ebx = base;
+        regs.ecx = limit;
+        regs.edx = isCached;
+        _PM_VxDCall(&regs,_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,&regs,&regs);
+    *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(&regs,0,sizeof(regs));
+        regs.eax = API_NUM(PMHELP_MAPPHYS);
+        regs.ebx = base;
+        regs.ecx = limit;
+        regs.edx = isCached;
+        _PM_VxDCall(&regs,_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(&regs,0,sizeof(regs));
+        regs.eax = API_NUM(PMHELP_GETPHYSICALADDRRANGE);
+        regs.ebx = (ulong)p;
+        regs.ecx = (ulong)length;
+        regs.edx = (ulong)physAddress;
+        _PM_VxDCall(&regs,_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(&regs, 0, sizeof(regs));
+    regs.eax = 0x4F05;
+    regs.ebx = 0x0000;
+    regs.edx = bank;
+    DPMI_int86(0x10,&regs);
+}
+
+/****************************************************************************
+REMARKS:
+Call the VBE/Core software interrupt to change display banks.
+****************************************************************************/
+void PMAPI PM_setBankAB(
+    int bank)
+{
+    DPMI_regs   regs;
+    memset(&regs, 0, sizeof(regs));
+    regs.eax = 0x4F05;
+    regs.ebx = 0x0000;
+    regs.edx = bank;
+    DPMI_int86(0x10,&regs);
+    regs.eax = 0x4F05;
+    regs.ebx = 0x0001;
+    regs.edx = bank;
+    DPMI_int86(0x10,&regs);
+}
+
+/****************************************************************************
+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(&regs, 0, sizeof(regs));
+    regs.eax = 0x4F07;
+    regs.ebx = waitVRT;
+    regs.ecx = x;
+    regs.edx = y;
+    DPMI_int86(0x10,&regs);
+}
+
+#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
new file mode 100644
index 00000000000..74f8427a1c5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/dos/pmdos.c
@@ -0,0 +1,1637 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dos.h>
+
+/*--------------------------- 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, &regs, &regs);
+    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, &regs, &regs);
+        _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 <pldos32.h>
+#include <pharlap.h>
+#include <hw386.h>
+
+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, &regs, &regs, &sregs);
+    return 1;
+}
+
+void PMAPI PM_restoreMouseHandler(void)
+{
+    RMREGS  regs;
+
+    if (_PM_mouseHandler) {
+        regs.x.ax = 33;
+        PM_int86(0x33, &regs, &regs);
+        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 <x32.h>
+#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,&regs,&regs,&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, &regs, &regs, &sregs);
+    return 1;
+}
+
+void PMAPI PM_restoreMouseHandler(void)
+{
+    RMREGS  regs;
+
+    if (_PM_mouseHandler) {
+        regs.x.ax = 33;
+        PM_int86(0x33, &regs, &regs);
+        _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, &regs, &regs, &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, &regs, &regs, &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, &regs, &regs, &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, &regs, &regs, &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,&regs,&regs);
+    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,&regs,&regs);
+}
+
+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,&regs,&regs);
+}
+#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,&regs,&regs,&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,&regs,&regs,&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,&regs,&regs,&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, &regs, &regs);
+        _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,&regs,&regs);
+    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,&regs,&regs);
+}
+
+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,&regs,&regs);
+}
+
+#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, &regs, &regs, &sregs);
+    return 1;
+}
+
+void PMAPI PM_restoreMouseHandler(void)
+{
+    RMREGS  regs;
+
+    if (_PM_mouseHandler) {
+        regs.x.ax = 33;
+        PM_int86(0x33, &regs, &regs);
+        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
new file mode 100644
index 00000000000..2e78e25a8b5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/dos/vflat.c
@@ -0,0 +1,251 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <dos.h>
+
+/*-------------------------------------------------------------------------*/
+/* 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,&regs,&regs);
+    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
new file mode 100644
index 00000000000..960ed06cd74
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/dos/ztimer.c
@@ -0,0 +1,111 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..b284c68cfb0
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/event.c
@@ -0,0 +1,1115 @@
+/****************************************************************************
+*
+*                   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 <time.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#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
new file mode 100644
index 00000000000..e88d2109541
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/linux/cpuinfo.c
@@ -0,0 +1,68 @@
+/****************************************************************************
+*
+*                         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 <ztimer.h>
+
+/*----------------------------- 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
new file mode 100644
index 00000000000..c2668ceb883
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/linux/event.c
@@ -0,0 +1,1361 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..c0358a0f8ac
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/linux/event.svga
@@ -0,0 +1,1058 @@
+/****************************************************************************
+*
+*           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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <ctype.h>
+#include <termios.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <linux/keyboard.h>
+#include <linux/kd.h>
+#include <linux/vt.h>
+#include <gpm.h>
+#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,&regs,&regs);
+        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
new file mode 100644
index 00000000000..6023dff1098
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/linux/oshdr.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+*
+*                   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 <fcntl.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <linux/keyboard.h>
+#include <linux/kd.h>
+#include <linux/vt.h>
+#include <linux/fs.h>
+#ifdef USE_OS_JOYSTICK
+#include <linux/joystick.h>
+#endif
+#include <termios.h>
+#include <signal.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+/* 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
new file mode 100644
index 00000000000..1d52984a6a6
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/linux/pm.c
@@ -0,0 +1,1810 @@
+;/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/kd.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/vt.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <termios.h>
+#include <fcntl.h>
+#include <syscall.h>
+#include <signal.h>
+#include <time.h>
+#include <ctype.h>
+#include <errno.h>
+#include <asm/io.h>
+#include <asm/types.h>
+#ifdef ENABLE_MTRR
+#include <asm/mtrr.h>
+#endif
+#include <asm/vm86.h>
+#ifdef __GLIBC__
+#include <sys/perm.h>
+#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,&regs[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,&regs[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,&regs,&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
new file mode 100644
index 00000000000..579ef2c95c4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/linux/vflat.c
@@ -0,0 +1,49 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..1b9bae28a65
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/linux/ztimer.c
@@ -0,0 +1,95 @@
+/****************************************************************************
+*
+*                         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 <unistd.h>
+#include <sys/time.h>
+#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
new file mode 100644
index 00000000000..265f0e36d05
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/makefile
@@ -0,0 +1,290 @@
+#############################################################################
+#
+#                   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
new file mode 100644
index 00000000000..11824a0afc5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/_irq.asm
@@ -0,0 +1,288 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..6cb276d25e8
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/_pm.asm
@@ -0,0 +1,281 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..e72a856019e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/cpuinfo.c
@@ -0,0 +1,65 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..f93d9c22e78
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/int86.c
@@ -0,0 +1,252 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..bc6b4274df3
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/irq.c
@@ -0,0 +1,143 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..b30d2be8609
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/mem.c
@@ -0,0 +1,519 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..3f747bb9cec
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/oshdr.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..d4bbe228b72
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/pm.c
@@ -0,0 +1,934 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..856215206ff
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdio.c
@@ -0,0 +1,331 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..d7705130b73
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdlib.c
@@ -0,0 +1,140 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..901ce1cf037
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/vflat.c
@@ -0,0 +1,45 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..ef272941073
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/ztimer.c
@@ -0,0 +1,124 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..761f0f42e1e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/os2/_pmos2.asm
@@ -0,0 +1,180 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..7de400d0674
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/os2/cpuinfo.c
@@ -0,0 +1,66 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..706e84d6f34
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/os2/event.c
@@ -0,0 +1,566 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..52f12f0d2dc
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/os2/mon.h
@@ -0,0 +1,165 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..ae1f97a06c0
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/os2/oshdr.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+*
+*                   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 <os2.h>
+#include <process.h>
+#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
new file mode 100644
index 00000000000..50251028062
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/os2/pm.c
@@ -0,0 +1,2008 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+#ifndef __EMX__
+#include <direct.h>
+#endif
+#define INCL_DOSERRORS
+#define INCL_DOS
+#define INCL_SUB
+#define INCL_VIO
+#define INCL_KBD
+#include <os2.h>
+
+/* 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
new file mode 100644
index 00000000000..579ef2c95c4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/os2/vflat.c
@@ -0,0 +1,49 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..30ffe4340b0
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/os2/ztimer.c
@@ -0,0 +1,110 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..97c2caa82f9
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/os2pm/event.c
@@ -0,0 +1,170 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..0b69f8222cc
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/os2pm/oshdr.h
@@ -0,0 +1,36 @@
+/****************************************************************************
+*
+*                   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 <os2.h>
diff --git a/board/MAI/bios_emulator/scitech/src/pm/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/oshdr.h
new file mode 100644
index 00000000000..404e5c93c5e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/oshdr.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..738dfea3795
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/photon/event.c
@@ -0,0 +1,268 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..3c72563de23
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/photon/oshdr.h
@@ -0,0 +1,38 @@
+/****************************************************************************
+*
+*                   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 <sys/mouse.h>
+#include <sys/keyboard.h>
+#include <sys/fd.h>
+#include <sys/stat.h>
+#include <conio.h>
+#include <process.h>
+#include <sys/kernel.h>
+#include <Ph.h>
diff --git a/board/MAI/bios_emulator/scitech/src/pm/pm.vpw b/board/MAI/bios_emulator/scitech/src/pm/pm.vpw
new file mode 100644
index 00000000000..26e68a7a3af
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/pm.vpw
@@ -0,0 +1,43 @@
+[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
new file mode 100644
index 00000000000..48b872d9817
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/pmcommon.vpj
@@ -0,0 +1,45 @@
+[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
new file mode 100644
index 00000000000..1157513b30e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/pmdos.vpj
@@ -0,0 +1,41 @@
+[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
new file mode 100644
index 00000000000..0bfbf8446a5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/pmlinux.vpj
@@ -0,0 +1,35 @@
+[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
new file mode 100644
index 00000000000..3ec35a76e48
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/pmntdrv.vpj
@@ -0,0 +1,39 @@
+[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
new file mode 100644
index 00000000000..d54170252c4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/pmqnx.vpj
@@ -0,0 +1,35 @@
+[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
new file mode 100644
index 00000000000..1fcf911769b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/pmvxd.vpj
@@ -0,0 +1,34 @@
+[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
new file mode 100644
index 00000000000..ace682208c6
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/pmwin32.vpj
@@ -0,0 +1,35 @@
+[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
new file mode 100644
index 00000000000..5a3fe105ec2
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/qnx/_mtrrqnx.asm
@@ -0,0 +1,226 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..a8782542b20
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/qnx/cpuinfo.c
@@ -0,0 +1,64 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..e16f8a53928
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/qnx/event.c
@@ -0,0 +1,602 @@
+/****************************************************************************
+*
+*                   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 <errno.h>
+#include <unistd.h>
+
+/*--------------------------- 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
new file mode 100644
index 00000000000..de749e38349
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/qnx/mtrrqnx.c
@@ -0,0 +1,182 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <sys/mman.h>
+#include <time.h>
+#ifdef __QNXNTO__
+#include <sys/neutrino.h>
+#include <sys/syspage.h>
+#else
+#include <i86.h>
+#include <sys/irqinfo.h>
+#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
new file mode 100644
index 00000000000..09611930495
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/qnx/oshdr.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+*
+*                   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 <sys/stat.h>
+#include <fcntl.h>
+#include <process.h>
+#include <time.h>
+#ifndef __QNXNTO__
+#include <sys/mouse.h>
+#include <sys/keyboard.h>
+#include <sys/fd.h>
+#include <conio.h>
+#else
+#include <sys/dcmd_input.h>
+
+/* 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
new file mode 100644
index 00000000000..c2b41eb09ff
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/qnx/pm.c
@@ -0,0 +1,891 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <termios.h>
+#include <fcntl.h>
+#include <malloc.h>
+#include <sys/mman.h>
+#include "qnx/vbios.h"
+#ifndef __QNXNTO__
+#include <sys/seginfo.h>
+#include <sys/console.h>
+#include <conio.h>
+#include <i86.h>
+#else
+#include <sys/neutrino.h>
+#include <sys/dcmd_chr.h>
+#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
new file mode 100644
index 00000000000..579ef2c95c4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/qnx/vflat.c
@@ -0,0 +1,49 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..d2740971f98
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/qnx/ztimer.c
@@ -0,0 +1,91 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..3d6dd44313b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/rttarget/cpuinfo.c
@@ -0,0 +1,94 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..e9aba21b9f8
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/rttarget/event.c
@@ -0,0 +1,287 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..1352dadad60
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/rttarget/oshdr.h
@@ -0,0 +1,34 @@
+/****************************************************************************
+*
+*                   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 <windows.h>
+#include <mmsystem.h>
diff --git a/board/MAI/bios_emulator/scitech/src/pm/rttarget/pm.c b/board/MAI/bios_emulator/scitech/src/pm/rttarget/pm.c
new file mode 100644
index 00000000000..e6c1fbd8b31
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/rttarget/pm.c
@@ -0,0 +1,701 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define WIN32_LEAN_AND_MEAN
+#define STRICT
+#include <windows.h>
+#include <mmsystem.h>
+#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
new file mode 100644
index 00000000000..dd9dfe68268
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/rttarget/vflat.c
@@ -0,0 +1,48 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..52472c385a7
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/rttarget/ztimer.c
@@ -0,0 +1,136 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..da62b1f712b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/smx/_event.asm
@@ -0,0 +1,175 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..068eea65d2c
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/smx/_lztimer.asm
@@ -0,0 +1,58 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..1c7cb21864b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/smx/_pm.asm
@@ -0,0 +1,448 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..8352ce30c15
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/smx/_pmsmx.asm
@@ -0,0 +1,933 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..34985a9d8bf
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/smx/_vflat.asm
@@ -0,0 +1,652 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..5447e574ec6
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/smx/cpuinfo.c
@@ -0,0 +1,72 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..fc13bbbe420
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/smx/event.c
@@ -0,0 +1,368 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..3ff8daa2a9d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/smx/oshdr.h
@@ -0,0 +1,29 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..d6c95d688c5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/smx/pm.c
@@ -0,0 +1,1187 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dos.h>
+#include <conio.h>
+#ifdef  __GNUC__
+#include <unistd.h>
+#include <sys/nearptr.h>
+#include <sys/stat.h>
+#else
+#include <direct.h>
+#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, &regs, &regs, &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, &regs, &regs, &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,&regs,&regs);
+    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,&regs,&regs);
+        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,&regs,&regs);
+        }
+    (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,&regs,&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,&regs,&regs);
+    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
new file mode 100644
index 00000000000..2596c76a363
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/smx/pmsmx.c
@@ -0,0 +1,471 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dos.h>
+#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,&regs,&regs);
+    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,&regs,&regs);
+}
+
+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,&regs,&regs);
+}
+
+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
new file mode 100644
index 00000000000..579ef2c95c4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/smx/vflat.c
@@ -0,0 +1,49 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..01e180bdca4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/smx/ztimer.c
@@ -0,0 +1,115 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..2833a72f448
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/stub/cpuinfo.c
@@ -0,0 +1,79 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..8e805d060f6
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/stub/event.c
@@ -0,0 +1,199 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..81a20aaf15d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/stub/oshdr.h
@@ -0,0 +1,33 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..51656b05e35
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/stub/pm.c
@@ -0,0 +1,980 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+// 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,&regs,&regs);
+}
+
+/****************************************************************************
+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,&regs,&regs);
+    regs.x.ax = 0x4F05;
+    regs.x.bx = 0x0001;
+    regs.x.dx = bank;
+    PM_int86(0x10,&regs,&regs);
+}
+
+/****************************************************************************
+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,&regs,&regs);
+}
+
+/****************************************************************************
+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
new file mode 100644
index 00000000000..579ef2c95c4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/stub/vflat.c
@@ -0,0 +1,49 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..9bad6c09751
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/stub/ztimer.c
@@ -0,0 +1,111 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..5d899b7a67d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/altbrk.c
@@ -0,0 +1,90 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#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
new file mode 100644
index 00000000000..c5390f68a93
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/altcrit.c
@@ -0,0 +1,85 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#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
new file mode 100644
index 00000000000..43668487af3
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/biosptr.c
@@ -0,0 +1,92 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#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
new file mode 100644
index 00000000000..e9488729567
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/block.c
@@ -0,0 +1,69 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#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
new file mode 100644
index 00000000000..3561fee921f
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/brk.c
@@ -0,0 +1,78 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#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
new file mode 100644
index 00000000000..3897ce99993
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/callreal.c
@@ -0,0 +1,107 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#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,&regs,&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
new file mode 100644
index 00000000000..81737e17d7b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/checks.c
@@ -0,0 +1,100 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef  __WINDOWS__
+#define WIN32_LEAN_AND_MEAN
+#define STRICT
+#include <windows.h>
+#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
new file mode 100644
index 00000000000..34abb2418d5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/cpu.c
@@ -0,0 +1,46 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+
+/*----------------------------- 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
new file mode 100644
index 00000000000..21ec9946f7b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/critical.c
@@ -0,0 +1,70 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#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
new file mode 100644
index 00000000000..c70f7ee3c3b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/getch.c
@@ -0,0 +1,501 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#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
new file mode 100644
index 00000000000..9c02452bb3d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/isvesa.c
@@ -0,0 +1,110 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#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, &regs, &regs, &sregs);
+    memcpy(&vgaInfo,vgPtr,sizeof(VgaInfoBlock));
+    if (regs.x.ax == 0x4F && strncmp(vgaInfo.VESASignature,"VESA",4) == 0) {
+        printf("VESA VBE version %d.%d BIOS detected\n\n",
+            vgaInfo.VESAVersion >> 8, vgaInfo.VESAVersion & 0xF);
+        printf("Available video modes:\n");
+        mode = PM_mapRealPointer(vgaInfo.VideoModePtr >> 16, vgaInfo.VideoModePtr & 0xFFFF);
+        while (*mode != 0xFFFF) {
+            printf("    %04hXh (%08X)\n", *mode, (int)mode);
+            mode++;
+            }
+        }
+    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
new file mode 100644
index 00000000000..cf89f79fb78
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/key.c
@@ -0,0 +1,92 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#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
new file mode 100644
index 00000000000..5c0d27a1748
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/key15.c
@@ -0,0 +1,96 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#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
new file mode 100644
index 00000000000..221bfb1a022
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/memtest.c
@@ -0,0 +1,106 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#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
new file mode 100644
index 00000000000..5b426517c82
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/mouse.c
@@ -0,0 +1,109 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#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,&regs,&regs);
+    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
new file mode 100644
index 00000000000..b808052c027
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/restore.c
@@ -0,0 +1,82 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#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
new file mode 100644
index 00000000000..07c6eaafd47
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/rtc.c
@@ -0,0 +1,92 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#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
new file mode 100644
index 00000000000..be96968f62e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/save.c
@@ -0,0 +1,70 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#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
new file mode 100644
index 00000000000..8222b86024b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/showpci.c
@@ -0,0 +1,253 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+/*------------------------- 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
new file mode 100644
index 00000000000..ee1014fb9f5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/tick.c
@@ -0,0 +1,94 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#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
new file mode 100644
index 00000000000..55e95a85d6c
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/timerc.c
@@ -0,0 +1,87 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#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
new file mode 100644
index 00000000000..1258a4bb108
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/timercpp.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+*
+*                   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 <iostream.h>
+#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
new file mode 100644
index 00000000000..0892e25f3a5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/uswc.c
@@ -0,0 +1,311 @@
+/****************************************************************************
+*
+*                   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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+/*------------------------- 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
new file mode 100644
index 00000000000..633a76d2b70
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/vftest.c
@@ -0,0 +1,78 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#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
new file mode 100644
index 00000000000..7f6f67f67ee
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/tests/video.c
@@ -0,0 +1,200 @@
+/****************************************************************************
+*
+*                   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 <stdlib.h>
+#include <stdio.h>
+#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
new file mode 100644
index 00000000000..3460b724568
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/vdd/cpuinfo.c
@@ -0,0 +1,66 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..dbbaf37dfa1
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/vdd/fileio.c
@@ -0,0 +1,359 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..03286bdc2ee
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/vdd/oshdr.h
@@ -0,0 +1,29 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..32177f810da
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/vdd/pm.c
@@ -0,0 +1,1050 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..10c63e3405f
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/vdd/vflat.c
@@ -0,0 +1,45 @@
+/****************************************************************************
+*
+*                                       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
new file mode 100644
index 00000000000..631f6558ee4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/vdd/ztimer.c
@@ -0,0 +1,103 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..64a7cecb2dc
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/vxd/_pm.asm
@@ -0,0 +1,299 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..3c7eaaeaac6
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/vxd/cpuinfo.c
@@ -0,0 +1,66 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..e2ff585839c
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/vxd/fileio.c
@@ -0,0 +1,305 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..7efc0f9f853
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/vxd/oshdr.h
@@ -0,0 +1,29 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..8d00df9065c
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/vxd/pm.c
@@ -0,0 +1,1360 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..901ce1cf037
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/vxd/vflat.c
@@ -0,0 +1,45 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..76df48c38b7
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/vxd/ztimer.c
@@ -0,0 +1,105 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..7c242b57243
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/win32/_pmwin32.asm
@@ -0,0 +1,78 @@
+;****************************************************************************
+;*
+;*                  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
new file mode 100644
index 00000000000..5978b9f76e2
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/win32/cpuinfo.c
@@ -0,0 +1,94 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..cf89401fe64
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/win32/ddraw.c
@@ -0,0 +1,583 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..c14377dcda3
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/win32/event.c
@@ -0,0 +1,460 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..a3324d33b84
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/win32/ntservc.c
@@ -0,0 +1,259 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..018c936d8aa
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/win32/oshdr.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+*
+*                   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 <windows.h>
+#include <mmsystem.h>
+#include <float.h>
+#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
new file mode 100644
index 00000000000..d08da4c630d
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/win32/pm.c
@@ -0,0 +1,1460 @@
+/****************************************************************************
+*
+*                   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 <windows.h>
+#include <mmsystem.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <direct.h>
+#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,&regs,&regs);
+}
+
+/****************************************************************************
+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,&regs,&regs);
+    regs.x.ax = 0x4F05;
+    regs.x.bx = 0x0001;
+    regs.x.dx = bank;
+    PM_int86(0x10,&regs,&regs);
+}
+
+/****************************************************************************
+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,&regs,&regs);
+}
+
+/****************************************************************************
+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
new file mode 100644
index 00000000000..70491cdb801
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/win32/vflat.c
@@ -0,0 +1,53 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..318929a2c03
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/win32/ztimer.c
@@ -0,0 +1,136 @@
+/****************************************************************************
+*
+*                         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
new file mode 100644
index 00000000000..23b938023de
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/x11/event.c
@@ -0,0 +1,307 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..45d7451be55
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/x11/oshdr.h
@@ -0,0 +1,38 @@
+/****************************************************************************
+*
+*                   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 <X11/Xlib.h>
+#include <X11/keysym.h>
+#include <time.h>
+#include <signal.h>
+#ifdef USE_OS_JOYSTICK
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XInput.h>
+#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
new file mode 100644
index 00000000000..0c6c80f0543
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/z_samples.vpj
@@ -0,0 +1,74 @@
+[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
new file mode 100644
index 00000000000..35081e9a367
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/pm/ztimer.c
@@ -0,0 +1,517 @@
+/****************************************************************************
+*
+*                   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
new file mode 100644
index 00000000000..e824299c050
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/AsmMacros.h
@@ -0,0 +1,450 @@
+/* $XConsortium: AsmMacros.h /main/13 1996/10/25 11:33:12 kaleb $ */
+/*
+ * (c) Copyright 1993,1994 by David Wexelblat <dwex@xfree86.org>
+ *
+ * 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 <sys/types.h>
+
+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 <sys/types.h>
+#  ifndef __USLC__
+#   define __USLC__
+#  endif
+# endif
+#ifndef SCO325
+# include <sys/inline.h>
+#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
new file mode 100644
index 00000000000..4b7d0fa0299
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/README
@@ -0,0 +1,35 @@
+
+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.  <Egbert.Eich@Physik.TU-Darmstadt.DE>
+
+
+
diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/awk.scr b/board/MAI/bios_emulator/scitech/src/v86bios/awk.scr
new file mode 100644
index 00000000000..9d2a80d7d8a
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/awk.scr
@@ -0,0 +1,15 @@
+/.*\(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
new file mode 100644
index 00000000000..4173c953ba9
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/cbios.c
@@ -0,0 +1,415 @@
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <sys/stat.h>
+#include <getopt.h>
+#if defined(__alpha__) || defined (__ia64__)
+#include <sys/io.h>
+#elif defined(HAVE_SYS_PERM)
+#include <sys/perm.h>
+#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; i<size; i++)
+    val += *(start + i);
+    
+  if (!val)
+    return 1;
+
+    fprintf(stderr,"BIOS cksum wrong!\n");
+  return 0;
+}
+
+static void
+print_regs(i86biosRegsPtr regs)
+{
+    printf("ax=%x bx=%x cx=%x dx=%x es=%x di=%x\n",(CARD16)regs->ax,
+       (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
new file mode 100644
index 00000000000..3a468da3138
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/command.c
@@ -0,0 +1,41 @@
+#include <stdio.h>
+#include <readline/readline.h>
+#include <readline/history.h>
+#include <malloc.h>
+
+#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
new file mode 100644
index 00000000000..46805155f87
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/console.c
@@ -0,0 +1,104 @@
+/*
+ * 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 <sys/ioctl.h>
+#include <sys/vt.h>
+#include <sys/kd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#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
new file mode 100644
index 00000000000..bc0b1117db2
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/debug.h
@@ -0,0 +1,62 @@
+/*
+ * 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
new file mode 100644
index 00000000000..943d44ede4b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/happy_cards
@@ -0,0 +1,76 @@
+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
new file mode 100644
index 00000000000..4f359e5eddb
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/hexdump
@@ -0,0 +1,3 @@
+"%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
new file mode 100644
index 00000000000..40b17b1d702
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/int.c
@@ -0,0 +1,238 @@
+/*
+ * 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 <sys/io.h>
+#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
new file mode 100644
index 00000000000..129e24f383f
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/io.c
@@ -0,0 +1,257 @@
+/*
+ * 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 <stdio.h>
+#if defined(__alpha__) || defined (__ia64__)
+#include <sys/io.h>
+#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
new file mode 100644
index 00000000000..3a3391c7b41
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/lex.l
@@ -0,0 +1,79 @@
+%{
+#include "parser.h"
+
+#include <string.h>
+#include <stdio.h>
+
+ 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
new file mode 100644
index 00000000000..b73d05776e2
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/main.c
@@ -0,0 +1,616 @@
+/*
+ * 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 <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <sys/stat.h>
+#if defined(__alpha__) || defined (__ia64__)
+#include <sys/io.h>
+#elif defined(HAVE_SYS_PERM)
+#include <sys/perm.h>
+#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<size; i++)
+    val += *(start + i);
+    
+  if (!val)
+    return 1;
+
+    fprintf(stderr,"BIOS cksum wrong!\n");
+  return 0;
+}
diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/makefile.linux b/board/MAI/bios_emulator/scitech/src/v86bios/makefile.linux
new file mode 100644
index 00000000000..5dfe3069917
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/makefile.linux
@@ -0,0 +1,59 @@
+CFLAGS=-g -I/usr/include -I../../include/ -O0 -Wall
+CC=gcc
+
+.y.c:
+    bison -d -o $@ $<
+.l.c:
+    flex -o$@ $< 
+
+SRCS = main.c io.c x86emu.c int.c pci.c
+OBJS = main.o io.o x86emu.o int.o pci.o
+
+all : vbios.vm86 v86bios.vm86 cbios.vm86 cbios.x86emu vbios.x86emu v86bios.x86emu 
+#all :  cbios.x86emu vbios.x86emu v86bios.x86emu 
+
+parser.c : parser.y
+lex.c : lex.l
+cbios.o : cbios.c v86bios.h debug.h
+main.o : main.c v86bios.h pci.h debug.h
+io.o : v86bios.h AsmMacros.h debug.h
+mem.o : mem.c debug.h v86bios.h
+int.o : int.c v86bios.h debug.h
+pci.o : pci.c pci.h debug.h
+console.o : console.c v86bios.h debug.h
+v86.o : v86.c debug.h
+parser.o : parser.c
+lex.o : lex.c
+v86bios.o: v86bios.c v86bios.h pci.h debug.h
+logging.o: logging.c v86bios.h
+x86emu.o : x86emu.c v86bios.h debug.h
+    $(CC) -c -DX86EMU $(CFLAGS) $*.c
+
+vbios.x86emu : main.o x86emu.o io.o int.o pci.o console.o mem.o logging.o
+    gcc -Wl,-defsym -Wl,printk=lprintf -o vbios.x86emu main.o \
+    x86emu.o io.o int.o pci.o console.o mem.o logging.o \
+    -L../x86emu -lx86emud -lc 
+vbios.vm86 : main.o v86.o io.o int.o pci.o console.o logging.o
+    gcc -o vbios.vm86 main.o v86.o io.o int.o pci.o console.o \
+    logging.o -lc 
+cbios.x86emu : cbios.o x86emu.o io.o int.o pci.o console.o mem.o logging.o
+    gcc -Wl,-defsym -Wl,printk=lprintf -o cbios.x86emu cbios.o \
+    x86emu.o io.o int.o pci.o console.o mem.o logging.o \
+    -L../x86emu -lx86emud -lc 
+cbios.vm86 : cbios.o v86.o io.o int.o pci.o console.o logging.o
+    gcc -o cbios.vm86 cbios.o v86.o io.o int.o pci.o console.o \
+    logging.o -lc 
+v86bios.vm86: command.o parser.o lex.o v86bios.o v86.o io.o int.o pci.o console.o logging.o
+     gcc -o v86bios.vm86 command.o parser.o lex.o v86bios.o v86.o io.o \
+     int.o pci.o console.o logging.o -L/usr/lib/curses -lfl \
+     -lreadline -lc -lncurses /usr/lib/libc.a
+v86bios.x86emu: command.o parser.o lex.o v86bios.o x86emu.o io.o int.o pci.o console.o logging.o
+    gcc -Wl,-defsym -Wl,printk=lprintf -o v86bios.x86emu \
+    command.o parser.o lex.o v86bios.o x86emu.o io.o \
+    int.o pci.o console.o logging.o -L/usr/lib/curses -lfl \
+    -lreadline -lc -lncurses  /usr/lib/libc.a -L../x86emu -lx86emud
+
+clean:
+    rm -f *.o vbios.x86emu vbios.vm86 cbios.x86emu cbios.vm86 parser.c \
+    lex.c parser.h v86bios.x86emu v86bios.vm86
+
diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/mem.c b/board/MAI/bios_emulator/scitech/src/v86bios/mem.c
new file mode 100644
index 00000000000..50dc55fdf50
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/mem.c
@@ -0,0 +1,126 @@
+/*
+ * 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 "v86bios.h"
+#include "x86emu.h"
+
+#ifdef __alpha__
+
+void* vram_map = 0;
+int sparse_shift = 5;
+
+#define mem_barrier()        __asm__ __volatile__("mb"  : : : "memory")
+
+#define vuip    volatile unsigned int *
+
+CARD8
+mem_rb(CARD32 addr)
+{
+  unsigned long result, shift;
+#if 1
+  if (addr >= 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<<sparse_shift)
+             +(1<<(sparse_shift-2)));
+    result >>= 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<<sparse_shift)+(3<<(sparse_shift-2)));
+    return result;
+  } else 
+#endif
+    return rdl(addr);
+}
+
+void
+mem_wb(CARD32 addr, CARD8 val)
+{
+    unsigned int b = val & 0xffU;
+#if 1  
+  if (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<<sparse_shift)
+        +(1<<(sparse_shift-2))) = w * 0x00010001;
+    mem_barrier();
+  } else 
+#endif
+    wrw(addr,val);
+}
+
+void
+mem_wl(CARD32 addr, CARD32 val)
+{
+#if 1  
+  if (addr >= 0xA0000 && addr <= 0xBFFFF) {
+    addr -= 0xA0000;
+    *(vuip)((unsigned long)vram_map+(addr<<sparse_shift)
+        +(3<<(sparse_shift-2))) = val;
+    mem_barrier();
+  } else 
+#endif
+    wrl(addr,val);
+}
+#endif
+
+
diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/parser.y b/board/MAI/bios_emulator/scitech/src/v86bios/parser.y
new file mode 100644
index 00000000000..21c4023dcdb
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/parser.y
@@ -0,0 +1,498 @@
+%{
+#include <malloc.h>
+#include <string.h>
+#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 \"<filename>\" | ? |"
+                         " 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 | <hex-number> | 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 \"<filename>\" | 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,&regs);
+}
+
+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
new file mode 100644
index 00000000000..e68c61d5ef4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/pci.c
@@ -0,0 +1,903 @@
+/*
+ * 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 <fcntl.h>
+#include <unistd.h>
+#include <malloc.h>
+#include <stdio.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#if defined (__alpha__) || defined (__ia64__)
+#include <sys/io.h>
+#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 <asm/unistd.h>
+
+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;i<length;i++)
+            *(scratch + i)=*(ptr + i);
+        break;
+    }
+
+    if (pciP != CurrentPci)
+      PciWrite32(0x4,enablePci,pciP->Slot.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
new file mode 100644
index 00000000000..0ab7363df20
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/pci.h
@@ -0,0 +1,127 @@
+/*
+ * 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
new file mode 100644
index 00000000000..3170a9cb557
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/v86.c
@@ -0,0 +1,562 @@
+/*
+ * 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 <sys/vm86.h>
+#include <unistd.h>
+#include <errno.h>
+#include <asm/unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+#include <setjmp.h>
+#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,&regs)))
+        if (!(val = run_bios_int(num,&regs)))
+            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
new file mode 100644
index 00000000000..7a3fb36655e
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.c
@@ -0,0 +1,933 @@
+/*
+ * 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 <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <sys/stat.h>
+#include <readline/readline.h>
+#include <readline/history.h>
+#if defined(__alpha__) || defined (__ia64__)
+#include <sys/io.h>
+#elif defined(HAVE_SYS_PERM)
+#include <sys/perm.h>
+#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; i<size; i++)
+    val += *(start + i);
+    
+  if (!val)
+    return 1;
+
+    fprintf(stderr,"BIOS cksum wrong!\n");
+  return 0;
+}
+
+void
+runINT(int num, i86biosRegsPtr Regs)
+{
+    Bool isVideo = FALSE;
+    CARD8 code_int[] = { 3, 0xcd, 0x00, 0xf4 };
+
+    code_int[2] = (CARD8) num;
+    
+    if (num == 0x10)
+    isVideo = TRUE;
+    
+    if (!setup_system_bios())
+    return;
+
+    if ((isVideo && (!CurrentPci || CurrentPci->active)) || !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
new file mode 100644
index 00000000000..06d0f9ff52c
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.h
@@ -0,0 +1,215 @@
+/*
+ * 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 <stdio.h>
+
+#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
new file mode 100644
index 00000000000..7753f2495d4
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/working_cards
@@ -0,0 +1,7 @@
+David Monro:                    Trident TGUI 9440
+                                Virge/VX (Diamond Stealth 3D 3400)   
+                                Riva TNT (Diamond Viper V550)   no vbios?
+Jarno Paananen <jpaana@s2.org>: 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
new file mode 100644
index 00000000000..2cc72df995c
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/v86bios/x86emu.c
@@ -0,0 +1,316 @@
+/*
+ * 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 </usr/include/unistd.h>
+#include <errno.h>
+#include <asm/unistd.h>
+//#include <syscall-list.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#ifdef __alpha__
+#include <sys/io.h>
+#endif
+#include <signal.h>
+#include <setjmp.h>
+#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,&regs))) {
+        if (!run_bios_int(num,&regs))
+            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
new file mode 100644
index 00000000000..a3ede4a87d5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/LICENSE
@@ -0,0 +1,17 @@
+                         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
new file mode 100644
index 00000000000..050008c9306
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/debug.c
@@ -0,0 +1,443 @@
+/****************************************************************************
+*
+*						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 <stdarg.h>
+#include <stdlib.h>
+
+/*----------------------------- 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<n; i++) {
+		op1 = (*sys_rdb)(((u32)M.x86.R_CS<<4) + (M.x86.R_IP++));
+		(x86emu_optab[op1])(op1);
+    }
+    /* end major hack mode. */
+}
+
+void x86emu_check_ip_access (void)
+{
+    /* NULL as of now */
+}
+
+void x86emu_check_sp_access (void)
+{
+}
+
+void x86emu_check_mem_access (u32 dummy)
+{
+	/*  check bounds, etc */
+}
+
+void x86emu_check_data_access (uint dummy1, uint dummy2)
+{
+	/*  check bounds, etc */
+}
+
+void x86emu_inc_decoded_inst_len (int x)
+{
+	M.x86.enc_pos += x;
+}
+
+void x86emu_decode_printf (char *x)
+{
+	sprintf(M.x86.decoded_buf+M.x86.enc_str_pos,"%s",x);
+	M.x86.enc_str_pos += strlen(x);
+}
+
+void x86emu_decode_printf2 (char *x, int y)
+{
+	char temp[100];
+	sprintf(temp,x,y);
+	sprintf(M.x86.decoded_buf+M.x86.enc_str_pos,"%s",temp);
+	M.x86.enc_str_pos += strlen(temp);
+}
+
+void x86emu_end_instr (void)
+{
+	M.x86.enc_str_pos = 0;
+	M.x86.enc_pos = 0;
+}
+
+static void print_encoded_bytes (u16 s, u16 o)
+{
+    int i;
+    char buf1[64];
+	for (i=0; i< M.x86.enc_pos; i++) {
+		sprintf(buf1+2*i,"%02x", fetch_data_byte_abs(s,o+i));
+    }
+	printk("%-20s",buf1);
+}
+
+static void print_decoded_instruction (void)
+{
+	printk("%s", M.x86.decoded_buf);
+}
+
+void x86emu_print_int_vect (u16 iv)
+{
+	u16 seg,off;
+
+	if (iv > 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
new file mode 100644
index 00000000000..bb204e60014
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/decode.c
@@ -0,0 +1,970 @@
+/****************************************************************************
+*
+*						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
new file mode 100644
index 00000000000..08aea422925
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/fpu.c
@@ -0,0 +1,945 @@
+/****************************************************************************
+*
+*						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
new file mode 100644
index 00000000000..8ce2e9e848b
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/makefile
@@ -0,0 +1,63 @@
+#############################################################################
+#
+#						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
new file mode 100644
index 00000000000..6edfd76e199
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/makefile.cross
@@ -0,0 +1,79 @@
+#############################################################################
+#
+#						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 \
+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)
+	ppc-elf32-ar rv $(TARGETLIB) $(OBJS)
+
+$(TARGETDEBUGLIB): $(DEBUGOBJS)
+	ppc-elf32-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 -mrelocatable -ffixed-r14 -meabi -mrelocatable -ffixed-r14 -meabi
+CDEBUGFLAGS = -DDEBUG
+
+.c.o:
+	ppc-elf32-gcc -g -O2 -Wall -c $(CFLAGS) $(INCS) $*.c
+
+.c.d:
+	ppc-elf32-gcc -g -O2 -Wall -c -o$*.d $(CFLAGS) $(CDEBUGFLAGS) $(INCS) $*.c
+
+.cpp.o:
+	ppc-elf32-gcc -c $(CFLAGS) $(INCS) $*.cpp
+
+clean:
+	rm -f *.a *.o *.d
+
+validate:	validate.o libx86emu.a
+	ppc-elf32-gcc -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
new file mode 100644
index 00000000000..f74b88d4c88
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/makefile.linux
@@ -0,0 +1,81 @@
+#############################################################################
+#
+#						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/ops.c b/board/MAI/bios_emulator/scitech/src/x86emu/ops.c
new file mode 100644
index 00000000000..0d797766b0a
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/ops.c
@@ -0,0 +1,11701 @@
+/****************************************************************************
+*
+*						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
new file mode 100644
index 00000000000..2ada44ee212
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/ops2.c
@@ -0,0 +1,2800 @@
+/****************************************************************************
+*
+*						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
new file mode 100644
index 00000000000..ba4ffdeda35
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/prim_ops.c
@@ -0,0 +1,2914 @@
+/****************************************************************************
+*
+*						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
new file mode 100644
index 00000000000..d54ca79c0a3
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/sys.c
@@ -0,0 +1,658 @@
+/****************************************************************************
+*
+*						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 <string.h>
+
+/*------------------------- 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
new file mode 100644
index 00000000000..239f6c1f340
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/validate.c
@@ -0,0 +1,765 @@
+/****************************************************************************
+*
+*						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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#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
new file mode 100644
index 00000000000..b4a3ed50009
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/debug.h
@@ -0,0 +1,210 @@
+/****************************************************************************
+*
+*						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
new file mode 100644
index 00000000000..321a345399f
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/decode.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+*
+*						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
new file mode 100644
index 00000000000..5fb271463b6
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/fpu.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+*
+*						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
new file mode 100644
index 00000000000..65ea6765439
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/ops.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+*
+*						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
new file mode 100644
index 00000000000..e023cf88daa
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/prim_asm.h
@@ -0,0 +1,970 @@
+/****************************************************************************
+*
+*						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
new file mode 100644
index 00000000000..1633fe1fae5
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/prim_ops.h
@@ -0,0 +1,231 @@
+/****************************************************************************
+*
+*						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
new file mode 100644
index 00000000000..bff49039e01
--- /dev/null
+++ b/board/MAI/bios_emulator/scitech/src/x86emu/x86emu/x86emui.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+*
+*						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 <stdio.h>
+#include <string.h>
+
+/*--------------------------- 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
new file mode 100644
index 00000000000..b1ad61a6a04
--- /dev/null
+++ b/board/MAI/bios_emulator/x86interface.c
@@ -0,0 +1,815 @@
+#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;
+#ifdef DEBUG
+    char *s;
+#endif
+#ifdef EASTEREGG
+    int easteregg_active = 0;
+#endif
+    char *pal_reset;
+    u8 *fb;
+    unsigned char *msg;
+    unsigned char current_attr;
+
+    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;
+    }
+
+#ifdef 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<video_rows()*video_cols()*2; i+=2)
+    {
+	*(fb+i) = ' ';
+	*(fb+i+1) = current_attr;
+    }
+
+    fb = (u8 *)VIDEO_BASE + (video_rows())-1*(video_cols()*2);
+    for (i=0; i<video_cols(); i++)
+    {
+	*(fb + 2*i)     = 32;
+	*(fb + 2*i + 1) = 0x17;
+    }
+
+    msg = done_msg;
+    while (*msg)
+    {
+	*fb = *msg;
+	fb  += 2;
+	msg ++;
+    }
+*/
+#ifdef DEBUG
+    if (getenv("x86_do_inout")) do_inout();
+#endif
+
+    dcache_disable();
+    return 1;
+}
+
+// Clean up the x86 mess
+void shutdown_bios(void)
+{
+//    disable_compatibility_hole();
+    // Free the memory associated
+    free(M.mem_base);
+
+}
+
+int to_int(char *buffer)
+{
+    int base = 0;
+    int res  = 0;
+
+    if (*buffer == '$') 
+    {
+	base = 16;
+	buffer++;
+    }
+    else base = 10;
+
+    for (;;)
+    {
+	switch(*buffer)
+	{
+	case '0' ... '9':
+	    res *= base;
+	    res += *buffer - '0';
+	    break;
+	case 'A':
+	case 'a':
+	    res *= base;
+	    res += 10;
+	    break;
+	case 'B':
+	case 'b':
+	    res *= base;
+	    res += 11;
+	    break;	    
+	case 'C':
+	case 'c':
+	    res *= base;
+	    res += 12;
+	    break;	    
+	case 'D':
+	case 'd':
+	    res *= base;
+	    res += 13;
+	    break;	    
+	case 'E':
+	case 'e':
+	    res *= base;
+	    res += 14;
+	    break;	    
+	case 'F':
+	case 'f':
+	    res *= base;
+	    res += 15;
+	    break;	
+	default:
+	    return res;
+	}
+	buffer++;
+    }
+    return res;
+}
+
+void one_arg(char *buffer, int *a)
+{
+    while (*buffer && *buffer != '\n')
+    {
+	if (*buffer == ' ') buffer++;
+	else break;
+    }
+
+    *a = to_int(buffer);
+}
+
+void two_args(char *buffer, int *a, int *b)
+{
+    while (*buffer && *buffer != '\n')
+    {
+	if (*buffer == ' ') buffer++;
+	else break;
+    }
+
+    *a = to_int(buffer);
+
+    while (*buffer && *buffer != '\n')
+    {
+	if (*buffer != ' ') buffer++;
+	else break;
+    }
+
+    while (*buffer && *buffer != '\n')
+    {
+	if (*buffer == ' ') buffer++;
+	else break;
+    }
+
+    *b = to_int(buffer);
+}
+
+void do_inout(void)
+{
+    char buffer[256];
+    char *arg1, *arg2;
+    int a,b;
+
+    printf("In/Out Session\nUse 'i[bwl]' for in, 'o[bwl]' for out and 'q' to quit\n");
+
+    do
+    {
+	cons_gets(buffer);
+	printf("\n");
+
+	*arg1 = buffer;
+	while (*arg1 != ' ' ) arg1++;
+	while (*arg1 == ' ') arg1++;
+
+	if (buffer[0] == 'i')
+	{
+	    one_arg(buffer+2, &a);
+	    switch (buffer[1])
+	    {
+	    case 'b':
+		printf("in_byte(%xh) = %xh\n", a, A1_inb(a));
+		break;
+	    case 'w':
+		printf("in_word(%xh) = %xh\n", a, A1_inw(a));
+		break;
+	    case 'l':
+		printf("in_dword(%xh) = %xh\n", a, A1_inl(a));
+		break;
+	    default:
+		printf("Invalid length '%c'\n", buffer[1]);
+		break;
+	    }
+	}
+	else if (buffer[0] == 'o')
+	{
+	    two_args(buffer+2, &a, &b);
+	    switch (buffer[1])
+	    {
+	    case 'b':
+		printf("out_byte(%d, %d)\n", a, b);
+		A1_outb(a,b);
+		break;
+	    case 'w':
+		printf("out_word(%d, %d)\n", a, b);
+		A1_outw(a, b);
+		break;
+	    case 'l':
+		printf("out_long(%d, %d)\n", a, b);
+		A1_outl(a, b);
+		break;
+	    default:
+		printf("Invalid length '%c'\n", buffer[1]);
+		break;
+	    }
+	} else if (buffer[0] == 'q') return;
+    } while (1);
+}
diff --git a/board/MAI/menu/cmd_menu.c b/board/MAI/menu/cmd_menu.c
new file mode 100644
index 00000000000..a24ab492679
--- /dev/null
+++ b/board/MAI/menu/cmd_menu.c
@@ -0,0 +1,9 @@
+#include <common.h>
+#include <command.h>
+#include <cmd_menu.h>
+
+int do_menu( cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[] )
+{
+//    printf("<NOT YET IMPLEMENTED>\n");
+    return 0;
+}
diff --git a/board/MAI/menu/menu.c b/board/MAI/menu/menu.c
new file mode 100644
index 00000000000..31301426472
--- /dev/null
+++ b/board/MAI/menu/menu.c
@@ -0,0 +1,66 @@
+#include "menu.h"
+
+#define SINGLE_BOX 0
+#define DOUBLE_BOX 1
+
+void video_draw_box(int style, int attr, char *title, int separate, int x, int y, int w, int h);
+void video_draw_text(int x, int y, int attr, char *text);
+void video_save_rect(int x, int y, int w, int h, void *save_area, int clearchar, int clearattr);
+void video_restore_rect(int x, int y, int w, int h, void *save_area);
+int  video_rows(void);
+int  video_cols(void);
+
+#define MAX_MENU_OPTIONS 200
+
+typedef struct
+{
+    int used;                  /* flag if this entry is used */
+    int entry_x;               /* Character column of the menu entry */
+    int entry_y;               /* Character line of the entry */
+    int option_x;              /* Character colum of the option (entry is same) */
+} option_data_t;
+
+option_data_t odata[MAX_MENU_OPTIONS];
+
+int normal_attr = 0x0F;
+int select_attr = 0x2F;
+int disabled_attr = 0x07;
+
+menu_t *root_menu;
+
+int menu_init (menu_t *root)
+{
+    char *s;
+    int i;
+
+    s = getenv("menu_normal");
+    if (s) normal_attr = atoi(s);
+
+    s = getenv("menu_select");
+    if (s) select_attr = atoi(s);
+
+    s = getenv("menu_disabled");
+    if (s) disabled_attr = atoi(s);
+    
+    for (i=0; i<MAX_MENU_OPTIONS; i++) odata[i].used = 0;
+    
+    root_menu = root;
+}
+
+option_data_t *menu_alloc_odata(void)
+{
+    int i;
+    for (int i=0; i<MAX_MENU_OPTIONS; i++)
+    {
+	if (odata[i].used == 0) return &odata[i];
+    }
+    return NULL;
+}
+
+void menu_free_odata(option_data_t *odata)
+{
+    odata->used = 0;
+}
+
+void menu_layout (menu_t *menu)
+{
diff --git a/board/MAI/menu/menu.h b/board/MAI/menu/menu.h
new file mode 100644
index 00000000000..e5886b83b3e
--- /dev/null
+++ b/board/MAI/menu/menu.h
@@ -0,0 +1,174 @@
+#ifndef MENU_H
+#define MENU_H
+
+/* A single menu */
+typedef void (*menu_finish_callback)(struct menu_s *menu);
+
+typedef struct menu_s
+{
+    char *name;                     /* Menu name */
+    int  num_options;               /* Number of options in this menu */
+    int  flags;                     /* Various flags - see below */
+    int  option_align;              /* Aligns options to a field width of this much characters if != 0 */
+
+    struct menu_option_s **options; /* Pointer to this menu's options */
+    menu_finish_callback callback;  /* Called when the menu closes */
+} menu_t;
+
+/*
+ * type: Type of the option (see below)
+ * name: Name to display for this option
+ * help: Optional help string
+ * id  : optional id number
+ * sys : pointer for system-specific data, init to NULL and don't touch
+ */
+
+#define OPTION_PREAMBLE				\
+    int type;                     		\
+    char *name;   				\
+    char *help;   				\
+    int id;                                     \
+    void *sys;                                  \
+
+
+/*
+ * Menu option types.
+ * There are a number of different layouts for menu options depending
+ * on their types. Currently there are the following possibilities:
+ *
+ * Submenu:
+ *   This entry links to a new menu.
+ *
+ * Boolean:
+ *   A simple on/off toggle entry. Booleans can be either yes/no, 0/1 or on/off.
+ *   Optionally, this entry can enable/disable a set of other options. An example would
+ *   be to enable/disable on-board USB, and if enabled give access to further options like
+ *   irq settings, base address etc.
+ *
+ * Text:
+ *   A single line/limited number of characters text entry box. Text can be restricted
+ *   to a certain charset (digits/hex digits/all/custom). Result is also available as an
+ *   int if numeric. 
+ *
+ * Selection:
+ *   One-of-many type of selection entry. User may choose on of a set of strings, which
+ *   maps to a specific value for the variable.
+ *
+ * Routine:
+ *   Selecting this calls an entry-specific routine. This can be used for saving contents etc.
+ *
+ * Custom:
+ *   Display and behaviour of this entry is defined by a set of callbacks.
+ */
+
+#define MENU_SUBMENU_TYPE 0
+typedef struct menu_submenu_s
+{
+    OPTION_PREAMBLE
+
+    menu_t *   submenu;            /* Pointer to the submenu */
+} menu_submenu_t;
+
+#define MENU_BOOLEAN_TYPE 1
+typedef struct menu_boolean_s
+{
+    OPTION_PREAMBLE
+
+    char *variable;                /* Name of the variable to getenv()/setenv() */
+    int subtype;                   /* Subtype (on/off, 0/1, yes/no, enable/disable), see below */
+    int mutex;                     /* Bit mask of options to enable/disable. Bit 0 is the option
+				      immediately following this one, bit 1 is the next one etc.
+				      bit 7 = 0 means to disable when this option is off,
+				      bit 7 = 1 means to disable when this option is on.
+				      An option is disabled when the type field's upper bit is set */
+} menu_boolean_t;
+
+/* BOOLEAN Menu flags */
+#define MENU_BOOLEAN_ONOFF         0x01
+#define MENU_BOOLEAN_01            0x02
+#define MENU_BOOLEAN_YESNO         0x03
+#define MENU_BOOLEAN_ENDIS         0x04
+#define MENU_BOOLEAN_TYPE_MASK     0x07
+
+
+#define MENU_TEXT_TYPE 2
+typedef struct menu_text_s
+{
+    OPTION_PREAMBLE
+
+    char *variable;                /* Name of the variable to getenv()/setenv() */
+    int maxchars;                  /* Max number of characters */
+    char *charset;                 /* Optional charset to use */
+    int flags;                     /* Flags - see below */
+} menu_text_t;
+
+/* TEXT entry menu flags */
+#define MENU_TEXT_NUMERIC         0x01
+#define MENU_TEXT_HEXADECIMAL     0x02
+#define MENU_TEXT_FREE            0x03
+#define MENU_TEXT_TYPE_MASK       0x07
+
+
+#define MENU_SELECTION_TYPE 3
+typedef struct menu_select_option_s
+{
+    char *map_from;               /* Map this variable contents ... */
+    char *map_to;                 /* ... to this menu text and vice versa */
+} menu_select_option_t;
+
+typedef struct menu_select_s
+{
+    OPTION_PREAMBLE
+
+    int num_options;             /* Number of mappings */
+    menu_select_option_t **options;
+                                 /* Option list array */
+} menu_select_t;
+
+
+#define MENU_ROUTINE_TYPE 4
+typedef void (*menu_routine_callback)(struct menu_routine_s *);
+
+typedef struct menu_routine_s
+{
+    OPTION_PREAMBLE
+    menu_routine_callback callback;
+                                 /* routine to be called */ 
+    void *user_data;             /* User data, don't care for system */
+} menu_routine_t;
+    
+
+#define MENU_CUSTOM_TYPE 5
+typedef void (*menu_custom_draw)(struct menu_custom_s *);
+typedef void (*menu_custom_key)(struct menu_custom_s *, int);
+
+typedef struct menu_custom_s
+{
+    OPTION_PREAMBLE
+    menu_custom_draw drawfunc;
+    menu_custom_key  keyfunc;
+    void *user_data;
+} menu_custom_t;
+
+/*
+ * The menu option superstructure
+ */
+typedef struct menu_option_s
+{
+    union
+    {
+	menu_submenu_t m_sub_menu;
+	menu_boolean_t m_boolean;
+	menu_text_t    m_text;
+	menu_select_t  m_select;
+	menu_routine_t m_routine;
+    };
+} menu_option_t;
+
+/* Init the menu system. Returns <0 on error */
+int menu_init(menu_t *root);
+
+/* Execute a single menu. Returns <0 on error */
+int menu_do(menu_t *menu);
+
+#endif
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index a0587d019f8..4c0d1f5bde5 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -224,6 +224,17 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 	iflag = disable_interrupts();
 
+#ifdef CONFIG_AMIGAONEG3SE
+	/*
+	 * We've possible left the caches enabled during 
+	 * bios emulation, so turn them off again
+	 */
+	icache_disable();
+	invalidate_l1_instruction_cache();
+	flush_data_cache();
+	dcache_disable();
+#endif
+
 	switch (hdr->ih_comp) {
 	case IH_COMP_NONE:
 		if(ntohl(hdr->ih_load) == addr) {
diff --git a/common/cmd_fdc.c b/common/cmd_fdc.c
index e45b3361ca1..3ee342fcfc0 100644
--- a/common/cmd_fdc.c
+++ b/common/cmd_fdc.c
@@ -188,6 +188,30 @@ static FDC_COMMAND_STRUCT cmd; /* global command struct */
 #endif
 
 
+#ifdef CONFIG_AMIGAONEG3SE
+unsigned char INT6_Status;
+
+void fdc_interrupt(void)
+{
+    INT6_Status = 0x80;
+}
+
+/* waits for an interrupt (polling) */
+int wait_for_fdc_int(void)
+{
+	unsigned long timeout;
+	timeout = FDC_TIME_OUT;
+	while(((volatile)INT6_Status & 0x80) == 0) {
+		timeout--;
+		udelay(10);
+		if(timeout == 0) /* timeout occured */
+			return FALSE;
+	}
+	INT6_Status = 0;
+	return TRUE;
+}
+#endif
+   
 /* Supporting Functions */
 /* reads a Register of the FDC */
 unsigned char read_fdc_reg(unsigned int addr)
@@ -210,6 +234,7 @@ void write_fdc_reg(unsigned int addr, unsigned char val)
 	tmp[0]=val;
 }
 
+#ifndef CONFIG_AMIGAONEG3SE
 /* waits for an interrupt (polling) */
 int wait_for_fdc_int(void)
 {
@@ -224,6 +249,7 @@ int wait_for_fdc_int(void)
 	return TRUE;
 }
 
+#endif
 
 /* reads a byte from the FIFO of the FDC and checks direction and RQM bit
    of the MSR. returns -1 if timeout, or byte if ok */
@@ -416,7 +442,7 @@ int fdc_seek(FDC_COMMAND_STRUCT *pCMD,FD_GEO_STRUCT *pFG)
 	return(fdc_issue_cmd(pCMD,pFG));
 }
 
-
+#ifndef CONFIG_AMIGAONEG3SE
 /* terminates current command, by not servicing the FIFO
  * waits for interrupt and fills in the result bytes */
 int fdc_terminate(FDC_COMMAND_STRUCT *pCMD)
@@ -430,6 +456,27 @@ int fdc_terminate(FDC_COMMAND_STRUCT *pCMD)
 	}
 	return TRUE;
 }
+#endif
+#ifdef CONFIG_AMIGAONEG3SE
+int fdc_terminate(FDC_COMMAND_STRUCT *pCMD)
+{
+	int i;
+	for(i=0;i<100;i++)
+		udelay(500); /* wait 500usec for fifo overrun */
+	while((INT6_Status&0x80)==0x00); /* wait as long as no int has occured */
+	for(i=0;i<7;i++) {
+		pCMD->result[i]=(unsigned char)read_fdc_byte();
+	}
+	INT6_Status = 0;
+	return TRUE;
+}
+
+#endif
+
+#ifdef CONFIG_AMIGAONEG3SE
+#define disable_interrupts() 0
+#define enable_interrupts() (void)0
+#endif
 
 /* reads data from FDC, seek commands are issued automatic */
 int fdc_read_data(unsigned char *buffer, unsigned long blocks,FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
@@ -550,6 +597,11 @@ retrycal:
 	return TRUE;
 }
 
+#ifdef CONFIG_AMIGAONEG3SE
+#undef disable_interrupts()
+#undef enable_interrupts()
+#endif
+
 /* Scan all drives and check if drive is present and disk is inserted */
 int fdc_check_drive(FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
 {
@@ -590,6 +642,7 @@ int fdc_check_drive(FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
 }
 
 
+
 /**************************************************************************
 * int fdc_setup
 * setup the fdc according the datasheet
@@ -597,9 +650,13 @@ int fdc_check_drive(FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
 */
 int fdc_setup(int drive, FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
 {
-
 	int i;
 
+#ifdef CONFIG_AMIGAONEG3SE
+	irq_install_handler(6, (interrupt_handler_t *)fdc_interrupt, NULL);
+	i8259_unmask_irq(6);
+#endif
+
 #ifdef CFG_FDC_HW_INIT
         fdc_hw_init ();
 #endif
@@ -648,6 +705,7 @@ int fdc_setup(int drive, FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
 	/* then, we clear the reset in the DOR */
 	/* fdc_check_drive(pCMD,pFG);	*/
 	/*	write_fdc_reg(FDC_DOR,0x04); */
+
 	return TRUE;
 }
 #endif /* ((CONFIG_COMMANDS & CFG_CMD_FDC)||(CONFIG_COMMANDS & CFG_CMD_FDOS))*/
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index e514cf71e3e..7b455086a87 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -58,6 +58,7 @@
 
 #undef	IDE_DEBUG
 
+
 #ifdef	IDE_DEBUG
 #define	PRINTF(fmt,args...)	printf (fmt ,##args)
 #else
@@ -121,7 +122,11 @@ ulong ide_bus_offset[CFG_IDE_MAXBUS] = {
 #define	ATA_CURR_BASE(dev)	(CFG_ATA_BASE_ADDR+ide_bus_offset[IDE_BUS(dev)])
 #endif
 
+#ifndef CONFIG_AMIGAONEG3SE
 static int	    ide_bus_ok[CFG_IDE_MAXBUS];
+#else
+static int	    ide_bus_ok[CFG_IDE_MAXBUS] = {0,};
+#endif
 
 static  block_dev_desc_t ide_dev_desc[CFG_IDE_MAXDEVICE];
 /* ------------------------------------------------------------------------- */
@@ -129,7 +134,15 @@ static  block_dev_desc_t ide_dev_desc[CFG_IDE_MAXDEVICE];
 #ifdef CONFIG_IDE_LED
 static void  ide_led   (uchar led, uchar status);
 #else
+#ifndef CONFIG_AMIGAONEG3SE
 #define ide_led(a,b)	/* dummy */
+#else
+extern void ide_led(uchar led, uchar status);
+#define LED_IDE1  1
+#define LED_IDE2  2
+#define CONFIG_IDE_LED 1
+#define DEVICE_LED(x) 1
+#endif
 #endif
 
 #ifdef CONFIG_IDE_RESET
@@ -464,6 +477,11 @@ void ide_init (void)
 #endif
 	unsigned char c;
 	int i, bus;
+#ifdef CONFIG_AMIGAONEG3SE
+	unsigned int max_bus_scan;
+	unsigned int ata_reset_time;
+	char *s;
+#endif
 
 #ifdef CONFIG_IDE_8xx_PCCARD
 	extern int pcmcia_on (void);
@@ -514,8 +532,19 @@ void ide_init (void)
 	 * Wait for IDE to get ready.
 	 * According to spec, this can take up to 31 seconds!
 	 */
+#ifndef CONFIG_AMIGAONEG3SE
 	for (bus=0; bus<CFG_IDE_MAXBUS; ++bus) {
 		int dev = bus * (CFG_IDE_MAXDEVICE / CFG_IDE_MAXBUS);
+#else
+	s = getenv("ide_maxbus");
+	if (s)
+	    max_bus_scan = simple_strtol(s, NULL, 10);
+	else
+	    max_bus_scan = CFG_IDE_MAXBUS;
+
+	for (bus=0; bus<max_bus_scan; ++bus) {
+		int dev = bus * (CFG_IDE_MAXDEVICE / max_bus_scan);
+#endif
 
 		printf ("Bus %d: ", bus);
 
@@ -526,16 +555,32 @@ void ide_init (void)
 		udelay (100000);		/* 100 ms */
 		ide_outb (dev, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(dev));
 		udelay (100000);		/* 100 ms */
-
+#ifdef CONFIG_AMIGAONEG3SE
+		ata_reset_time = ATA_RESET_TIME;
+		s = getenv("ide_reset_timeout");
+		if (s) ata_reset_time = 2*simple_strtol(s, NULL, 10);
+#endif
 		i = 0;
 		do {
 			udelay (10000);		/* 10 ms */
 
 			c = ide_inb (dev, ATA_STATUS);
 			i++;
+#ifdef CONFIG_AMIGAONEG3SE
+			if (i > (ata_reset_time * 100)) {
+#else
 			if (i > (ATA_RESET_TIME * 100)) {
+#endif
 				puts ("** Timeout **\n");
 				ide_led ((LED_IDE1 | LED_IDE2), 0); /* LED's off */
+#ifdef CONFIG_AMIGAONEG3SE
+				/* If this is the second bus, the first one was OK */
+				if (bus != 0)
+				{
+				    ide_bus_ok[bus] = 0;
+				    goto skip_bus;
+				}
+#endif
 				return;
 			}
 			if ((i >= 100) && ((i%100)==0)) {
@@ -557,6 +602,10 @@ void ide_init (void)
 		}
 		WATCHDOG_RESET();
 	}
+
+#ifdef CONFIG_AMIGAONEG3SE
+      skip_bus:
+#endif
 	putc ('\n');
 
 	ide_led ((LED_IDE1 | LED_IDE2), 0);	/* LED's off	*/
@@ -736,6 +785,26 @@ __inline__ unsigned ld_le16(const volatile unsigned short *addr)
 	return val;
 }
 
+#ifdef CONFIG_AMIGAONEG3SE
+static void
+output_data_short(int dev, ulong *sect_buf, int words)
+{
+	ushort	*dbuf;
+	volatile ushort	*pbuf;
+	
+	pbuf = (ushort *)(ATA_CURR_BASE(dev)+ATA_DATA_REG);
+	dbuf = (ushort *)sect_buf;
+	while (words--) {
+		__asm__ volatile ("eieio");
+		*pbuf = *dbuf++;
+		__asm__ volatile ("eieio");
+	}
+
+	if (words&1)
+	    *pbuf = 0;
+}
+#endif
+
 static void
 input_swap_data(int dev, ulong *sect_buf, int words)
 {
@@ -803,6 +872,29 @@ input_data(int dev, ulong *sect_buf, int words)
 
 #endif	/* __PPC__ */
 
+#ifdef CONFIG_AMIGAONEG3SE
+static void
+input_data_short(int dev, ulong *sect_buf, int words)
+{
+	ushort	*dbuf;
+	volatile ushort	*pbuf;
+
+	pbuf = (ushort *)(ATA_CURR_BASE(dev)+ATA_DATA_REG);
+	dbuf = (ushort *)sect_buf;
+	while (words--) {
+		__asm__ volatile ("eieio");
+		*dbuf++ = *pbuf;
+		__asm__ volatile ("eieio");
+	}
+
+	if (words&1)
+	{
+	    ushort dummy;
+	    dummy = *pbuf;
+	}
+}
+#endif
+
 /* -------------------------------------------------------------------------
  */
 static void ide_ident (block_dev_desc_t *dev_desc)
@@ -811,6 +903,13 @@ static void ide_ident (block_dev_desc_t *dev_desc)
 	unsigned char c;
 	hd_driveid_t *iop = (hd_driveid_t *)iobuf;
 
+#ifdef CONFIG_AMIGAONEG3SE
+	int max_bus_scan;
+	int retries = 0;
+	char *s;
+	int do_retry = 0;
+#endif
+
 #if 0
 	int mode, cycle_time;
 #endif
@@ -818,12 +917,35 @@ static void ide_ident (block_dev_desc_t *dev_desc)
 	device=dev_desc->dev;
 	printf ("  Device %d: ", device);
 
+#ifdef CONFIG_AMIGAONEG3SE
+	s = getenv("ide_maxbus");
+	if (s) {
+		max_bus_scan = simple_strtol(s, NULL, 10);
+	} else {
+		max_bus_scan = CFG_IDE_MAXBUS;
+	}
+	if (device >= max_bus_scan*2) {
+		dev_desc->type=DEV_TYPE_UNKNOWN;
+		return;
+	}
+#endif
+
 	ide_led (DEVICE_LED(device), 1);	/* LED on	*/
 	/* Select device
 	 */
 	ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
 	dev_desc->if_type=IF_TYPE_IDE;
 #ifdef CONFIG_ATAPI
+
+#ifdef CONFIG_AMIGAONEG3SE
+    do_retry = 0;
+    retries = 0;
+
+    /* Warning: This will be tricky to read */
+    while (retries <= 1)
+    {
+#endif	/* CONFIG_AMIGAONEG3SE */
+
 	/* check signature */
 	if ((ide_inb(device,ATA_SECT_CNT) == 0x01) &&
 		 (ide_inb(device,ATA_SECT_NUM) == 0x01) &&
@@ -855,9 +977,34 @@ static void ide_ident (block_dev_desc_t *dev_desc)
 
 	if (((c & ATA_STAT_DRQ) == 0) ||
 	    ((c & (ATA_STAT_FAULT|ATA_STAT_ERR)) != 0) ) {
+#ifdef CONFIG_AMIGAONEG3SE
+		if (retries == 0) {
+			do_retry = 1;
+		} else {
+			dev_desc->type=DEV_TYPE_UNKNOWN;
+			return;
+		}
+#else
 		dev_desc->type=DEV_TYPE_UNKNOWN;
 		return;
+#endif	/* CONFIG_AMIGAONEG3SE */
+	}
+
+#ifdef CONFIG_AMIGAONEG3SE
+	s = getenv("ide_doreset");
+	if (s && strcmp(s, "on") == 0 && 1 == do_retry) {
+		/* Need to soft reset the device in case it's an ATAPI...  */
+		PRINTF("Retrying...\n");
+		ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
+		udelay(100000);
+		ide_outb (device, ATA_COMMAND, 0x08);
+		udelay (100000);	/* 100 ms */
+		retries++;
+	} else {
+		retries = 100;
 	}
+    }	/* see above - ugly to read */
+#endif	/* CONFIG_AMIGAONEG3SE */
 
 	input_swap_data (device, iobuf, ATA_SECTORWORDS);
 
@@ -1200,7 +1347,7 @@ static void ide_reset (void)
 
 /* ------------------------------------------------------------------------- */
 
-#ifdef CONFIG_IDE_LED
+#if defined(CONFIG_IDE_LED) && !defined(CONFIG_AMIGAONEG3SE)
 
 static	uchar	led_buffer = 0;		/* Buffer for current LED status	*/
 
@@ -1320,6 +1467,9 @@ unsigned char atapi_issue(int device,unsigned char* ccb,int ccblen, unsigned cha
 	 */
 	mask = ATA_STAT_BUSY|ATA_STAT_DRQ;
 	res = 0;
+#ifdef	CONFIG_AMIGAONEG3SE
+# warning THF: Removed LBA mode ???
+#endif
 	ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
 	c = atapi_wait_mask(device,ATAPI_TIME_OUT,mask,res);
 	if ((c & mask) != res) {
@@ -1329,8 +1479,13 @@ unsigned char atapi_issue(int device,unsigned char* ccb,int ccblen, unsigned cha
 	}
 	/* write taskfile */
 	ide_outb (device, ATA_ERROR_REG, 0); /* no DMA, no overlaped */
+	ide_outb (device, ATA_SECT_CNT, 0);
+	ide_outb (device, ATA_SECT_NUM, 0);
 	ide_outb (device, ATA_CYL_LOW,  (unsigned char)(buflen & 0xFF));
-	ide_outb (device, ATA_CYL_HIGH, (unsigned char)((buflen<<8) & 0xFF));
+	ide_outb (device, ATA_CYL_HIGH, (unsigned char)((buflen>>8) & 0xFF));
+#ifdef	CONFIG_AMIGAONEG3SE
+# warning THF: Removed LBA mode ???
+#endif
 	ide_outb (device, ATA_DEV_HD,   ATA_LBA | ATA_DEVICE(device));
 
 	ide_outb (device, ATA_COMMAND,  ATAPI_CMD_PACKET);
@@ -1429,6 +1584,16 @@ unsigned char atapi_issue_autoreq (int device,
 	unsigned char res,key,asc,ascq;
 	int notready,unitattn;
 
+#ifdef CONFIG_AMIGAONEG3SE
+	char *s;
+	unsigned int timeout, retrycnt;
+
+	s = getenv("ide_cd_timeout");
+	timeout = s ? (simple_strtol(s, NULL, 10)*1000000)/5 : 0;
+
+	retrycnt = 0;
+#endif
+
 	unitattn=ATAPI_UNIT_ATTN;
 	notready=ATAPI_DRIVE_NOT_READY;
 
@@ -1445,7 +1610,7 @@ retry:
 	memset(sense_ccb,0,sizeof(sense_ccb));
 	memset(sense_data,0,sizeof(sense_data));
 	sense_ccb[0]=ATAPI_CMD_REQ_SENSE;
-	sense_ccb[4]=18; /* allocation Legnth */
+	sense_ccb[4]=18; /* allocation Length */
 
 	res=atapi_issue(device,sense_ccb,12,sense_data,18);
 	key=(sense_data[2]&0xF);
@@ -1482,6 +1647,26 @@ retry:
 		AT_PRINTF("Media not present\n");
 		goto error;
 	}
+
+#ifdef CONFIG_AMIGAONEG3SE
+	if ((sense_data[2]&0xF)==0x0B) {
+		AT_PRINTF("ABORTED COMMAND...retry\n");
+		if (retrycnt++ < 4)
+			goto retry;
+		return (0xFF);
+	}
+
+	if ((sense_data[2]&0xf) == 0x02 &&
+	    sense_data[12] == 0x04	&&
+	    sense_data[13] == 0x01	) {
+		AT_PRINTF("Waiting for unit to become active\n");
+		udelay(timeout);
+		if (retrycnt++ < 4)
+			goto retry;
+		return 0xFF;
+	}
+#endif	/* CONFIG_AMIGAONEG3SE */
+
 	printf ("ERROR: Unknown Sense key %02X ASC %02X ASCQ %02X\n",key,asc,ascq);
 error:
 	AT_PRINTF ("ERROR Sense key %02X ASC %02X ASCQ %02X\n",key,asc,ascq);
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 0a19ce405b7..9b6d14fe235 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -353,6 +353,18 @@ int _do_setenv (int flag, int argc, char *argv[])
 		return 0;
 	}
 #endif	/* CFG_CMD_NET */
+
+#ifdef CONFIG_AMIGAONEG3SE 
+	if (strcmp(argv[1], "vga_fg_color") == 0 ||
+	    strcmp(argv[1], "vga_bg_color") == 0 ) {
+		extern void video_set_color(unsigned char attr);
+		extern unsigned char video_get_attr(void);
+
+		video_set_color(video_get_attr());
+		return 0;
+	}
+#endif	/* CONFIG_AMIGAONEG3SE */
+
 	return 0;
 }
 
diff --git a/common/cmd_pci.c b/common/cmd_pci.c
index 22e4b9a86fe..300ac020046 100644
--- a/common/cmd_pci.c
+++ b/common/cmd_pci.c
@@ -96,7 +96,7 @@ void pciinfo(int BusNum, int ShortPCIListing)
 			if ((VendorID == 0xFFFF) || (VendorID == 0x0000))
 				continue;
 
-			pci_read_config_byte(dev, PCI_HEADER_TYPE, &HeaderType);
+			if (!Function) pci_read_config_byte(dev, PCI_HEADER_TYPE, &HeaderType);
 
 			if (ShortPCIListing)
 			{
diff --git a/common/command.c b/common/command.c
index cab68abf8e3..2304d7a9b4d 100644
--- a/common/command.c
+++ b/common/command.c
@@ -72,6 +72,11 @@
 #include <cmd_log.h>
 #include <cmd_fdos.h>
 
+#ifdef CONFIG_AMIGAONEG3SE
+#include <cmd_menu.h>
+#include <cmd_boota.h>
+#endif
+
 /*
  * HELP command
  */
@@ -225,6 +230,9 @@ cmd_tbl_t cmd_tbl[] = {
 	CMD_TBL_AUTOSCRIPT
 	CMD_TBL_BASE
 	CMD_TBL_BDINFO
+#ifdef CONFIG_AMIGAONEG3SE
+	CMD_TBL_BOOTA
+#endif
 	CMD_TBL_BOOTELF
 	CMD_TBL_BOOTM
 	CMD_TBL_BOOTP
@@ -291,6 +299,9 @@ cmd_tbl_t cmd_tbl[] = {
 	CMD_TBL_MCCINFO
 	CMD_TBL_MD
 	CMD_TBL_MEMCINFO
+#ifdef CONFIG_AMIGAONEG3SE
+	CMD_TBL_MENU
+#endif
 	CMD_TBL_MII
 	CMD_TBL_MM
 	CMD_TBL_MTEST
diff --git a/common/console.c b/common/console.c
index f99dfcc64c1..d888d1ddc7e 100644
--- a/common/console.c
+++ b/common/console.c
@@ -29,6 +29,10 @@
 
 void **syscall_tbl;
 
+#ifdef CONFIG_AMIGAONEG3SE
+int console_changed = 0;
+#endif
+
 #ifdef CFG_CONSOLE_IS_IN_ENV
 /*
  * if overwrite_console returns 1, the stdin, stderr and stdout
diff --git a/common/docecc.c b/common/docecc.c
index 09e8233d81a..74ac7411a4b 100644
--- a/common/docecc.c
+++ b/common/docecc.c
@@ -35,8 +35,6 @@
 
 #if (CONFIG_COMMANDS & CFG_CMD_DOC)
 
-#define min(x,y) ((x)<(y)?(x):(y))
-
 /* need to undef it (from asm/termbits.h) */
 #undef B0
 
diff --git a/common/env_common.c b/common/env_common.c
index f7f268e7b03..bd22e154281 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -38,6 +38,11 @@
 # define SHOW_BOOT_PROGRESS(arg)
 #endif
 
+#ifdef CONFIG_AMIGAONEG3SE
+	extern void enable_nvram(void);
+	extern void disable_nvram(void);
+#endif
+
 #undef DEBUG_ENV
 #ifdef DEBUG_ENV
 #define DEBUGF(fmt,args...) printf(fmt ,##args)
@@ -180,6 +185,10 @@ void env_relocate (void)
 	DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__,
 		gd->reloc_off);
 
+#ifdef CONFIG_AMIGAONEG3SE
+	enable_nvram();
+#endif
+
 #ifdef ENV_IS_EMBEDDED
 	/*
 	 * The environment buffer is embedded with the text segment,
@@ -228,4 +237,8 @@ void env_relocate (void)
 		env_relocate_spec ();
 	}
 	gd->env_addr = (ulong)&(env_ptr->data);
+
+#ifdef CONFIG_AMIGAONEG3SE
+	disable_nvram();
+#endif
 }
diff --git a/common/hush.c b/common/hush.c
index 3cb6fc3b1cb..925474332be 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -356,11 +356,6 @@ struct built_in_command {
 };
 #endif
 
-/* belongs in busybox.h */
-static inline int max(int a, int b) {
-	return (a>b)?a:b;
-}
-
 /* This should be in utility.c */
 #ifdef DEBUG_SHELL
 #ifndef __U_BOOT__
diff --git a/common/main.c b/common/main.c
index 014804b6ef5..08d54c5c140 100644
--- a/common/main.c
+++ b/common/main.c
@@ -179,11 +179,19 @@ static __inline__ int abortboot(int bootdelay)
 
 # else	/* !defined(CONFIG_AUTOBOOT_KEYED) */
 
+#ifdef CONFIG_MENUKEY
+static int menukey = 0;
+#endif
+
 static __inline__ int abortboot(int bootdelay)
 {
 	int abort = 0;
 
+#ifdef CONFIG_MENUPROMPT
+	printf(CONFIG_MENUPROMPT, bootdelay);
+#else
 	printf("Hit any key to stop autoboot: %2d ", bootdelay);
+#endif
 
 #if defined CONFIG_ZERO_BOOTDELAY_CHECK
         /*
@@ -208,7 +216,11 @@ static __inline__ int abortboot(int bootdelay)
 			if (tstc()) {	/* we got a key press	*/
 				abort  = 1;	/* don't auto boot	*/
 				bootdelay = 0;	/* no more delay	*/
+# ifdef CONFIG_MENUKEY
+				menukey = getc();
+# else
 				(void) getc();  /* consume input	*/
+# endif
 				break;
 			}
 			udelay (10000);
@@ -323,8 +335,31 @@ void main_loop (void)
 		disable_ctrlc(prev);	/* restore Control C checking */
 # endif
 	}
+
+# ifdef CONFIG_MENUKEY
+	if (menukey == CONFIG_MENUKEY)
+	{
+	    s = getenv("menucmd");
+	    if (s)
+	    {
+# ifndef CFG_HUSH_PARSER
+		run_command (s, bd, 0);
+# else
+		parse_string_outer(s, FLAG_PARSE_SEMICOLON |
+				    FLAG_EXIT_FROM_LOOP);
+# endif
+	    }
+	}
+#endif /* CONFIG_MENUKEY */
 #endif	/* CONFIG_BOOTDELAY */
 
+#ifdef CONFIG_AMIGAONEG3SE
+	{
+	    extern void video_banner(void);
+	    video_banner();
+	}
+#endif
+
 	/*
 	 * Main Loop for Monitor Command Processing
 	 */
diff --git a/cpu/74xx_7xx/cpu.c b/cpu/74xx_7xx/cpu.c
index 8a6915fca7b..c265ce265af 100644
--- a/cpu/74xx_7xx/cpu.c
+++ b/cpu/74xx_7xx/cpu.c
@@ -44,6 +44,11 @@
 #include <74xx_7xx.h>
 #include <asm/cache.h>
 
+#ifdef CONFIG_AMIGAONEG3SE
+#include "../board/MAI/AmigaOneG3SE/via686.h"
+#include "../board/MAI/AmigaOneG3SE/memio.h"
+#endif
+
 cpu_t
 get_cpu_type(void)
 {
@@ -218,12 +223,20 @@ do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
 /*
  * For the 7400 the TB clock runs at 1/4 the cpu bus speed.
  */
-unsigned long
-get_tbclk (void)
+#ifdef CONFIG_AMIGAONEG3SE
+unsigned long get_tbclk(void)
 {
-	return CFG_BUS_HZ / 4;
+	DECLARE_GLOBAL_DATA_PTR;
+
+	return (gd->bus_clk / 4);
 }
+#else	/* ! CONFIG_AMIGAONEG3SE */
 
+unsigned long get_tbclk (void)
+{
+	return CFG_BUS_HZ / 4;
+}
+#endif	/* CONFIG_AMIGAONEG3SE */
 /* ------------------------------------------------------------------------- */
 
 #if defined(CONFIG_WATCHDOG)
diff --git a/cpu/74xx_7xx/interrupts.c b/cpu/74xx_7xx/interrupts.c
index 10450da1c56..2e2e45615db 100644
--- a/cpu/74xx_7xx/interrupts.c
+++ b/cpu/74xx_7xx/interrupts.c
@@ -89,7 +89,7 @@ disable_interrupts(void)
 
 int interrupt_init(void)
 {
-#ifdef DEBUG
+#if defined(DEBUG) && !defined(CONFIG_AMIGAONEG3SE)
 	printf("interrupt_init: GT main cause reg: %08x:%08x\n",
 	       GTREGREAD(LOW_INTERRUPT_CAUSE_REGISTER),
 	       GTREGREAD(HIGH_INTERRUPT_CAUSE_REGISTER));
diff --git a/cpu/74xx_7xx/speed.c b/cpu/74xx_7xx/speed.c
index fe553f125bb..ac99bcd5b35 100644
--- a/cpu/74xx_7xx/speed.c
+++ b/cpu/74xx_7xx/speed.c
@@ -25,6 +25,10 @@
 #include <74xx_7xx.h>
 #include <asm/processor.h>
 
+#ifdef CONFIG_AMIGAONEG3SE
+#include "../board/MAI/AmigaOneG3SE/via686.h"
+#endif
+
 static const int hid1_multipliers_x_10[] = {
 	25,	/* 0000 - 2.5x */
 	75,	/* 0001 - 7.5x */
diff --git a/cpu/74xx_7xx/traps.c b/cpu/74xx_7xx/traps.c
index 26db0974025..6e94601ccc5 100644
--- a/cpu/74xx_7xx/traps.c
+++ b/cpu/74xx_7xx/traps.c
@@ -45,7 +45,11 @@ extern unsigned long search_exception_table(unsigned long);
 
 /* THIS NEEDS CHANGING to use the board info structure.
 */
+#ifdef CONFIG_AMIGAONEG3SE
+#define END_OF_MEM (gd->bd->bi_memstart + gd->bd->bi_memsize)
+#else
 #define END_OF_MEM	0x02000000
+#endif
 
 /*
  * Trap & Exception support
@@ -54,6 +58,9 @@ extern unsigned long search_exception_table(unsigned long);
 void
 print_backtrace(unsigned long *sp)
 {
+#ifdef CONFIG_AMIGAONEG3SE
+	DECLARE_GLOBAL_DATA_PTR;
+#endif
 	int cnt = 0;
 	unsigned long i;
 
@@ -171,11 +178,25 @@ AlignmentException(struct pt_regs *regs)
 void
 ProgramCheckException(struct pt_regs *regs)
 {
+	unsigned char *p = regs ? (unsigned char *)(regs->nip) : NULL;
+	int i, j;
+
 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
 		return;
 #endif
 	show_regs(regs);
+
+	p = (unsigned char *) ((unsigned long)p & 0xFFFFFFE0);
+	p -= 32;
+	for (i = 0; i < 256; i+=16) {
+		printf("%08x: ", (unsigned int)p+i);
+		for (j = 0; j < 16; j++) {
+			printf("%02x ", p[i+j]);
+		}
+		printf("\n");
+	}
+
 	print_backtrace((unsigned long *)regs->gpr[1]);
 	panic("Program Check Exception");
 }
diff --git a/disk/Makefile b/disk/Makefile
index 7b80174f5b3..39677f1e2e0 100644
--- a/disk/Makefile
+++ b/disk/Makefile
@@ -27,7 +27,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= libdisk.a
 
-OBJS	= part.o part_mac.o part_dos.o part_iso.o
+OBJS	= part.o part_mac.o part_dos.o part_iso.o part_amiga.o
 
 all:	$(LIB)
 
diff --git a/disk/part.c b/disk/part.c
index 99fe0db9fa7..70511ca0654 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -106,7 +106,8 @@ void dev_print (block_dev_desc_t *dev_desc)
 
 #if defined(CONFIG_MAC_PARTITION) || \
     defined(CONFIG_DOS_PARTITION) || \
-    defined(CONFIG_ISO_PARTITION)
+    defined(CONFIG_ISO_PARTITION) || \
+    defined(CONFIG_AMIGA_PARTITION) 
 
 void init_part (block_dev_desc_t * dev_desc)
 {
@@ -130,6 +131,13 @@ void init_part (block_dev_desc_t * dev_desc)
 		return;
 	}
 #endif
+
+#ifdef CONFIG_AMIGA_PARTITION
+	if (test_part_amiga(dev_desc) == 0) {
+	    dev_desc->part_type = PART_TYPE_AMIGA;
+	    return;
+	}
+#endif
 }
 
 
@@ -162,6 +170,16 @@ int get_partition_info (block_dev_desc_t *dev_desc, int part, disk_partition_t *
 		}
 		break;
 #endif
+
+#ifdef CONFIG_AMIGA_PARTITION
+	case PART_TYPE_AMIGA:
+	    if (get_partition_info_amiga(dev_desc, part, info) == 0)
+	    {
+		PRINTF ("## Valid Amiga partition found ##\n");
+		return (0);
+	    }
+	    break;
+#endif
 	default:
 		break;
 	}
@@ -215,6 +233,14 @@ void print_part (block_dev_desc_t * dev_desc)
 		print_part_iso (dev_desc);
 		return;
 #endif
+
+#ifdef CONFIG_AMIGA_PARTITION
+	case PART_TYPE_AMIGA:
+	    PRINTF ("## Testing for a valid Amiga partition ##\n");
+	    print_part_header ("AMIGA", dev_desc);
+	    print_part_amiga (dev_desc);
+	    return;
+#endif
 	}
 	puts ("## Unknown partition table\n");
 }
diff --git a/disk/part_amiga.c b/disk/part_amiga.c
new file mode 100644
index 00000000000..aafbcd84cc4
--- /dev/null
+++ b/disk/part_amiga.c
@@ -0,0 +1,399 @@
+/*
+ * (C) Copyright 2001
+ * Hans-Joerg Frieden, Hyperion Entertainment 
+ * Hans-JoergF@hyperion-entertainment.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#include <common.h>
+#include <command.h>
+#include <ide.h>
+#include <cmd_disk.h>
+#include "part_amiga.h"
+
+#if ((CONFIG_COMMANDS & CFG_CMD_IDE) || (CONFIG_COMMANDS & CFG_CMD_SCSI)) && defined(CONFIG_AMIGA_PARTITION)
+
+#undef AMIGA_DEBUG
+
+#ifdef AMIGA_DEBUG
+#define PRINTF(fmt, args...) printf(fmt ,##args)
+#else
+#define PRINTF(fmt, args...)
+#endif
+
+struct block_header
+{
+    u32 id;
+    u32 summed_longs;
+    s32 chk_sum;
+};
+
+static unsigned char block_buffer[DEFAULT_SECTOR_SIZE];
+static struct rigid_disk_block rdb = {0};
+static struct bootcode_block bootcode = {0};
+
+/*
+ * Copy a bcpl to a c string
+ */
+static void bcpl_strcpy(char *to, char *from)
+{
+    int len = *from++;
+
+    while (len)
+    {
+	*to++ = *from++;
+	len--;
+    }
+    *to = 0;
+}
+
+/*
+ * Print a BCPL String. BCPL strings start with a byte with the length
+ * of the string, and don't contain a terminating nul character
+ */
+static void bstr_print(char *string)
+{
+    int len = *string++;
+    char buffer[256];
+    int i;
+    
+    i = 0;
+    while (len)
+    {
+	buffer[i++] = *string++;
+	len--;
+    }
+
+    buffer[i] = 0;
+    printf("%-10s", buffer);
+}
+
+/*
+ * Sum a block. The checksum of a block must end up at zero
+ * to be valid. The chk_sum field is selected so that adding
+ * it yields zero.
+ */
+int sum_block(struct block_header *header)
+{
+    s32 *block = (s32 *)header;
+    u32 i;
+    s32 sum = 0;
+
+    for (i = 0; i < header->summed_longs; i++)
+	sum += *block++;
+    
+    return (sum != 0);
+}
+
+/*
+ * Print an AmigaOS disk type. Disk types are a four-byte identifier
+ * describing the file system. They are usually written as a three-letter
+ * word followed by a backslash and a version number. For example,
+ * DOS\0 would be the original file system. SFS\0 would be SmartFileSystem.
+ * DOS\1 is FFS.
+ */
+static void print_disk_type(u32 disk_type)
+{
+    char buffer[6];
+    buffer[0] = (disk_type & 0xFF000000)>>24;
+    buffer[1] = (disk_type & 0x00FF0000)>>16;
+    buffer[2] = (disk_type & 0x0000FF00)>>8;
+    buffer[3] = '\\';
+    buffer[4] = (disk_type & 0x000000FF) + '0';
+    buffer[5] = 0;
+    printf("%s", buffer);
+}
+
+/*
+ * Print the info contained within the given partition block
+ */
+static void print_part_info(struct partition_block *p)
+{
+    struct amiga_part_geometry *g;
+    
+    g = (struct amiga_part_geometry *)&(p->environment);
+
+    bstr_print(p->drive_name);
+    printf("%6d\t%6d\t", 
+	   g->low_cyl * g->block_per_track * g->surfaces , 
+	   (g->high_cyl - g->low_cyl + 1) * g->block_per_track * g->surfaces - 1);
+    print_disk_type(g->dos_type);
+    printf("\t%5d\n", g->boot_priority);
+}
+
+/*
+ * Search for the Rigid Disk Block. The rigid disk block is required
+ * to be within the first 16 blocks of a drive, needs to have
+ * the ID AMIGA_ID_RDISK ('RDSK') and needs to have a valid
+ * sum-to-zero checksum
+ */
+struct rigid_disk_block *get_rdisk(block_dev_desc_t *dev_desc)
+{
+    int i;
+    int limit;
+    char *s;
+
+    s = getenv("amiga_scanlimit");
+    if (s)
+	limit = atoi(s);
+    else
+	limit = AMIGA_BLOCK_LIMIT;
+
+    for (i=0; i<limit; i++)
+    {
+	ulong res = dev_desc->block_read(dev_desc->dev, i, 1,
+					 (ulong *)block_buffer);
+	if (res == 1)
+	{
+	    struct rigid_disk_block *trdb = (struct rigid_disk_block *)block_buffer;
+	    if (trdb->id == AMIGA_ID_RDISK)
+	    {
+		PRINTF("Rigid disk block suspect at %d, checking checksum\n",i);
+		if (sum_block((struct block_header *)block_buffer) == 0)
+		{
+		    PRINTF("FOUND\n");
+		    memcpy(&rdb, trdb, sizeof(struct rigid_disk_block));
+		    return (struct rigid_disk_block *)&rdb;
+		}
+	    }
+	}
+    }
+    PRINTF("Done scanning, no RDB found\n");
+    return NULL;
+}
+
+/* 
+ * Search for boot code
+ * Again, the first boot block must be located somewhere in the first 16 blocks, or rooted in the
+ * Ridgid disk block
+ */
+
+struct bootcode_block *get_bootcode(block_dev_desc_t *dev_desc)
+{
+    int i;
+    int limit;
+    char *s;
+
+    s = getenv("amiga_scanlimit");
+    if (s)
+	limit = atoi(s);
+    else
+	limit = AMIGA_BLOCK_LIMIT;
+
+    PRINTF("Scanning for BOOT from 0 to %d\n", limit);
+
+    for (i = 0; i < limit; i++)
+    {
+	ulong res = dev_desc->block_read(dev_desc->dev, i, 1, (ulong *)block_buffer);
+	if (res == 1)
+	{
+	    struct bootcode_block *boot = (struct bootcode_block *)block_buffer;
+	    if (boot->id == AMIGA_ID_BOOT)
+	    {
+		PRINTF("BOOT block at %d, checking checksum\n", i);
+		if (sum_block((struct block_header *)block_buffer) == 0)
+		{
+		    PRINTF("Found valid bootcode block\n");
+		    memcpy(&bootcode, boot, sizeof(struct bootcode_block));
+		    return &bootcode;
+		}
+	    }
+	}
+    }
+
+    PRINTF("No boot code found on disk\n");
+    return 0;
+}
+
+/* 
+ * Test if the given partition has an Amiga partition table/Rigid
+ * Disk block
+ */
+int test_part_amiga(block_dev_desc_t *dev_desc)
+{
+    struct rigid_disk_block *rdb;
+    struct bootcode_block *bootcode;
+
+    PRINTF("test_part_amiga: Testing for an Amiga RDB partition\n");
+    
+    rdb = get_rdisk(dev_desc);
+    if (rdb)
+    {
+	bootcode = get_bootcode(dev_desc);
+	if (bootcode)
+	    PRINTF("test_part_amiga: bootable Amiga disk\n");
+	else
+	    PRINTF("test_part_amiga: non-bootable Amiga disk\n");
+
+	return 0;
+    }
+    else 
+    {
+	PRINTF("test_part_amiga: no RDB found\n");
+	return -1;
+    }
+
+}
+
+/* 
+ * Find partition number partnum on the given drive.
+ */
+static struct partition_block *find_partition(block_dev_desc_t *dev_desc, int partnum)
+{
+    struct rigid_disk_block *rdb;
+    struct partition_block *p;
+    u32 block;
+
+    PRINTF("Trying to find partition block %d\n", partnum);
+    rdb = get_rdisk(dev_desc);
+    if (!rdb) 
+    {
+	PRINTF("find_partition: no rdb found\n");
+	return NULL;
+    }
+    
+    PRINTF("find_partition: Scanning partition list\n");
+
+    block = rdb->partition_list;
+    PRINTF("find_partition: partition list at 0x%x\n", block);
+
+    while (block != 0xFFFFFFFF)
+    {
+	ulong res = dev_desc->block_read(dev_desc->dev, block, 1,
+					 (ulong *)block_buffer);
+	if (res == 1)
+	{
+	    p = (struct partition_block *)block_buffer;
+	    if (p->id == AMIGA_ID_PART)
+	    {
+		PRINTF("PART block suspect at 0x%x, checking checksum\n",block);
+		if (sum_block((struct block_header *)p) == 0)
+		{
+		    if (partnum == 0) break;
+		    else 
+		    {
+			partnum--;
+			block = p->next;
+		    }
+		}
+	    } else block = 0xFFFFFFFF;
+	} else block = 0xFFFFFFFF;
+    }
+
+    if (block == 0xFFFFFFFF) 
+    {
+	PRINTF("PART block not found\n");
+	return NULL;
+    }
+
+    return (struct partition_block *)block_buffer;
+}
+
+/* 
+ * Get info about a partition
+ */
+int get_partition_info_amiga (block_dev_desc_t *dev_desc, int part, disk_partition_t *info)
+{
+    struct partition_block *p = find_partition(dev_desc, part-1);
+    struct amiga_part_geometry *g;
+    u32 disk_type;
+
+    if (!p) return -1;
+
+    g = (struct amiga_part_geometry *)&(p->environment);
+    info->start = g->low_cyl  * g->block_per_track * g->surfaces;
+    info->size  = (g->high_cyl - g->low_cyl + 1) * g->block_per_track * g->surfaces - 1;
+    info->blksz = rdb.block_bytes;
+    bcpl_strcpy(info->name, p->drive_name);
+    
+
+    disk_type = g->dos_type;
+
+    info->type[0] = (disk_type & 0xFF000000)>>24;
+    info->type[1] = (disk_type & 0x00FF0000)>>16;
+    info->type[2] = (disk_type & 0x0000FF00)>>8;
+    info->type[3] = '\\';
+    info->type[4] = (disk_type & 0x000000FF) + '0';
+    info->type[5] = 0;
+   
+    return 0;
+}
+
+void print_part_amiga (block_dev_desc_t *dev_desc)
+{    
+    struct rigid_disk_block *rdb;
+    struct bootcode_block *boot;
+    struct partition_block *p;
+    u32 block;
+    int i = 1;
+
+    rdb = get_rdisk(dev_desc);
+    if (!rdb) 
+    {
+	PRINTF("print_part_amiga: no rdb found\n");
+	return;
+    }
+    
+    PRINTF("print_part_amiga: Scanning partition list\n");
+
+    block = rdb->partition_list;
+    PRINTF("print_part_amiga: partition list at 0x%x\n", block);
+
+    printf("Summary:  DiskBlockSize: %d\n"
+	   "          Cylinders    : %d\n"
+	   "          Sectors/Track: %d\n"
+	   "          Heads        : %d\n\n",
+	   rdb->block_bytes, rdb->cylinders, rdb->sectors,
+	   rdb->heads);
+
+    printf("                 First   Num. \n"
+	   "Nr.  Part. Name  Block   Block  Type        Boot Priority\n");
+
+    while (block != 0xFFFFFFFF)
+    {
+	ulong res;
+
+	PRINTF("Trying to load block #0x%X\n", block);
+	
+	res = dev_desc->block_read(dev_desc->dev, block, 1,
+				   (ulong *)block_buffer);
+	if (res == 1)
+	{
+	    p = (struct partition_block *)block_buffer;
+	    if (p->id == AMIGA_ID_PART)
+	    {
+		PRINTF("PART block suspect at 0x%x, checking checksum\n",block);
+		if (sum_block((struct block_header *)p) == 0)
+		{
+		    printf("%-4d ", i); i++;
+		    print_part_info(p);
+		    block = p->next;
+		}
+	    } else block = 0xFFFFFFFF;
+	} else block = 0xFFFFFFFF;
+    }
+
+    boot = get_bootcode(dev_desc);
+    if (boot)
+    {
+	printf("Disk is bootable\n");
+    }
+}
+
+#endif
diff --git a/disk/part_amiga.h b/disk/part_amiga.h
new file mode 100644
index 00000000000..9e59be9faa5
--- /dev/null
+++ b/disk/part_amiga.h
@@ -0,0 +1,157 @@
+/*
+ * (C) Copyright 2000
+ * Hans-Joerg Frieden, Hyperion Entertainment
+ * Hans-JoergF@hyperion-entertainment.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _DISK_PART_AMIGA_H
+#define _DISK_PART_AMIGA_H
+#include <common.h>
+
+#ifdef CONFIG_ISO_PARTITION
+/* Make the buffers bigger if ISO partition support is enabled -- CD-ROMS
+   have 2048 byte blocks */
+#define DEFAULT_SECTOR_SIZE   2048
+#else
+#define DEFAULT_SECTOR_SIZE	512
+#endif
+
+
+#define AMIGA_BLOCK_LIMIT 16
+
+/*
+ * Amiga disks have a very open structure. The head for the partition table information
+ * is stored somewhere within the first 16 blocks on disk, and is called the
+ * "RigidDiskBlock".
+ */
+
+struct rigid_disk_block 
+{
+    u32 id;
+    u32 summed_longs;
+    s32 chk_sum;
+    u32 host_id;
+    u32 block_bytes;
+    u32 flags;
+    u32 bad_block_list;
+    u32 partition_list;
+    u32 file_sys_header_list;
+    u32 drive_init;
+    u32 bootcode_block;
+    u32 reserved_1[5];
+    
+    /* Physical drive geometry */
+    u32 cylinders;
+    u32 sectors;
+    u32 heads;
+    u32 interleave;
+    u32 park;
+    u32 reserved_2[3];
+    u32 write_pre_comp;
+    u32 reduced_write;
+    u32 step_rate;
+    u32 reserved_3[5];
+
+    /* logical drive geometry */
+    u32 rdb_blocks_lo;
+    u32 rdb_blocks_hi;
+    u32 lo_cylinder;
+    u32 hi_cylinder;
+    u32 cyl_blocks;
+    u32 auto_park_seconds;
+    u32 high_rdsk_block;
+    u32 reserved_4;
+    
+    char disk_vendor[8];
+    char disk_product[16];
+    char disk_revision[4];
+    char controller_vendor[8];
+    char controller_product[16];
+    char controller_revision[4];
+    
+    u32 reserved_5[10];
+};
+
+/*
+ * Each partition on this drive is defined by such a block
+ */
+
+struct partition_block 
+{
+    u32 id;
+    u32 summed_longs;
+    s32 chk_sum;
+    u32 host_id;
+    u32 next;
+    u32 flags;
+    u32 reserved_1[2];
+    u32 dev_flags;
+    char drive_name[32];
+    u32 reserved_2[15];
+    u32 environment[17];
+    u32 reserved_3[15];
+};
+
+struct bootcode_block 
+{
+    u32   id;
+    u32   summed_longs;
+    s32   chk_sum;
+    u32   host_id;
+    u32   next;
+    u32   load_data[123];
+};
+
+
+#define AMIGA_ID_RDISK                  0x5244534B
+#define AMIGA_ID_PART                   0x50415254
+#define AMIGA_ID_BOOT                   0x424f4f54
+
+/* 
+ * The environment array in the partition block
+ * describes the partition
+ */
+
+struct amiga_part_geometry 
+{
+    u32 table_size;
+    u32 size_blocks;
+    u32 unused1;
+    u32 surfaces;
+    u32 sector_per_block;
+    u32 block_per_track;
+    u32 reserved;
+    u32 prealloc;
+    u32 interleave;
+    u32 low_cyl;
+    u32 high_cyl;
+    u32 num_buffers;
+    u32 buf_mem_type;
+    u32 max_transfer;
+    u32 mask;
+    s32 boot_priority;
+    u32 dos_type;
+    u32 baud;
+    u32 control;
+    u32 boot_blocks;
+};
+
+#endif /* _DISK_PART_AMIGA_H_ */
diff --git a/disk/part_dos.h b/disk/part_dos.h
index 1a5c3777b5c..cc3fa81d73b 100644
--- a/disk/part_dos.h
+++ b/disk/part_dos.h
@@ -25,7 +25,13 @@
 #define _DISK_PART_DOS_H
 
 
+#ifdef CONFIG_ISO_PARTITION
+/* Make the buffers bigger if ISO partition support is enabled -- CD-ROMS
+   have 2048 byte blocks */
+#define DEFAULT_SECTOR_SIZE   2048
+#else
 #define DEFAULT_SECTOR_SIZE	512
+#endif
 #define DOS_PART_TBL_OFFSET	0x1be
 #define DOS_PART_MAGIC_OFFSET	0x1fe
 
diff --git a/disk/part_iso.c b/disk/part_iso.c
index a98539da469..72259274c17 100644
--- a/disk/part_iso.c
+++ b/disk/part_iso.c
@@ -97,6 +97,7 @@ int get_partition_info_iso_verb(block_dev_desc_t * dev_desc, int part_num, disk_
 	info->blksz=ppr->secsize_BE; /* assuming same block size for all entries */
 	PRINTF(" Lastsect:%08lx\n",lastsect);
 	for(i=blkaddr;i<lastsect;i++) {
+		PRINTF("Reading block %d\n", i);
 		if (dev_desc->block_read (dev_desc->dev, i, 1, (ulong *) tmpbuf) != 1)
   	 	return (-1);
 		if(ppr->desctype==0x00)
diff --git a/disk/part_mac.h b/disk/part_mac.h
index 0340fe8febd..fb1edac561e 100644
--- a/disk/part_mac.h
+++ b/disk/part_mac.h
@@ -89,6 +89,9 @@ typedef struct mac_partition {
 	__u32	boot_cksum;	/* boot code checksum			*/
 	uchar	processor[16];	/* Type of Processor			*/
 	__u16	part_pad[188];	/* reserved				*/
+#ifdef CONFIG_ISO_PARTITION
+        uchar   iso_dummy[2048];/* Reservere enough room for an ISO partition block to fit */ 
+#endif
 } mac_partition_t;
 
 #define MAC_STATUS_BOOTABLE	8	/* partition is bootable */
diff --git a/doc/README.amigaone b/doc/README.amigaone
new file mode 100644
index 00000000000..99759779171
--- /dev/null
+++ b/doc/README.amigaone
@@ -0,0 +1,12 @@
+AmigaOne U-Boot and the SciTech emulator
+
+The directory board/MAI/bios_emulator contains the source code
+of the SciTech x86 emulator. This emulator is normally available
+under a BSD license. However, SciTech kindly gave us permission
+to use their emulator in PPCBoot for the AmigaOne. It's available
+in this form only under GPL.
+
+Thanks to Kendall Bennett and the rest of the team at SciTech.
+See http://www.scitechsoft.com for their web site
+
+The GPL license can be found at http://www.gnu.org/licenses/gpl.html
diff --git a/drivers/pci.c b/drivers/pci.c
index 52584ce62bf..dc58abfe484 100644
--- a/drivers/pci.c
+++ b/drivers/pci.c
@@ -421,8 +421,11 @@ void pci_cfgfunc_do_nothing(struct pci_controller *hose,
  *
  */
 
+/* HJF: Changed this to return int. I think this is required
+ * to get the correct result when scanning bridges
+ */
+extern int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev);
 extern void pciauto_config_init(struct pci_controller *hose);
-extern void pciauto_config_device(struct pci_controller *hose, pci_dev_t dev);
 
 int pci_hose_scan_bus(struct pci_controller *hose, int bus)
 {
@@ -451,8 +454,7 @@ int pci_hose_scan_bus(struct pci_controller *hose, int bus)
 
 		pci_hose_read_config_word(hose, dev, PCI_VENDOR_ID, &vendor);
 
-		if (vendor != 0xffff && vendor != 0x0000)
-		{
+		if (vendor != 0xffff && vendor != 0x0000) {
 
 			if (!PCI_FUNC(dev))
 				found_multi = header_type & 0x80;
@@ -465,12 +467,15 @@ int pci_hose_scan_bus(struct pci_controller *hose, int bus)
 
 			cfg = pci_find_config(hose, class, vendor, device,
 					      PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev));
-			if (cfg)
+			if (cfg) {
 				cfg->config_device(hose, dev, cfg);
 #ifdef CONFIG_PCI_PNP
-			else
-				pciauto_config_device(hose, dev);
+			} else {
+				int n = pciauto_config_device(hose, dev);
+
+				sub_bus = max(sub_bus, n);
 #endif
+			}
 			if (hose->fixup_irq)
 				hose->fixup_irq(hose, dev);
 
diff --git a/drivers/pci_auto.c b/drivers/pci_auto.c
index f665ee6fec6..295f7c848d2 100644
--- a/drivers/pci_auto.c
+++ b/drivers/pci_auto.c
@@ -277,11 +277,15 @@ void pciauto_config_init(struct pci_controller *hose)
 	}
 }
 
-void pciauto_config_device(struct pci_controller *hose, pci_dev_t dev)
+/* HJF: Changed this to return int. I think this is required
+ * to get the correct result when scanning bridges
+ */
+int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev)
 {
-	unsigned int sub_bus;
+	unsigned int sub_bus = PCI_BUS(dev);
 	unsigned short class;
 	unsigned char prg_iface;
+	int n;
 
 	pci_hose_read_config_word(hose, dev, PCI_CLASS_DEVICE, &class);
 
@@ -290,13 +294,25 @@ void pciauto_config_device(struct pci_controller *hose, pci_dev_t dev)
 	case PCI_CLASS_BRIDGE_PCI:
 		pciauto_setup_device(hose, dev, 2, hose->pci_mem, hose->pci_io);
 
-		DEBUGF("PCI Autoconfig: Found P2P bridge, device %d\n", PCI_DEV(dev));
+		DEBUGF("PCI Autoconfig: Found P2P bridge, device %d\n",
+			PCI_DEV(dev));
+
+		/* HJF: Make sure two bridges on the same bus
+		 * won't get the same bus number
+		 */
+		pciauto_prescan_setup_bridge(hose, dev,
+				max(sub_bus, hose->current_busno));
 
-		pciauto_prescan_setup_bridge(hose, dev, PCI_BUS(dev));
+		n = pci_hose_scan_bus(hose, hose->current_busno+1 /*PCI_BUS(dev)+1*/);
+		sub_bus = max(sub_bus, n);
+		sub_bus = max(sub_bus, hose->current_busno);
 
-		sub_bus = pci_hose_scan_bus(hose, PCI_BUS(dev)+1);
+		DEBUGF("PCI Autoconfig: Got %d from pci_hose_scan_bus\n",
+			sub_bus);
 
-		pciauto_postscan_setup_bridge(hose, dev, sub_bus);
+		pciauto_postscan_setup_bridge(hose, dev,
+				max(sub_bus, hose->current_busno));
+		hose->current_busno++;
 		break;
 
 	case PCI_CLASS_STORAGE_IDE:
@@ -304,7 +320,7 @@ void pciauto_config_device(struct pci_controller *hose, pci_dev_t dev)
 		if (!(prg_iface & PCIAUTO_IDE_MODE_MASK))
 			{
 				DEBUGF("PCI Autoconfig: Skipping legacy mode IDE controller\n");
-				return;
+				return sub_bus;
 			}
 
 		pciauto_setup_device(hose, dev, 6, hose->pci_mem, hose->pci_io);
@@ -314,6 +330,8 @@ void pciauto_config_device(struct pci_controller *hose, pci_dev_t dev)
 		pciauto_setup_device(hose, dev, 6, hose->pci_mem, hose->pci_io);
 		break;
 	}
+
+	return sub_bus;
 }
 
 #endif /* CONFIG_PCI */
diff --git a/examples/syscall.S b/examples/syscall.S
index 9934490433d..a952fd7744c 100644
--- a/examples/syscall.S
+++ b/examples/syscall.S
@@ -75,4 +75,6 @@ name:				; \
 	SYSCALL(mon_free_hdlr,SYSCALL_FREE_HDLR)
 	SYSCALL(mon_malloc,SYSCALL_MALLOC)
 	SYSCALL(mon_free,SYSCALL_FREE)
+	SYSCALL(mon_udelay,SYSCALL_UDELAY)
+	SYSCALL(mon_get_timer,SYSCALL_GET_TIMER)
 #endif /* CONFIG_ARM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
diff --git a/include/asm-ppc/global_data.h b/include/asm-ppc/global_data.h
index 7cf234d1847..34701803ffe 100644
--- a/include/asm-ppc/global_data.h
+++ b/include/asm-ppc/global_data.h
@@ -62,6 +62,9 @@ typedef	struct	global_data {
 #if defined(CONFIG_SANDPOINT) || defined(CONFIG_MUSENKI)
 	void *		console_addr;
 #endif
+#ifdef CONFIG_AMIGAONEG3SE
+	unsigned long	relocaddr;	/* Start address of U-Boot in RAM */
+#endif
 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
 	unsigned long	fb_base;	/* Base address of framebuffer memory	*/
 #endif
diff --git a/include/cmd_boota.h b/include/cmd_boota.h
new file mode 100644
index 00000000000..3ec31183b4a
--- /dev/null
+++ b/include/cmd_boota.h
@@ -0,0 +1,42 @@
+/*
+ * (C) Copyright 2001
+ * Thomas Frieden, Hyperion Entertainment
+ * ThomasF@hyperion-entertainment.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#ifndef _CMD_BOOTA_H
+#define _CMD_BOOTA_H
+
+#include <common.h>
+#include <command.h>
+
+#if defined(CONFIG_AMIGAONEG3SE) && (CONFIG_COMMANDS & CFG_CMD_BSP)
+#define CMD_TBL_BOOTA     MK_CMD_TBL_ENTRY(                      \
+        "boota", 5,   3,      1,      do_boota,                   \
+        "boota   - boot an Amiga kernel\n",                     \
+        "address disk"                                        \
+),
+
+int do_boota (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] );
+#else
+#define CMD_TBL_BOOTA
+#endif
+
+#endif /* _CMD_BOOTA_H */
diff --git a/include/cmd_bsp.h b/include/cmd_bsp.h
index b39d50bd27c..e4b10414b34 100644
--- a/include/cmd_bsp.h
+++ b/include/cmd_bsp.h
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2001
+ * (C) Copyright 2001, 2002
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * See file CREDITS for list of people who contributed to this
@@ -29,7 +29,7 @@
 
 #if (CONFIG_COMMANDS & CFG_CMD_BSP)
 
-/* ----- LWMON -----------------------------------------------------------------
+/* ----- LWMON ---------------------------------------------------------
  */
 #if defined(CONFIG_LWMON)
 
@@ -54,10 +54,9 @@ int do_kbd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 int do_lsb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 
 #endif	/* CONFIG_LWMON */
-/* ----------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------	*/
 
-/* ----- PCU E -----------------------------------------------------------------
- */
+/* ----- PCU E -------------------------------------------------------- */
 #if defined(CONFIG_PCU_E)
 
 #define CMD_TBL_BSP	MK_CMD_TBL_ENTRY(					\
@@ -69,10 +68,9 @@ int do_lsb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 int do_puma (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 
 #endif	/* CONFIG_PCU_E */
-/* ----------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------	*/
 
-/* ----- CCM/SCM ---------------------------------------------------------------
- */
+/* ----- CCM/SCM ------------------------------------------------------ */
 #if defined(CONFIG_CCM) || defined(CONFIG_SCM)
 
 #define CMD_TBL_BSP	MK_CMD_TBL_ENTRY(					\
@@ -85,10 +83,9 @@ int do_puma (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 int do_fpga (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 
 #endif	/* CONFIG_CCM, CONFIG_SCM */
-/* ----------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------	*/
 
-/* ----- PIP405 -----------------------------------------------------------------
- */
+/* ----- PIP405 ------------------------------------------------------- */
 #if defined(CONFIG_PIP405)
 
 #define	CMD_TBL_BSP MK_CMD_TBL_ENTRY(				\
@@ -101,9 +98,9 @@ int do_fpga (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 int do_pip405 (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 
 #endif /* CONFIG_PIP405 */
-/* ----------------------------------------------------------------------------*/
-/* ----- MIP405 -----------------------------------------------------------------
- */
+/* --------------------------------------------------------------------	*/
+
+/* ----- MIP405 ------------------------------------------------------- */
 #if defined(CONFIG_MIP405)
 
 #define	CMD_TBL_BSP MK_CMD_TBL_ENTRY(				\
@@ -115,10 +112,9 @@ int do_pip405 (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 int do_mip405 (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 
 #endif /* CONFIG_MIP405 */
-/* ----------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------	*/
 
-/* ----- DASA_SIM ---------------------------------------------------------------
- */
+/* ----- DASA_SIM ----------------------------------------------------- */
 #if defined(CONFIG_DASA_SIM)
 
 #define	CMD_TBL_BSP MK_CMD_TBL_ENTRY(				                \
@@ -130,10 +126,9 @@ int do_mip405 (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 int do_pci9054 (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 
 #endif /* CONFIG_DASA_SIM */
-/* ----------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------	*/
 
-/* ----- HYMOD -----------------------------------------------------------------
- */
+/* ----- HYMOD -------------------------------------------------------- */
 #if defined(CONFIG_HYMOD)
 
 #define	CMD_TBL_BSP	MK_CMD_TBL_ENTRY(				\
@@ -171,8 +166,9 @@ int do_fpga (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 int do_eecl (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 
 #endif	/* CONFIG_HYMOD */
-/* ----------------------------------------------------------------------------*/
-/* CRAY405 (L1) */
+/* --------------------------------------------------------------------	*/
+
+/* ----- CRAY405 (L1) ------------------------------------------------- */
 #if defined (CONFIG_CRAYL1)
 #define	CMD_TBL_BSP MK_CMD_TBL_ENTRY(						\
 	"L1cmd",	5,	4,	1,	do_crayL1,			\
@@ -182,10 +178,10 @@ int do_eecl (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 ),
 int do_crayL1 (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 #endif /* CONFIG_CRAY405 */
-/* ----------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------	*/
 
+/* ----- EVB64260 ----------------------------------------------------- */
 #if defined (CONFIG_EVB64260)
-/* ----- EVB64260 -------------------------------------------------------------*/
 #ifdef CONFIG_ZUMA_V2
 #define CMD_TBL_BSP  ZUMA_TBL_ENTRY
 
@@ -218,9 +214,9 @@ int zuma_test_dma(int cmd, int size);
 #endif /* ZUMA_NTL */
 
 #endif /* CONFIG_EVB64260 */
-/* ----------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------	*/
 
-/* -----W7O--------------------------------------------------------------------*/
+/* -----W7O------------------------------------------------------------ */
 #if defined(CONFIG_W7O)
 
 #define CMD_TBL_BSP MK_CMD_TBL_ENTRY(			\
@@ -233,18 +229,18 @@ int zuma_test_dma(int cmd, int size);
 extern int do_vpd (cmd_tbl_t *, int, int, char *[]);
 
 #endif	/* CONFIG_W7O */
-/* ----------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------	*/
 
-/* ---- PCIPPC2 / PCIPPC6 -----------------------------------------------------*/
+/* ---- PCIPPC2 / PCIPPC6 --------------------------------------------- */
 #if defined(CONFIG_PCIPPC2) || defined(CONFIG_PCIPPC6)
 #if defined(CONFIG_WATCHDOG)
 
 #define CMD_TBL_BSP MK_CMD_TBL_ENTRY(			\
-	"wd",	3,	2,	1,	do_wd,					\
-	"wd      - check and set watchdog\n",					\
-	"on   - switch watchDog on\n"							\
-	"wd off  - switch watchdog off\n"						\
-	"wd      - print current status\n"					\
+	"wd",	3,	2,	1,	do_wd,		\
+	"wd      - check and set watchdog\n",		\
+	"on   - switch watchDog on\n"			\
+	"wd off  - switch watchdog off\n"		\
+	"wd      - print current status\n"		\
 ),
 
 extern int do_wd (cmd_tbl_t *, int, int, char *[]);
@@ -254,9 +250,9 @@ extern int do_wd (cmd_tbl_t *, int, int, char *[]);
 #endif  /* CONFIG_WATCHDOG */
 
 #endif	/* CONFIG_PCIPPC2 , CONFIG_PCIPPC6 */
-/* ----------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------	*/
 
-/* ----- PN62 -----------------------------------------------------------------*/
+/* ----- PN62 --------------------------------------------------------- */
 #if defined(CONFIG_PN62)
 
 #define CMD_TBL_BSP MK_CMD_TBL_ENTRY(				\
@@ -274,40 +270,46 @@ extern int do_wd (cmd_tbl_t *, int, int, char *[]);
 extern int do_loadpci (cmd_tbl_t *, int, int, char *[]);
 extern int do_led (cmd_tbl_t *, int, int, char *[]);
 #endif /* CONFIG_PN62 */
-/* ----------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------	*/
 
-/* ----- TRAB ------------------------------------------------------------------
- */
+/* ----- TRAB --------------------------------------------------------- */
 #if defined(CONFIG_TRAB)
 
-#define	CMD_TBL_BSP	MK_CMD_TBL_ENTRY(					\
-	"kbd",	3,	1,	1,	do_kbd,					\
-	"kbd     - read keyboard status\n",					\
-	NULL									\
+#define	CMD_TBL_BSP	MK_CMD_TBL_ENTRY(			\
+	"kbd",	3,	1,	1,	do_kbd,			\
+	"kbd     - read keyboard status\n",			\
+	NULL							\
 ),
 
 int do_kbd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 
 #endif	/* CONFIG_TRAB */
-/* ----------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------	*/
 
-#else
-#define CMD_TBL_BSP
-#endif	/* CFG_CMD_BSP */
-
-/* ----- R360MPI ---------------------------------------------------------------
- */
+/* ----- R360MPI ------------------------------------------------------ */
 #if defined(CONFIG_R360MPI)
 
-#define	CMD_TBL_BSP	MK_CMD_TBL_ENTRY(					\
-	"kbd",	3,	1,	1,	do_kbd,					\
-	"kbd     - read keyboard status\n",					\
-	NULL									\
+#define	CMD_TBL_BSP	MK_CMD_TBL_ENTRY(			\
+	"kbd",	3,	1,	1,	do_kbd,			\
+	"kbd     - read keyboard status\n",			\
+	NULL							\
 ),
 
 int do_kbd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 
 #endif	/* CONFIG_R360MPI */
-/* ----------------------------------------------------------------------------*/
+/* --------------------------------------------------------------------	*/
+
+/* ------ AMIGAONEG3SE ------------------------------------------------ */
+#if defined(CONFIG_AMIGAONEG3SE)
+
+#define CMD_TBL_BSP	/* dummy */
+
+#endif  /* AmigaOneG3SE */
+/* -------------------------------------------------------------------- */
+
+#else
+#define CMD_TBL_BSP
+#endif	/* CFG_CMD_BSP */
 
 #endif	/* _CMD_BSP_H_ */
diff --git a/include/cmd_confdefs.h b/include/cmd_confdefs.h
index 25f386b95cc..c462c3f425d 100644
--- a/include/cmd_confdefs.h
+++ b/include/cmd_confdefs.h
@@ -12,7 +12,7 @@
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
@@ -24,8 +24,8 @@
 /*
  *  Definitions for Configuring the monitor commands
  */
-#ifndef	_CMD_CONFIG_H
-#define	_CMD_CONFIG_H
+#ifndef _CMD_CONFIG_H
+#define _CMD_CONFIG_H
 
 /*
  * Configurable monitor commands
@@ -42,27 +42,27 @@
 #define CFG_CMD_ENV		0x00000100	/* saveenv			*/
 #define CFG_CMD_KGDB		0x00000200	/* kgdb				*/
 #define CFG_CMD_PCMCIA		0x00000400	/* PCMCIA support		*/
-#define	CFG_CMD_IDE		0x00000800	/* IDE harddisk support		*/
-#define	CFG_CMD_PCI		0x00001000	/* pciinfo			*/
-#define	CFG_CMD_IRQ		0x00002000	/* irqinfo			*/
+#define CFG_CMD_IDE		0x00000800	/* IDE harddisk support		*/
+#define CFG_CMD_PCI		0x00001000	/* pciinfo			*/
+#define CFG_CMD_IRQ		0x00002000	/* irqinfo			*/
 #define CFG_CMD_BOOTD		0x00004000	/* bootd			*/
 #define CFG_CMD_CONSOLE		0x00008000	/* coninfo			*/
 #define CFG_CMD_EEPROM		0x00010000	/* EEPROM read/write support	*/
-#define	CFG_CMD_ASKENV		0x00020000	/* ask for env variable		*/
-#define	CFG_CMD_RUN		0x00040000	/* run command in env variable	*/
-#define	CFG_CMD_ECHO		0x00080000	/* echo arguments		*/
-#define	CFG_CMD_I2C		0x00100000	/* I2C serial bus support	*/
-#define	CFG_CMD_REGINFO		0x00200000	/* Register dump		*/
-#define	CFG_CMD_IMMAP		0x00400000	/* IMMR dump support		*/
-#define	CFG_CMD_DATE		0x00800000	/* support for RTC, date/time...*/
+#define CFG_CMD_ASKENV		0x00020000	/* ask for env variable		*/
+#define CFG_CMD_RUN		0x00040000	/* run command in env variable	*/
+#define CFG_CMD_ECHO		0x00080000	/* echo arguments		*/
+#define CFG_CMD_I2C		0x00100000	/* I2C serial bus support	*/
+#define CFG_CMD_REGINFO		0x00200000	/* Register dump		*/
+#define CFG_CMD_IMMAP		0x00400000	/* IMMR dump support		*/
+#define CFG_CMD_DATE		0x00800000	/* support for RTC, date/time...*/
 #define CFG_CMD_DHCP		0x01000000	/* DHCP Support			*/
 #define CFG_CMD_BEDBUG		0x02000000	/* Include BedBug Debugger	*/
-#define	CFG_CMD_FDC		0x04000000	/* Floppy Disk Support		*/
-#define	CFG_CMD_SCSI		0x08000000	/* SCSI Support			*/
-#define	CFG_CMD_AUTOSCRIPT	0x10000000	/* Autoscript Support		*/
-#define	CFG_CMD_MII		0x20000000	/* MII support			*/
+#define CFG_CMD_FDC		0x04000000	/* Floppy Disk Support		*/
+#define CFG_CMD_SCSI		0x08000000	/* SCSI Support			*/
+#define CFG_CMD_AUTOSCRIPT	0x10000000	/* Autoscript Support		*/
+#define CFG_CMD_MII		0x20000000	/* MII support			*/
 #define CFG_CMD_SETGETDCR	0x40000000	/* DCR support on 4xx		*/
-#define	CFG_CMD_BSP		0x80000000	/* Board Specific functions	*/
+#define CFG_CMD_BSP		0x80000000	/* Board Specific functions	*/
 
 #define CFG_CMD_ELF	0x0000000100000000	/* ELF (VxWorks) load/boot cmd	*/
 #define CFG_CMD_MISC	0x0000000200000000	/* Misc functions like sleep etc*/
@@ -70,13 +70,14 @@
 #define CFG_CMD_DOC	0x0000000800000000	/* Disk-On-Chip Support		*/
 #define CFG_CMD_JFFS2	0x0000001000000000	/* JFFS2 Support		*/
 #define CFG_CMD_DTT	0x0000002000000000	/* Digital Therm and Thermostat */
-#define CFG_CMD_SDRAM	0x0000004000000000	/* SDRAM DIMM SPD info printout	*/
+#define CFG_CMD_SDRAM	0x0000004000000000	/* SDRAM DIMM SPD info printout */
 #define CFG_CMD_DIAG	0x0000008000000000	/* Diagnostics			*/
-#define CFG_CMD_FPGA	0x0000010000000000	/* FPGA configuration Support   */
+#define CFG_CMD_FPGA	0x0000010000000000	/* FPGA configuration Support	*/
 #define CFG_CMD_HWFLOW	0x0000020000000000	/* RTS/CTS hw flow control	*/
 #define CFG_CMD_SAVES	0x0000040000000000	/* save S record dump		*/
 #define CFG_CMD_SPI	0x0000100000000000	/* SPI utility			*/
-#define CFG_CMD_FDOS    0x0000200000000000      /* Floppy DOS support           */
+#define CFG_CMD_FDOS	0x0000200000000000	/* Floppy DOS support		*/
+#define CFG_CMD_VFD	0x0000400000000000	/* VFD support (TRAB)		*/
 
 #define CFG_CMD_ALL	0xFFFFFFFFFFFFFFFF	/* ALL commands			*/
 
@@ -96,7 +97,7 @@
 			CFG_CMD_EEPROM	| \
 			CFG_CMD_ELF	| \
 			CFG_CMD_FDC	| \
-                        CFG_CMD_FDOS    | \
+			CFG_CMD_FDOS	| \
 			CFG_CMD_HWFLOW	| \
 			CFG_CMD_I2C	| \
 			CFG_CMD_IDE	| \
@@ -107,7 +108,7 @@
 			CFG_CMD_MII	| \
 			CFG_CMD_PCI	| \
 			CFG_CMD_PCMCIA	| \
-			CFG_CMD_REGINFO	| \
+			CFG_CMD_REGINFO | \
 			CFG_CMD_SAVES	| \
 			CFG_CMD_SCSI	| \
 			CFG_CMD_SDRAM	| \
@@ -117,10 +118,10 @@
 
 /* Default configuration
  */
-#define	CONFIG_CMD_DFL	(CFG_CMD_ALL & ~CFG_CMD_NONSTD)
+#define CONFIG_CMD_DFL	(CFG_CMD_ALL & ~CFG_CMD_NONSTD)
 
 #ifndef CONFIG_COMMANDS
-#define CONFIG_COMMANDS	CONFIG_CMD_DFL
+#define CONFIG_COMMANDS CONFIG_CMD_DFL
 #endif
 
 
diff --git a/include/cmd_menu.h b/include/cmd_menu.h
new file mode 100644
index 00000000000..ad1bd7fdc18
--- /dev/null
+++ b/include/cmd_menu.h
@@ -0,0 +1,42 @@
+/*
+ * (C) Copyright 2001
+ * Hans-Jörg Frieden, Hyperion Entertainment
+ * Hans-JoergF@hyperion-entertainment.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#ifndef _CMD_MENU_H
+#define _CMD_MENU_H
+
+#include <common.h>
+#include <command.h>
+
+#if defined(CONFIG_AMIGAONEG3SE) && (CONFIG_COMMANDS & CFG_CMD_BSP)
+#define CMD_TBL_MENU     MK_CMD_TBL_ENTRY(                      \
+        "menu", 3,   1,      1,      do_menu,                   \
+        "menu    - display BIOS setup menu\n",                     \
+        ""                                                      \
+),
+
+int do_menu( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] );
+#else
+#define CMD_TBL_MENU
+#endif
+
+#endif /* _CMD_MENU_H */
diff --git a/include/common.h b/include/common.h
index a950cdcc40c..d9d5702a97c 100644
--- a/include/common.h
+++ b/include/common.h
@@ -80,6 +80,18 @@ typedef	void (interrupt_handler_t)(void *);
 #endif
 
 
+/*
+ * General Purpose Utilities
+ */
+#define min(X, Y)				\
+	({ typeof (X) __x = (X), __y = (Y);	\
+		(__x < __y) ? __x : __y; })
+
+#define max(X, Y)				\
+	({ typeof (X) __x = (X), __y = (Y);	\
+		(__x > __y) ? __x : __y; })
+
+
 /*
  * Function Prototypes
  */
diff --git a/include/configs/AmigaOneG3SE.h b/include/configs/AmigaOneG3SE.h
new file mode 100644
index 00000000000..7e40c533482
--- /dev/null
+++ b/include/configs/AmigaOneG3SE.h
@@ -0,0 +1,383 @@
+/*
+ * (C) Copyright 2002
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ *
+ * Configuration settings for the AmigaOneG3SE board.
+ *
+ */
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * board/config.h - configuration options, board specific
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * High Level Configuration Options
+ * (easy to change)
+ */
+
+#define CONFIG_AMIGAONEG3SE	1
+
+#define CONFIG_BOARD_PRE_INIT	1
+#define CONFIG_MISC_INIT_R	1
+
+#define CONFIG_VERY_BIG_RAM	1
+
+#define CONFIG_CONS_INDEX	1
+#define CONFIG_BAUDRATE		9600
+#define CFG_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, 115200 }
+
+#undef CONFIG_CLOCKS_IN_MHZ		/* clocks passed to Linux in Hz */
+
+#define CONFIG_BOOTARGS		"root=/dev/ram rw ramdisk=4096"
+
+#define CONFIG_BOOTP_MASK	(CONFIG_BOOTP_DEFAULT | \
+				 CONFIG_BOOTP_BOOTFILESIZE)
+
+#define CONFIG_MAC_PARTITION
+#define CONFIG_DOS_PARTITION
+#define CONFIG_AMIGA_PARTITION
+
+#define CONFIG_COMMANDS		(CONFIG_CMD_DFL | \
+				 CFG_CMD_ASKENV | \
+				 CFG_CMD_BSP	| \
+				 CFG_CMD_DATE	| \
+				 CFG_CMD_DHCP	| \
+				 CFG_CMD_ELF	| \
+				 CFG_CMD_NET	| \
+				 CFG_CMD_IDE	| \
+				 CFG_CMD_FDC	| \
+				 CFG_CMD_CACHE	| \
+				 CFG_CMD_CONSOLE| \
+				 CFG_CMD_USB	| \
+				 CFG_CMD_BSP	| \
+				 CFG_CMD_PCI	)
+
+/*				    CFG_CMD_MII	   | \ */
+
+#define CONFIG_PCI		1
+/* #define CONFIG_PCI_SCAN_SHOW 1 */
+#define CONFIG_PCI_PNP		1	/* PCI plug-and-play */
+
+/* This must be included AFTER the definition of CONFIG_COMMANDS (if any)
+ */
+#include <cmd_confdefs.h>
+
+
+/*
+ * Miscellaneous configurable options
+ */
+#define CFG_LONGHELP			/* undef to save memory		*/
+#define CFG_PROMPT	"=> "		/* Monitor Command Prompt	*/
+
+#define CFG_HUSH_PARSER		1	/* use "hush" command parser	*/
+/* #undef CFG_HUSH_PARSER */
+#ifdef	CFG_HUSH_PARSER
+#define CFG_PROMPT_HUSH_PS2	"> "
+#endif
+#define CFG_CBSIZE	1024		/* Console I/O Buffer Size	*/
+
+/* Print Buffer Size
+ */
+#define CFG_PBSIZE	(CFG_CBSIZE + sizeof(CFG_PROMPT) + 16)
+
+#define CFG_MAXARGS	64		/* max number of command args	*/
+#define CFG_BARGSIZE	CFG_CBSIZE	/* Boot Argument Buffer Size	*/
+#define CFG_LOAD_ADDR	0x00500000	/* Default load address		*/
+
+/*-----------------------------------------------------------------------
+ * Start addresses for the final memory configuration
+ * (Set up by the startup code)
+ * Please note that CFG_SDRAM_BASE _must_ start at 0
+ */
+#define CFG_SDRAM_BASE	    0x00000000
+#define CFG_FLASH_BASE	    0xFFF00000
+#define CFG_FLASH_MAX_SIZE  0x00080000
+/* Maximum amount of RAM.
+ */
+#define CFG_MAX_RAM_SIZE    0x80000000	/* 2G			*/
+
+#define CFG_RESET_ADDRESS   0xFFF00100
+
+#define CFG_MONITOR_BASE    TEXT_BASE
+
+#define CFG_MONITOR_LEN	    (768 << 10) /* Reserve 512 kB for Monitor	*/
+#define CFG_MALLOC_LEN	    (2500 << 10) /* Reserve 128 kB for malloc() */
+
+#if CFG_MONITOR_BASE >= CFG_SDRAM_BASE && \
+    CFG_MONITOR_BASE < CFG_SDRAM_BASE + CFG_MAX_RAM_SIZE
+#define CFG_RAMBOOT
+#else
+#undef CFG_RAMBOOT
+#endif
+
+#define CFG_MEMTEST_START	0x00004000	/* memtest works on	*/
+#define CFG_MEMTEST_END		0x02000000	/* 0 ... 32 MB in DRAM	*/
+
+/*-----------------------------------------------------------------------
+ * Definitions for initial stack pointer and data area
+ */
+
+/* Size in bytes reserved for initial data
+ */
+#define CFG_INIT_RAM_ADDR	0x400000
+#define CFG_INIT_RAM_END	0x8000
+#define CFG_GBL_DATA_SIZE	128
+#define CFG_GBL_DATA_OFFSET	(CFG_INIT_RAM_END - CFG_GBL_DATA_SIZE)
+#define CFG_INIT_SP_OFFSET	CFG_GBL_DATA_OFFSET
+
+#define CFG_INIT_RAM_LOCK
+
+/*
+ * Temporary buffer for serial data until the real serial driver
+ * is initialised (memtest will destroy this buffer)
+ */
+#define CFG_SCONSOLE_ADDR     CFG_INIT_RAM_ADDR
+#define CFG_SCONSOLE_SIZE     0x0002000
+
+/* SDRAM 0 - 256MB
+ */
+
+#define CFG_IBAT0L (CFG_SDRAM_BASE | BATL_PP_RW | BATL_CACHEINHIBIT)
+#define CFG_IBAT0U (CFG_SDRAM_BASE | BATU_BL_4M | BATU_VS | BATU_VP)
+#define CFG_DBAT0L (CFG_SDRAM_BASE | BATL_PP_RW | BATL_CACHEINHIBIT)
+#define CFG_DBAT0U CFG_IBAT0U
+
+/* SDRAM 1 - 256MB
+ */
+#define CFG_IBAT1L ((CFG_SDRAM_BASE+CFG_INIT_RAM_ADDR) | BATL_PP_RW) /* | BATL_CACHEINHIBIT) */
+#define CFG_IBAT1U ((CFG_SDRAM_BASE+CFG_INIT_RAM_ADDR) | BATU_BL_256M | BATU_VS | BATU_VP)
+#define CFG_DBAT1L ((CFG_SDRAM_BASE+CFG_INIT_RAM_ADDR + 0x20000) | BATL_PP_RW ) /* | BATL_CACHEINHIBIT) */
+#define CFG_DBAT1U ((CFG_SDRAM_BASE+CFG_INIT_RAM_ADDR + 0x20000) | BATU_BL_256M | BATU_VS | BATU_VP)
+
+/* Init RAM in the CPU DCache (no backing memory)
+ */
+#define CFG_DBAT2L	(CFG_INIT_RAM_ADDR | BATL_PP_RW | BATL_MEMCOHERENCE)
+#define CFG_DBAT2U	(CFG_INIT_RAM_ADDR | BATU_BL_128K | BATU_VS | BATU_VP)
+#define CFG_IBAT2L	0 /* CFG_DBAT2L */
+#define CFG_IBAT2U	0 /* CFG_DBAT2U */
+
+/* I/O and PCI memory at 0xf0000000
+ */
+#define CFG_DBAT3L	(0xf0000000 | BATL_PP_RW | BATL_CACHEINHIBIT | BATL_GUARDEDSTORAGE)
+#define CFG_DBAT3U	(0xf0000000 | BATU_BL_256M | BATU_VS | BATU_VP)
+
+#define CFG_IBAT3L	(0xf0000000 | BATL_PP_RW | BATL_CACHEINHIBIT)
+#define CFG_IBAT3U	(0xf0000000 | BATU_BL_256M | BATU_VS | BATU_VP)
+
+/*
+ * Low Level Configuration Settings
+ * (address mappings, register initial values, etc.)
+ */
+#define CFG_HZ		1000
+#define CFG_BUS_HZ	133000000 /* bus speed - 100 mhz		*/
+#define CFG_CPU_CLK	133000000
+#define CFG_BUS_CLK	133000000
+
+/*
+ * For booting Linux, the board info and command line data
+ * have to be in the first 8 MB of memory, since this is
+ * the maximum mapped by the Linux kernel during initialization.
+ */
+#define CFG_BOOTMAPSZ	(8 << 20) /* Initial Memory map for Linux */
+
+/*-----------------------------------------------------------------------
+ * FLASH organization
+ */
+#define CFG_MAX_FLASH_BANKS	1	/* Max number of flash banks		*/
+#define CFG_MAX_FLASH_SECT	8	/* Max number of sectors in one bank	*/
+
+#define CFG_FLASH_ERASE_TOUT	120000	/* Timeout for Flash Erase (in ms)	*/
+#define CFG_FLASH_WRITE_TOUT	1000	/* Timeout for Flash Write (in ms)	*/
+
+/*
+ * Environment is stored in NVRAM.
+ */
+#define CFG_ENV_IS_IN_NVRAM	1
+#define CFG_ENV_ADDR		0xFD0E0000 /* This should be 0xFD0E0000, but we skip bytes to
+					    * protect softex's settings for now.
+					    * Original 768 bytes where not enough.
+					    */
+#define CFG_ENV_SIZE		0x8000	   /* Size of the Environment. See comment above */
+
+#define CFG_CONSOLE_IS_IN_ENV	1 /* stdin/stdout/stderr are in environment */
+#define CFG_CONSOLE_OVERWRITE_ROUTINE	1
+#define CONFIG_ENV_OVERWRITE 1
+
+/*-----------------------------------------------------------------------
+ * Cache Configuration
+ */
+#define CFG_CACHELINE_SIZE	32
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#  define CFG_CACHELINE_SHIFT	5	/* log base 2 of the above value	*/
+#endif
+
+/*
+ * L2 cache
+ */
+#define CFG_L2
+#define L2_INIT	  (L2CR_L2SIZ_2M | L2CR_L2CLK_3 | L2CR_L2RAM_BURST | \
+		   L2CR_L2OH_5 | L2CR_L2CTL | L2CR_L2WT)
+#define L2_ENABLE (L2_INIT | L2CR_L2E)
+
+/*
+ * Internal Definitions
+ *
+ * Boot Flags
+ */
+#define BOOTFLAG_COLD		0x01	/* Normal Power-On: Boot from FLASH	*/
+#define BOOTFLAG_WARM		0x02	/* Software reboot			*/
+
+
+/*-----------------------------------------------------------------------
+ * IDE ATAPI Configuration
+ */
+
+#define CONFIG_ATAPI		1
+#define CFG_IDE_MAXBUS		2
+#define CFG_IDE_MAXDEVICE	4
+#define CONFIG_ISO_PARTITION	1
+
+#define CFG_ATA_BASE_ADDR	0xFE000000  /* was: via_get_base_addr() */
+#define CFG_ATA_IDE0_OFFSET	0x1F0
+#define CFG_ATA_IDE1_OFFSET	0x170
+
+#define CFG_ATA_REG_OFFSET	0
+#define CFG_ATA_DATA_OFFSET	0
+#define CFG_ATA_ALT_OFFSET	0x0200
+
+/*-----------------------------------------------------------------------
+ * Disk-On-Chip configuration
+ */
+
+#define CFG_MAX_DOC_DEVICE	1	/* Max number of DOC devices		*/
+
+#define CFG_DOC_SUPPORT_2000
+#undef CFG_DOC_SUPPORT_MILLENNIUM
+
+/*-----------------------------------------------------------------------
+  RTC
+*/
+#define CONFIG_RTC_MC146818
+
+/*-----------------------------------------------------------------------
+ * NS16550 Configuration
+ */
+
+#define CFG_NS16550
+
+#define CFG_NS16550_COM1 0xFE0003F8
+#define CFG_NS16550_COM2 0xFE0002F8
+
+#define CFG_NS16550_REG_SIZE 1
+
+/* base address for ISA I/O
+ */
+#define CFG_ISA_IO_BASE_ADDRESS 0xFE000000
+
+/* ISA Interrupt stuff (taken from JWL) */
+
+#define ISA_INT1_OCW1		0x21
+#define ISA_INT2_OCW1		0xA1
+#define ISA_INT1_OCW2		0x20
+#define ISA_INT2_OCW2		0xA0
+#define ISA_INT1_OCW3		0x20
+#define ISA_INT2_OCW3		0xA0
+
+#define ISA_INT1_ICW1		0x20
+#define ISA_INT2_ICW1		0xA0
+#define ISA_INT1_ICW2		0x21
+#define ISA_INT2_ICW2		0xA1
+#define ISA_INT1_ICW3		0x21
+#define ISA_INT2_ICW3		0xA1
+#define ISA_INT1_ICW4		0x21
+#define ISA_INT2_ICW4		0xA1
+
+
+/*
+ * misc
+ */
+
+#define CONFIG_NET_MULTI
+#define CFG_BOARD_ASM_INIT
+#define CONFIG_LAST_STAGE_INIT
+
+/* #define CONFIG_ETHADDR	00:09:D2:10:00:76 */
+/* #define CONFIG_IPADDR	192.168.0.2 */
+/* #define CONFIG_NETMASK	255.255.255.240 */
+/* #define CONFIG_GATEWAYIP	192.168.0.3 */
+
+#define CONFIG_3COM
+/* #define CONFIG_BOOTP_RANDOM_DELAY */
+#define CONFIG_BOOTP_MASK	(CONFIG_BOOTP_DEFAULT | \
+				 CONFIG_BOOTP_BOOTFILESIZE)
+
+/*
+ * USB configuration
+ */
+#define CONFIG_USB_UHCI		1
+#define CONFIG_USB_STORAGE	1
+#define CONFIG_USB_KEYBOARD	1
+#define CFG_DEVICE_DEREGISTER	1 /* needed by CONFIG_USB_KEYBOARD */
+
+/*
+ * Autoboot stuff
+ */
+#define CONFIG_BOOTDELAY	5 /* Boot automatically after five seconds */
+#define CONFIG_PREBOOT		""
+#define CONFIG_BOOTCOMMAND	"fdcboot; diskboot"
+#define CONFIG_MENUPROMPT	"Press any key to interrupt autoboot: %2d "
+#define CONFIG_MENUKEY		' '
+#define CONFIG_MENUCOMMAND	"menu"
+/* #define CONFIG_AUTOBOOT_KEYED */
+
+/*
+ * Extra ENV stuff
+ */
+#define CONFIG_EXTRA_ENV_SETTINGS		\
+	"stdout=vga\0"				\
+	"stdin=ps2kbd\0"			\
+	"ide_doreset=on\0"			\
+	"ide_maxbus=2\0"			\
+	"ide_cd_timeout=30\0"			\
+	"menucmd=menu\0"			\
+	"pci_irqa=9\0"				\
+	"pci_irqa_select=edge\0"		\
+	"pci_irqb=10\0"				\
+	"pci_irqb_select=edge\0"		\
+	"pci_irqc=11\0"				\
+	"pci_irqc_select=edge\0"		\
+	"pci_irqd=12\0"				\
+	"pci_irqd_select=edge\0"
+
+
+/* #define CONFIG_MII		1 */
+/* #define CONFIG_BITBANGMII	1 */
+
+
+#endif	/* __CONFIG_H */
diff --git a/include/configs/sbc8260.h b/include/configs/sbc8260.h
index ec6017938d7..d47c208f163 100644
--- a/include/configs/sbc8260.h
+++ b/include/configs/sbc8260.h
@@ -239,12 +239,12 @@
 #endif /* CONFIG_ETHER_ON_FCC, CONFIG_ETHER_INDEX */
 
 /*
- * select SPI support configuration
+ * Select SPI support configuration
  */
-#undef  CONFIG_SPI			/* enable SPI driver		*/
+#undef  CONFIG_SPI			/* Disable SPI driver */
 
 /*
- * select i2c support configuration
+ * Select i2c support configuration
  *
  * Supported configurations are {none, software, hardware} drivers.
  * If the software driver is chosen, there are some additional
@@ -284,7 +284,10 @@
 /* What should the console's baud rate be? */
 #define CONFIG_BAUDRATE		9600
 
-/* Ethernet MAC address */
+/* Ethernet MAC address 
+ *     Note: We are using the EST Corporation OUI (00:a0:1e:xx:xx:xx)
+ *           http://standards.ieee.org/regauth/oui/index.shtml
+ */
 #define CONFIG_ETHADDR		00:a0:1e:a8:7b:cb
 
 /*
@@ -299,19 +302,53 @@
 /* Set to a positive value to delay for running BOOTCOMMAND */
 #define CONFIG_BOOTDELAY	5	/* autoboot after 5 seconds */
 
-#if 0
 /* Be selective on what keys can delay or stop the autoboot process
  *     To stop	use: " "
  */
-# define CONFIG_AUTOBOOT_KEYED
-# define CONFIG_AUTOBOOT_PROMPT "Autobooting in %d seconds, press \" \" to stop\n"
-# define CONFIG_AUTOBOOT_STOP_STR	" "
-# undef CONFIG_AUTOBOOT_DELAY_STR
-# define DEBUG_BOOTKEYS		0
+#undef CONFIG_AUTOBOOT_KEYED
+#ifdef CONFIG_AUTOBOOT_KEYED
+#   define CONFIG_AUTOBOOT_PROMPT	"Autobooting in %d seconds, press \" \" to stop\n"
+#   define CONFIG_AUTOBOOT_STOP_STR	" "
+#   undef  CONFIG_AUTOBOOT_DELAY_STR
+#   define DEBUG_BOOTKEYS		0
 #endif
 
 /* Define this to contain any number of null terminated strings that
  * will be part of the default enviroment compiled into the boot image.
+ * 
+ * Variable		Usage
+ * --------------       -------------------------------------------------------
+ * serverip		server IP address 
+ * ipaddr		my IP address
+ * reprog		Reload flash with a new copy of U-Boot
+ * zapenv		Erase the environment area in flash
+ * root-on-initrd       Set the bootcmd variable to allow booting of an initial
+ *                      ram disk.
+ * root-on-nfs          Set the bootcmd variable to allow booting of a NFS 
+ *                      mounted root filesystem.
+ * boot-hook            Convenient stub to do something useful before the 
+ *                      bootm command is executed.
+ * 
+ * Example usage of root-on-initrd and root-on-nfs :
+ *
+ * Note: The lines have been wrapped to improved its readability.
+ *
+ * => printenv bootcmd
+ * bootcmd=version;echo;bootp;setenv bootargs root=/dev/nfs rw
+ * nfsroot=$(serverip):$(rootpath) 
+ * ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname)::off;run boot-hook;bootm
+ *
+ * => run root-on-initrd
+ * => printenv bootcmd
+ * bootcmd=version;echo;bootp;setenv bootargs root=/dev/ram0 rw
+ * ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname)::off;run boot-hook;bootm
+ * 
+ * => run root-on-nfs
+ * => printenv bootcmd
+ * bootcmd=version;echo;bootp;setenv bootargs root=/dev/nfs rw
+ * nfsroot=$(serverip):$(rootpath) 
+ * ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname)::off;run boot-hook;bootm
+ *
  */
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"serverip=192.168.123.201\0" \
@@ -328,22 +365,22 @@
 		"protect on 1:1\0" \
 	"root-on-initrd="\
 		"setenv bootcmd "\
-		"version;" \
-		"echo;" \
-		"bootp;" \
+		"version\\;" \
+		"echo\\;" \
+		"bootp\\;" \
 		"setenv bootargs root=/dev/ram0 rw " \
-		"ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname)::off;" \
-		"run boot-hook;" \
+		"ip=\\$(ipaddr):\\$(serverip):\\$(gatewayip):\\$(netmask):\\$(hostname)::off\\;" \
+		"run boot-hook\\;" \
 		"bootm\0" \
 	"root-on-nfs="\
 		"setenv bootcmd "\
-		"version;" \
-		"echo;" \
-		"bootp;" \
+		"version\\;" \
+		"echo\\;" \
+		"bootp\\;" \
 		"setenv bootargs root=/dev/nfs rw " \
-		"nfsroot=$(serverip):$(rootpath) " \
-		"ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname)::off\\;" \
-		"run boot-hook;" \
+		"nfsroot=\\$(serverip):\\$(rootpath) " \
+		"ip=\\$(ipaddr):\\$(serverip):\\$(gatewayip):\\$(netmask):\\$(hostname)::off\\;" \
+		"run boot-hook\\;" \
 		"bootm\0" \
 	"boot-hook=echo boot-hook\0"
 
diff --git a/include/part.h b/include/part.h
index e43978c658d..9aa9f5ab455 100644
--- a/include/part.h
+++ b/include/part.h
@@ -51,6 +51,8 @@ typedef struct block_dev_desc {
 #define PART_TYPE_MAC		0x01
 #define PART_TYPE_DOS		0x02
 #define PART_TYPE_ISO		0x03
+#define PART_TYPE_AMIGA         0x04
+
 /* device types */
 #define DEV_TYPE_UNKNOWN 0xff /* not connected */
 #define DEV_TYPE_HARDDISK 0x00 /* harddisk */
@@ -94,6 +96,13 @@ void print_part_iso (block_dev_desc_t *dev_desc);
 int   test_part_iso (block_dev_desc_t *dev_desc);
 #endif
 
+#ifdef CONFIG_AMIGA_PARTITION
+/* disk/part_amiga.c */
+int get_partition_info_amiga (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
+void print_part_amiga (block_dev_desc_t *dev_desc);
+int   test_part_amiga (block_dev_desc_t *dev_desc);
+#endif
+
 #endif /* _PART_H */
 
 
diff --git a/include/pci.h b/include/pci.h
index 48753752674..e5055b17534 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -375,6 +375,7 @@ struct pci_controller {
 
 	/* Used by ppc405 autoconfig*/
 	struct pci_region *pci_fb;
+	int current_busno;
 };
 
 extern __inline__ void pci_set_ops(struct pci_controller *hose,
@@ -457,7 +458,7 @@ extern void pciauto_setup_device(struct pci_controller *hose,
 				 pci_dev_t dev, int bars_num,
 				 struct pci_region *mem,
 				 struct pci_region *io);
-void pciauto_config_device(struct pci_controller *hose, pci_dev_t dev);
+int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev);
 
 extern pci_dev_t pci_find_device (unsigned int vendor, unsigned int device, int index);
 extern pci_dev_t pci_find_devices (struct pci_device_id *ids, int index);
diff --git a/include/syscall.h b/include/syscall.h
index f80d550ee8d..9b9be0dd517 100644
--- a/include/syscall.h
+++ b/include/syscall.h
@@ -15,10 +15,13 @@ void mon_install_hdlr(int, interrupt_handler_t*, void*);
 void mon_free_hdlr(int);
 void *mon_malloc(size_t);
 void mon_free(void*);
+void mon_udelay(unsigned long);
+unsigned long mon_get_timer(unsigned long);
 
 #endif    /* ifndef __ASSEMBLY__ */
 
-#define NR_SYSCALLS            9        /* number of syscalls */
+#define NR_SYSCALLS            11        /* number of syscalls */
+
 
 /*
  * Make sure these functions are in the same order as they
@@ -33,5 +36,7 @@ void mon_free(void*);
 #define SYSCALL_FREE_HDLR      6
 #define SYSCALL_MALLOC         7
 #define SYSCALL_FREE           8
+#define SYSCALL_UDELAY         9
+#define SYSCALL_GET_TIMER     10
 
 #endif
diff --git a/lib_ppc/board.c b/lib_ppc/board.c
index bfc494ef8e2..2541a54e3aa 100644
--- a/lib_ppc/board.c
+++ b/lib_ppc/board.c
@@ -149,6 +149,8 @@ static void syscalls_init (void)
 
 	syscall_tbl[SYSCALL_INSTALL_HDLR] = (void *) irq_install_handler;
 	syscall_tbl[SYSCALL_FREE_HDLR] = (void *) irq_free_handler;
+	syscall_tbl[SYSCALL_GET_TIMER] = (void *)get_timer;
+	syscall_tbl[SYSCALL_UDELAY] = (void *)udelay;
 
 	addr = (ulong *) 0xc00;		/* syscall ISR addr */
 
@@ -420,6 +422,10 @@ void board_init_f (ulong bootflag)
 	printf ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
 #endif
 
+#ifdef CONFIG_AMIGAONEG3SE
+	gd->relocaddr = addr;
+#endif
+
 	/*
 	 * reserve memory for malloc() arena
 	 */
diff --git a/net/eth.c b/net/eth.c
index c2dbb934279..cb394337c8c 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -35,6 +35,7 @@ extern int eepro100_initialize(bd_t*);
 extern int natsemi_initialize(bd_t*);
 extern int ns8382x_initialize(bd_t*);
 extern int dc21x4x_initialize(bd_t*);
+extern int eth_3com_initialize(bd_t*);
 extern int pcnet_initialize(bd_t*);
 extern int fec_initialize(bd_t*);
 extern int scc_initialize(bd_t*);
@@ -100,6 +101,9 @@ int eth_initialize(bd_t *bis)
 #ifdef CONFIG_TULIP
 	dc21x4x_initialize(bis);
 #endif
+#ifdef CONFIG_3COM
+	eth_3com_initialize(bis);
+#endif
 #ifdef CONFIG_PCNET
 	pcnet_initialize(bis);
 #endif
diff --git a/rtc/mc146818.c b/rtc/mc146818.c
index 1d65808f79d..20b1b3e7702 100644
--- a/rtc/mc146818.c
+++ b/rtc/mc146818.c
@@ -69,10 +69,13 @@ void rtc_get (struct rtc_time *tmp)
 	wday	= rtc_read (RTC_DAY_OF_WEEK);
 	mon		= rtc_read (RTC_MONTH);
 	year	= rtc_read (RTC_YEAR);
+#ifdef CONFIG_AMIGAONEG3SE
+	wday -= 1; /* VIA 686 stores Sunday = 1, Monday = 2, ... */
+#endif
 #ifdef RTC_DEBUG
 	printf ( "Get RTC year: %02x mon/cent: %02x mday: %02x wday: %02x "
 		"hr: %02x min: %02x sec: %02x\n",
-		year, mon_cent, mday, wday,
+		year, mon, mday, wday,
 		hour, min, sec );
 	printf ( "Alarms: month: %02x hour: %02x min: %02x sec: %02x\n",
 		rtc_read (RTC_CONFIG_D) & 0x3F,
@@ -111,8 +114,11 @@ void rtc_set (struct rtc_time *tmp)
 
 	rtc_write (RTC_YEAR, bin2bcd(tmp->tm_year % 100));
 	rtc_write (RTC_MONTH, bin2bcd(tmp->tm_mon));
-
+#ifdef CONFIG_AMIGAONEG3SE
+	rtc_write (RTC_DAY_OF_WEEK, bin2bcd(tmp->tm_wday)+1);
+#else
 	rtc_write (RTC_DAY_OF_WEEK, bin2bcd(tmp->tm_wday));
+#endif
 	rtc_write (RTC_DATE_OF_MONTH, bin2bcd(tmp->tm_mday));
 	rtc_write (RTC_HOURS, bin2bcd(tmp->tm_hour));
 	rtc_write (RTC_MINUTES, bin2bcd(tmp->tm_min ));
diff --git a/rtc/mk48t59.c b/rtc/mk48t59.c
index 2d3c278e6e0..664d310d43d 100644
--- a/rtc/mk48t59.c
+++ b/rtc/mk48t59.c
@@ -65,6 +65,24 @@ static void rtc_write (short reg, uchar val)
 	out8(RTC(reg),val);
 }
 
+#elif defined(CONFIG_AMIGAONEG3SE)
+
+#include "../board/MAI/AmigaOneG3SE/via686.h"
+#include "../board/MAI/AmigaOneG3SE/memio.h"
+
+
+static uchar rtc_read (short reg)
+{
+    out_byte(CMOS_ADDR, (uint8)reg);
+    return in_byte(CMOS_DATA);
+}
+
+static void rtc_write (short reg, uchar val)
+{
+    out_byte(CMOS_ADDR, (uint8)reg);
+    out_byte(CMOS_DATA, (uint8)val);
+}
+
 #else
 # error Board specific rtc access functions should be supplied
 #endif
diff --git a/tools/updater/Makefile b/tools/updater/Makefile
new file mode 100644
index 00000000000..a8fb4ced3d2
--- /dev/null
+++ b/tools/updater/Makefile
@@ -0,0 +1,86 @@
+#
+# (C) Copyright 2000
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+LOAD_ADDR = 0x40000
+
+include $(TOPDIR)/config.mk
+
+PROG    = updater
+IMAGE   = updater.image
+SRC     = update.c flash.c flash_hw.c utils.c cmd_flash.c string.c ctype.c dummy.c
+ASRC    = ppcstring.S
+OBJS	= $(SRC:.c=.o) $(ASRC:.S=.o) 
+
+LIB	= $(TOPDIR)/examples/libsyscall.a 
+LIBAOBJS= $(TOPDIR)/examples/syscall.o
+LIBCOBJS=
+LIBOBJS	= $(LIBAOBJS) $(LIBCOBJS)
+
+CPPFLAGS += -I$(TOPDIR) -I$(TOPDIR)/board/MAI/AmigaOneG3SE
+CFLAGS   += -I$(TOPDIR)/board/MAI/AmigaOneG3SE
+
+all:	.depend $(LIB) $(PROG)
+
+#########################################################################
+$(LIB): .depend $(LIBOBJS)
+	$(AR) crv $@ $(LIBOBJS)
+
+%.srec:	%.o $(LIB)
+	$(LD) -g -Ttext $(LOAD_ADDR) -o $(<:.o=) -e $(<:.o=) $< $(LIB)
+	$(OBJCOPY) -O srec $(<:.o=) $@
+
+%.o: %.c
+	$(CC) $(CPPFLAGS) -c $< 
+
+%.o: %.S
+	$(CC) $(CPPFLAGS) -c $<
+
+#########################################################################
+
+updater: $(OBJS) $(LIB) $(TOPDIR)/board/MAI/AmigaOneG3SE/memio.o 
+	$(LD) -g -Ttext $(LOAD_ADDR) -o updater -e _main $(OBJS) $(LIB)  \
+	$(TOPDIR)/board/MAI/AmigaOneG3SE/memio.o
+	$(OBJCOPY) -O binary updater updater.bin
+
+updater.image: updater $(TOPDIR)/u-boot.bin
+	cat >/tmp/tempimage updater.bin junk $(TOPDIR)/u-boot.bin
+	$(TOPDIR)/tools/mkimage -A ppc -O u-boot -T standalone -C none -a $(LOAD_ADDR) \
+	-e `ppc-elf32-nm updater | grep _main | cut --bytes=0-8` \
+	-n "Firmware Updater" -d /tmp/tempimage updater.image
+	rm /tmp/tempimage
+	cp updater.image /tftpboot
+
+updater.image2: updater $(TOPDIR)/u-boot.bin
+	cat >/tmp/tempimage updater.bin junk ../../create_image/image
+	$(TOPDIR)/tools/mkimage -A ppc -O u-boot -T standalone -C none -a $(LOAD_ADDR) \
+	-e `ppc-elf32-nm updater | grep _main | cut --bytes=0-8` \
+	-n "Firmware Updater" -d /tmp/tempimage updater.image
+	rm /tmp/tempimage
+	cp updater.image /tftpboot
+
+.depend:	Makefile $(SRC) $(ASRC) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
+		$(CC) -M $(CFLAGS) $(SRC) $(ASRC) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S) > $@
+
+sinclude .depend
+
+#########################################################################
diff --git a/tools/updater/cmd_flash.c b/tools/updater/cmd_flash.c
new file mode 100644
index 00000000000..f3465f1d5b1
--- /dev/null
+++ b/tools/updater/cmd_flash.c
@@ -0,0 +1,431 @@
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * FLASH support
+ */
+#include <common.h>
+#include <command.h>
+#include <cmd_boot.h>
+#include <flash.h>
+
+#if (CONFIG_COMMANDS & CFG_CMD_FLASH)
+
+extern flash_info_t flash_info[];	/* info for FLASH chips */
+
+/*
+ * The user interface starts numbering for Flash banks with 1
+ * for historical reasons.
+ */
+
+/*
+ * this routine looks for an abbreviated flash range specification.
+ * the syntax is B:SF[-SL], where B is the bank number, SF is the first
+ * sector to erase, and SL is the last sector to erase (defaults to SF).
+ * bank numbers start at 1 to be consistent with other specs, sector numbers
+ * start at zero.
+ *
+ * returns:	1	- correct spec; *pinfo, *psf and *psl are
+ *			  set appropriately
+ *		0	- doesn't look like an abbreviated spec
+ *		-1	- looks like an abbreviated spec, but got
+ *			  a parsing error, a number out of range,
+ *			  or an invalid flash bank.
+ */
+static int
+abbrev_spec(char *str, flash_info_t **pinfo, int *psf, int *psl)
+{
+    flash_info_t *fp;
+    int bank, first, last;
+    char *p, *ep;
+
+    if ((p = strchr(str, ':')) == NULL)
+	return 0;
+    *p++ = '\0';
+
+    bank = simple_strtoul(str, &ep, 10);
+    if (ep == str || *ep != '\0' ||
+      bank < 1 || bank > CFG_MAX_FLASH_BANKS ||
+      (fp = &flash_info[bank - 1])->flash_id == FLASH_UNKNOWN)
+	return -1;
+
+    str = p;
+    if ((p = strchr(str, '-')) != NULL)
+	*p++ = '\0';
+
+    first = simple_strtoul(str, &ep, 10);
+    if (ep == str || *ep != '\0' || first >= fp->sector_count)
+	return -1;
+
+    if (p != NULL) {
+	last = simple_strtoul(p, &ep, 10);
+	if (ep == p || *ep != '\0' ||
+	  last < first || last >= fp->sector_count)
+	    return -1;
+    }
+    else
+	last = first;
+
+    *pinfo = fp;
+    *psf = first;
+    *psl = last;
+
+    return 1;
+}
+int do_flinfo (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+{
+	ulong bank;
+
+	if (argc == 1) {	/* print info for all FLASH banks */
+		for (bank=0; bank <CFG_MAX_FLASH_BANKS; ++bank) {
+			mon_printf ("\nBank # %ld: ", bank+1);
+
+			flash_print_info (&flash_info[bank]);
+		}
+		return 0;
+	}
+
+	bank = simple_strtoul(argv[1], NULL, 16);
+	if ((bank < 1) || (bank > CFG_MAX_FLASH_BANKS)) {
+		mon_printf ("Only FLASH Banks # 1 ... # %d supported\n",
+			CFG_MAX_FLASH_BANKS);
+		return 1;
+	}
+	mon_printf ("\nBank # %ld: ", bank);
+	flash_print_info (&flash_info[bank-1]);
+	return 0;
+}
+int do_flerase(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+{
+	flash_info_t *info;
+	ulong bank, addr_first, addr_last;
+	int n, sect_first, sect_last;
+	int rcode = 0;
+
+	if (argc < 2) {
+		mon_printf ("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+	}
+
+	if (strcmp(argv[1], "all") == 0) {
+		for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) {
+			mon_printf ("Erase Flash Bank # %ld ", bank);
+			info = &flash_info[bank-1];
+			rcode = flash_erase (info, 0, info->sector_count-1);
+		}
+		return rcode;
+	}
+
+	if ((n = abbrev_spec(argv[1], &info, &sect_first, &sect_last)) != 0) {
+		if (n < 0) {
+			mon_printf("Bad sector specification\n");
+			return 1;
+		}
+		mon_printf ("Erase Flash Sectors %d-%d in Bank # %d ",
+			sect_first, sect_last, (info-flash_info)+1);
+		rcode = flash_erase(info, sect_first, sect_last);
+		return rcode;
+	}
+
+	if (argc != 3) {
+		mon_printf ("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+	}
+
+	if (strcmp(argv[1], "bank") == 0) {
+		bank = simple_strtoul(argv[2], NULL, 16);
+		if ((bank < 1) || (bank > CFG_MAX_FLASH_BANKS)) {
+			mon_printf ("Only FLASH Banks # 1 ... # %d supported\n",
+				CFG_MAX_FLASH_BANKS);
+			return 1;
+		}
+		mon_printf ("Erase Flash Bank # %ld ", bank);
+		info = &flash_info[bank-1];
+		rcode = flash_erase (info, 0, info->sector_count-1);
+		return rcode;
+	}
+
+	addr_first = simple_strtoul(argv[1], NULL, 16);
+	addr_last  = simple_strtoul(argv[2], NULL, 16);
+
+	if (addr_first >= addr_last) {
+		mon_printf ("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+	}
+
+	mon_printf ("Erase Flash from 0x%08lx to 0x%08lx ", addr_first, addr_last);
+	rcode = flash_sect_erase(addr_first, addr_last);
+	return rcode;
+}
+
+int flash_sect_erase (ulong addr_first, ulong addr_last)
+{
+	flash_info_t *info;
+	ulong bank;
+	int s_first, s_last;
+	int erased;
+	int rcode = 0;
+
+	erased = 0;
+
+	for (bank=0,info=&flash_info[0]; bank < CFG_MAX_FLASH_BANKS; ++bank, ++info) {
+		ulong b_end;
+		int sect;
+
+		if (info->flash_id == FLASH_UNKNOWN) {
+			continue;
+		}
+
+		b_end = info->start[0] + info->size - 1; /* bank end addr */
+
+		s_first = -1;		/* first sector to erase	*/
+		s_last  = -1;		/* last  sector to erase	*/
+
+		for (sect=0; sect < info->sector_count; ++sect) {
+			ulong end;		/* last address in current sect	*/
+			short s_end;
+
+			s_end = info->sector_count - 1;
+
+			end = (sect == s_end) ? b_end : info->start[sect + 1] - 1;
+
+			if (addr_first > end)
+				continue;
+			if (addr_last < info->start[sect])
+				continue;
+
+			if (addr_first == info->start[sect]) {
+				s_first = sect;
+			}
+			if (addr_last  == end) {
+				s_last  = sect;
+			}
+		}
+		if (s_first>=0 && s_first<=s_last) {
+			erased += s_last - s_first + 1;
+			rcode = flash_erase (info, s_first, s_last);
+		}
+	}
+	if (erased) {
+	    //	mon_printf ("Erased %d sectors\n", erased);
+	} else {
+		mon_printf ("Error: start and/or end address"
+			" not on sector boundary\n");
+		rcode = 1;
+	}
+	return rcode;
+}
+
+
+int do_protect(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+{
+	flash_info_t *info;
+	ulong bank, addr_first, addr_last;
+	int i, p, n, sect_first, sect_last;
+	int rcode = 0;
+
+	if (argc < 3) {
+		mon_printf ("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+	}
+
+	if (strcmp(argv[1], "off") == 0)
+		p = 0;
+	else if (strcmp(argv[1], "on") == 0)
+		p = 1;
+	else {
+		mon_printf ("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+	}
+
+	if (strcmp(argv[2], "all") == 0) {
+		for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) {
+			info = &flash_info[bank-1];
+			if (info->flash_id == FLASH_UNKNOWN) {
+				continue;
+			}
+			//mon_printf ("%sProtect Flash Bank # %ld\n",
+			//	p ? "" : "Un-", bank);
+
+			for (i=0; i<info->sector_count; ++i) {
+#if defined(CFG_FLASH_PROTECTION)
+				if (flash_real_protect(info, i, p))
+					rcode = 1;
+				putc ('.');
+#else
+				info->protect[i] = p;
+#endif	/* CFG_FLASH_PROTECTION */
+			}
+		}
+
+#if defined(CFG_FLASH_PROTECTION)
+		if (!rcode) puts (" done\n");
+#endif	/* CFG_FLASH_PROTECTION */
+
+		return rcode;
+	}
+
+	if ((n = abbrev_spec(argv[2], &info, &sect_first, &sect_last)) != 0) {
+		if (n < 0) {
+			mon_printf("Bad sector specification\n");
+			return 1;
+		}
+		//mon_printf("%sProtect Flash Sectors %d-%d in Bank # %d\n",
+		//	p ? "" : "Un-", sect_first, sect_last,
+		//	(info-flash_info)+1);
+		for (i = sect_first; i <= sect_last; i++) {
+#if defined(CFG_FLASH_PROTECTION)
+			if (flash_real_protect(info, i, p))
+				rcode =  1;
+			putc ('.');
+#else
+			info->protect[i] = p;
+#endif	/* CFG_FLASH_PROTECTION */
+		}
+
+#if defined(CFG_FLASH_PROTECTION)
+		if (!rcode) puts (" done\n");
+#endif	/* CFG_FLASH_PROTECTION */
+
+		return rcode;
+	}
+
+	if (argc != 4) {
+		mon_printf ("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+	}
+
+	if (strcmp(argv[2], "bank") == 0) {
+		bank = simple_strtoul(argv[3], NULL, 16);
+		if ((bank < 1) || (bank > CFG_MAX_FLASH_BANKS)) {
+			mon_printf ("Only FLASH Banks # 1 ... # %d supported\n",
+				CFG_MAX_FLASH_BANKS);
+			return 1;
+		}
+		mon_printf ("%sProtect Flash Bank # %ld\n",
+			p ? "" : "Un-", bank);
+		info = &flash_info[bank-1];
+
+		if (info->flash_id == FLASH_UNKNOWN) {
+			mon_printf ("missing or unknown FLASH type\n");
+			return 1;
+		}
+		for (i=0; i<info->sector_count; ++i) {
+#if defined(CFG_FLASH_PROTECTION)
+			if (flash_real_protect(info, i, p))
+				rcode =  1;
+			putc ('.');
+#else
+			info->protect[i] = p;
+#endif	/* CFG_FLASH_PROTECTION */
+		}
+
+#if defined(CFG_FLASH_PROTECTION)
+		if (!rcode) puts (" done\n");
+#endif	/* CFG_FLASH_PROTECTION */
+
+		return rcode;
+	}
+
+	addr_first = simple_strtoul(argv[2], NULL, 16);
+	addr_last  = simple_strtoul(argv[3], NULL, 16);
+
+	if (addr_first >= addr_last) {
+		mon_printf ("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+	}
+	rcode = flash_sect_protect (p, addr_first, addr_last);
+	return rcode;
+}
+int flash_sect_protect (int p, ulong addr_first, ulong addr_last)
+{
+	flash_info_t *info;
+	ulong bank;
+	int s_first, s_last;
+	int protected, i;
+	int rcode = 0;
+
+	protected = 0;
+
+	for (bank=0,info=&flash_info[0]; bank < CFG_MAX_FLASH_BANKS; ++bank, ++info) {
+		ulong b_end;
+		int sect;
+
+		if (info->flash_id == FLASH_UNKNOWN) {
+			continue;
+		}
+
+		b_end = info->start[0] + info->size - 1; /* bank end addr */
+
+		s_first = -1;		/* first sector to erase	*/
+		s_last  = -1;		/* last  sector to erase	*/
+
+		for (sect=0; sect < info->sector_count; ++sect) {
+			ulong end;		/* last address in current sect	*/
+			short s_end;
+
+			s_end = info->sector_count - 1;
+
+			end = (sect == s_end) ? b_end : info->start[sect + 1] - 1;
+
+			if (addr_first > end)
+				continue;
+			if (addr_last < info->start[sect])
+				continue;
+
+			if (addr_first == info->start[sect]) {
+				s_first = sect;
+			}
+			if (addr_last  == end) {
+				s_last  = sect;
+			}
+		}
+		if (s_first>=0 && s_first<=s_last) {
+			protected += s_last - s_first + 1;
+			for (i=s_first; i<=s_last; ++i) {
+#if defined(CFG_FLASH_PROTECTION)
+				if (flash_real_protect(info, i, p))
+					rcode = 1;
+				putc ('.');
+#else
+				info->protect[i] = p;
+#endif	/* CFG_FLASH_PROTECTION */
+			}
+		}
+#if defined(CFG_FLASH_PROTECTION)
+		if (!rcode) putc ('\n');
+#endif	/* CFG_FLASH_PROTECTION */
+
+	}
+	if (protected) {
+	    //	mon_printf ("%sProtected %d sectors\n",
+	    //	p ? "" : "Un-", protected);
+	} else {
+	    mon_printf ("Error: start and/or end address"
+			" not on sector boundary\n");
+		rcode = 1;
+	}
+	return rcode;
+}
+
+#endif	/* CFG_CMD_FLASH */
diff --git a/tools/updater/ctype.c b/tools/updater/ctype.c
new file mode 100644
index 00000000000..6ed0468a219
--- /dev/null
+++ b/tools/updater/ctype.c
@@ -0,0 +1,56 @@
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ *  linux/lib/ctype.c
+ *
+ *  Copyright (C) 1991, 1992  Linus Torvalds
+ */
+
+#include <linux/ctype.h>
+
+unsigned char _ctype[] = {
+_C,_C,_C,_C,_C,_C,_C,_C,			/* 0-7 */
+_C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C,		/* 8-15 */
+_C,_C,_C,_C,_C,_C,_C,_C,			/* 16-23 */
+_C,_C,_C,_C,_C,_C,_C,_C,			/* 24-31 */
+_S|_SP,_P,_P,_P,_P,_P,_P,_P,			/* 32-39 */
+_P,_P,_P,_P,_P,_P,_P,_P,			/* 40-47 */
+_D,_D,_D,_D,_D,_D,_D,_D,			/* 48-55 */
+_D,_D,_P,_P,_P,_P,_P,_P,			/* 56-63 */
+_P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U,	/* 64-71 */
+_U,_U,_U,_U,_U,_U,_U,_U,			/* 72-79 */
+_U,_U,_U,_U,_U,_U,_U,_U,			/* 80-87 */
+_U,_U,_U,_P,_P,_P,_P,_P,			/* 88-95 */
+_P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L,	/* 96-103 */
+_L,_L,_L,_L,_L,_L,_L,_L,			/* 104-111 */
+_L,_L,_L,_L,_L,_L,_L,_L,			/* 112-119 */
+_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
+_S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,   /* 160-175 */
+_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,       /* 176-191 */
+_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,       /* 192-207 */
+_U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L,       /* 208-223 */
+_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,       /* 224-239 */
+_L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L};      /* 240-255 */
diff --git a/tools/updater/dummy.c b/tools/updater/dummy.c
new file mode 100644
index 00000000000..9fe5ac1b1e6
--- /dev/null
+++ b/tools/updater/dummy.c
@@ -0,0 +1 @@
+volatile int __dummy = 0xDEADBEEF;
diff --git a/tools/updater/flash.c b/tools/updater/flash.c
new file mode 100644
index 00000000000..d2e11d21248
--- /dev/null
+++ b/tools/updater/flash.c
@@ -0,0 +1,184 @@
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <flash.h>
+
+extern flash_info_t  flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
+
+/*-----------------------------------------------------------------------
+ * Functions
+ */
+
+/*-----------------------------------------------------------------------
+ * Set protection status for monitor sectors
+ *
+ * The monitor is always located in the _first_ Flash bank.
+ * If necessary you have to map the second bank at lower addresses.
+ */
+void
+flash_protect (int flag, ulong from, ulong to, flash_info_t *info)
+{
+	ulong b_end = info->start[0] + info->size - 1;	/* bank end address */
+	short s_end = info->sector_count - 1;	/* index of last sector */
+	int i;
+
+	/* Do nothing if input data is bad. */
+	if (info->sector_count == 0 || info->size == 0 || to < from) {
+		return;
+	}
+
+	/* There is nothing to do if we have no data about the flash
+	 * or the protect range and flash range don't overlap.
+	 */
+	if (info->flash_id == FLASH_UNKNOWN ||
+	    to < info->start[0] || from > b_end) {
+		return;
+	}
+
+	for (i=0; i<info->sector_count; ++i) {
+		ulong end;		/* last address in current sect	*/
+
+		end = (i == s_end) ? b_end : info->start[i + 1] - 1;
+
+		/* Update protection if any part of the sector
+		 * is in the specified range.
+		 */
+		if (from <= end && to >= info->start[i]) {
+			if (flag & FLAG_PROTECT_CLEAR) {
+#if defined(CFG_FLASH_PROTECTION)
+				flash_real_protect(info, i, 0);
+#else
+				info->protect[i] = 0;
+#endif	/* CFG_FLASH_PROTECTION */
+			}
+			else if (flag & FLAG_PROTECT_SET) {
+#if defined(CFG_FLASH_PROTECTION)
+				flash_real_protect(info, i, 1);
+#else
+				info->protect[i] = 1;
+#endif	/* CFG_FLASH_PROTECTION */
+			}
+		}
+	}
+}
+
+/*-----------------------------------------------------------------------
+ */
+
+flash_info_t *
+addr2info (ulong addr)
+{
+#ifndef CONFIG_SPD823TS
+	flash_info_t *info;
+	int i;
+
+	for (i=0, info=&flash_info[0]; i<CFG_MAX_FLASH_BANKS; ++i, ++info) {
+		if (info->flash_id != FLASH_UNKNOWN &&
+		    addr >= info->start[0] &&
+		    /* WARNING - The '- 1' is needed if the flash
+		     * is at the end of the address space, since
+		     * info->start[0] + info->size wraps back to 0.
+		     * Please don't change this unless you understand this.
+		     */
+		    addr <= info->start[0] + info->size - 1) {
+			return (info);
+		}
+	}
+#endif /* CONFIG_SPD823TS */
+
+	return (NULL);
+}
+
+/*-----------------------------------------------------------------------
+ * Copy memory to flash.
+ * Make sure all target addresses are within Flash bounds,
+ * and no protected sectors are hit.
+ * Returns:
+ * ERR_OK          0 - OK
+ * ERR_TIMOUT      1 - write timeout
+ * ERR_NOT_ERASED  2 - Flash not erased
+ * ERR_PROTECTED   4 - target range includes protected sectors
+ * ERR_INVAL       8 - target address not in Flash memory
+ * ERR_ALIGN       16 - target address not aligned on boundary
+ *			(only some targets require alignment)
+ */
+int
+flash_write (uchar *src, ulong addr, ulong cnt)
+{
+#ifdef CONFIG_SPD823TS
+	return (ERR_TIMOUT);	/* any other error codes are possible as well */
+#else
+	int i;
+	ulong         end        = addr + cnt - 1;
+	flash_info_t *info_first = addr2info (addr);
+	flash_info_t *info_last  = addr2info (end );
+	flash_info_t *info;
+	int j;
+
+	if (cnt == 0) {
+		return (ERR_OK);
+	}
+
+	if (!info_first || !info_last) {
+		return (ERR_INVAL);
+	}
+
+	for (info = info_first; info <= info_last; ++info) {
+		ulong b_end = info->start[0] + info->size;	/* bank end addr */
+		short s_end = info->sector_count - 1;
+		for (i=0; i<info->sector_count; ++i) {
+			ulong e_addr = (i == s_end) ? b_end : info->start[i + 1];
+
+			if ((end >= info->start[i]) && (addr < e_addr) &&
+			    (info->protect[i] != 0) ) {
+				return (ERR_PROTECTED);
+			}
+		}
+	}
+
+	mon_printf("\rWriting ");
+	for (j=0; j<20; j++) mon_putc(177);
+	mon_printf("\rWriting ");
+
+	/* finally write data to flash */
+	for (info = info_first; info <= info_last && cnt>0; ++info) {
+		ulong len;
+
+		len = info->start[0] + info->size - addr;
+		if (len > cnt)
+			len = cnt;
+
+		if ((i = write_buff(info, src, addr, len)) != 0) {
+			return (i);
+		}
+		cnt  -= len;
+		addr += len;
+		src  += len;
+	}
+	return (ERR_OK);
+#endif /* CONFIG_SPD823TS */
+}
+
+/*-----------------------------------------------------------------------
+ */
diff --git a/tools/updater/flash_hw.c b/tools/updater/flash_hw.c
new file mode 100644
index 00000000000..ec11589c779
--- /dev/null
+++ b/tools/updater/flash_hw.c
@@ -0,0 +1,660 @@
+/*
+ * (C) Copyright 2001
+ * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
+ *
+ * (C) Copyright 2002
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <flash.h>
+#include <asm/io.h>
+#include <memio.h>
+
+/*---------------------------------------------------------------------*/
+#undef DEBUG_FLASH
+//#define DEBUG_FLASH
+
+#ifdef DEBUG_FLASH
+#define DEBUGF(fmt,args...) mon_printf(fmt ,##args)
+#else
+#define DEBUGF(fmt,args...)
+#endif
+/*---------------------------------------------------------------------*/
+
+flash_info_t	flash_info[CFG_MAX_FLASH_BANKS];
+
+static ulong flash_get_size (ulong addr, flash_info_t *info);
+static int flash_get_offsets (ulong base, flash_info_t *info);
+static int write_word (flash_info_t *info, ulong dest, ulong data);
+static void flash_reset (ulong addr);
+
+int flash_xd_nest;
+
+static void flash_to_xd(void)
+{
+    unsigned char x;
+
+    flash_xd_nest ++;
+
+    if (flash_xd_nest == 1)
+    {
+	DEBUGF("Flash on XD\n");
+	x = pci_read_cfg_byte(0, 0, 0x74);
+	pci_write_cfg_byte(0, 0, 0x74, x|1);
+    }
+}
+
+static void flash_to_mem(void)
+{
+    unsigned char x;
+
+    flash_xd_nest --;
+   
+    if (flash_xd_nest == 0)
+    {
+	DEBUGF("Flash on memory bus\n");
+	x = pci_read_cfg_byte(0, 0, 0x74);
+	pci_write_cfg_byte(0, 0, 0x74, x&0xFE);
+    }
+}
+
+unsigned long flash_init_old(void)
+{
+    int i;
+
+    for (i = 0; i < CFG_MAX_FLASH_BANKS; i++)
+    {
+	flash_info[i].flash_id = FLASH_UNKNOWN;
+	flash_info[i].sector_count = 0;
+	flash_info[i].size = 0;
+    }
+
+
+    return 1;
+}
+
+unsigned long flash_init (void)
+{
+	unsigned int i;
+	unsigned long flash_size = 0;
+
+	flash_xd_nest = 0;
+
+	flash_to_xd();
+
+	/* Init: no FLASHes known */
+	for (i=0; i<CFG_MAX_FLASH_BANKS; ++i) {
+		flash_info[i].flash_id = FLASH_UNKNOWN;
+		flash_info[i].sector_count = 0;
+		flash_info[i].size = 0;
+	}
+
+	DEBUGF("\n## Get flash size @ 0x%08x\n", CFG_FLASH_BASE);
+
+	flash_size = flash_get_size (CFG_FLASH_BASE, flash_info);
+
+	DEBUGF("## Flash bank size: %08lx\n", flash_size);
+
+	if (flash_size) {
+#if CFG_MONITOR_BASE >= CFG_FLASH_BASE && \
+    CFG_MONITOR_BASE < CFG_FLASH_BASE + CFG_FLASH_MAX_SIZE
+		/* monitor protection ON by default */
+		flash_protect(FLAG_PROTECT_SET,
+			      CFG_MONITOR_BASE,
+			      CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1,
+			      &flash_info[0]);
+#endif
+
+#ifdef CFG_ENV_IS_IN_FLASH
+		/* ENV protection ON by default */
+		flash_protect(FLAG_PROTECT_SET,
+			      CFG_ENV_ADDR,
+			      CFG_ENV_ADDR + CFG_ENV_SECT_SIZE - 1,
+			      &flash_info[0]);
+#endif
+
+	} else {
+		mon_printf ("Warning: the BOOT Flash is not initialised !");
+	}
+
+	flash_to_mem();
+
+	return flash_size;
+}
+
+/*
+ * The following code cannot be run from FLASH!
+ */
+static ulong flash_get_size (ulong addr, flash_info_t *info)
+{
+	short i;
+	uchar value;
+	uchar *x = (uchar *)addr;
+
+	flash_to_xd();
+
+	/* Write auto select command: read Manufacturer ID */
+	x[0x0555] =  0xAA;
+	__asm volatile ("sync\n eieio");
+	x[0x02AA] =  0x55;
+	__asm volatile ("sync\n eieio");
+	x[0x0555] =  0x90;
+	__asm volatile ("sync\n eieio");
+
+	value = x[0];
+	__asm volatile ("sync\n eieio");
+
+	DEBUGF("Manuf. ID @ 0x%08lx: 0x%08x\n", (ulong)addr, value);
+
+	switch (value | (value << 16)) {
+		case AMD_MANUFACT:
+			info->flash_id = FLASH_MAN_AMD;
+			break;
+
+		case FUJ_MANUFACT:
+			info->flash_id = FLASH_MAN_FUJ;
+			break;
+
+		case STM_MANUFACT:
+			info->flash_id = FLASH_MAN_STM;
+			break;
+
+		default:
+			info->flash_id = FLASH_UNKNOWN;
+			info->sector_count = 0;
+			info->size = 0;
+			flash_reset (addr);
+			return 0;
+	}
+
+	value = x[1];
+	__asm volatile ("sync\n eieio");
+
+	DEBUGF("Device ID @ 0x%08lx: 0x%08x\n", addr+1, value);
+
+	switch (value) {
+		case AMD_ID_F040B:
+			DEBUGF("Am29F040B\n");
+			info->flash_id += FLASH_AM040;
+			info->sector_count = 8;
+			info->size = 0x00080000;
+			break;			/* => 512 kB		*/
+
+		case AMD_ID_LV040B:
+			DEBUGF("Am29LV040B\n");
+			info->flash_id += FLASH_AM040;
+			info->sector_count = 8;
+			info->size = 0x00080000;
+			break;			/* => 512 kB		*/
+
+		case AMD_ID_LV400T:
+			DEBUGF("Am29LV400T\n");
+			info->flash_id += FLASH_AM400T;
+			info->sector_count = 11;
+			info->size = 0x00100000;
+			break;			/* => 1 MB		*/
+
+		case AMD_ID_LV400B:
+			DEBUGF("Am29LV400B\n");
+			info->flash_id += FLASH_AM400B;
+			info->sector_count = 11;
+			info->size = 0x00100000;
+			break;			/* => 1 MB		*/
+
+		case AMD_ID_LV800T:
+			DEBUGF("Am29LV800T\n");
+			info->flash_id += FLASH_AM800T;
+			info->sector_count = 19;
+			info->size = 0x00200000;
+			break;			/* => 2 MB		*/
+
+		case AMD_ID_LV800B:
+			DEBUGF("Am29LV400B\n");
+			info->flash_id += FLASH_AM800B;
+			info->sector_count = 19;
+			info->size = 0x00200000;
+			break;			/* => 2 MB		*/
+
+		case AMD_ID_LV160T:
+			DEBUGF("Am29LV160T\n");
+			info->flash_id += FLASH_AM160T;
+			info->sector_count = 35;
+			info->size = 0x00400000;
+			break;			/* => 4 MB		*/
+
+		case AMD_ID_LV160B:
+			DEBUGF("Am29LV160B\n");
+			info->flash_id += FLASH_AM160B;
+			info->sector_count = 35;
+			info->size = 0x00400000;
+			break;			/* => 4 MB		*/
+
+		case AMD_ID_LV320T:
+			DEBUGF("Am29LV320T\n");
+			info->flash_id += FLASH_AM320T;
+			info->sector_count = 67;
+			info->size = 0x00800000;
+			break;			/* => 8 MB		*/
+
+#if 0
+		/* Has the same ID as AMD_ID_LV320T, to be fixed */
+		case AMD_ID_LV320B:
+			DEBUGF("Am29LV320B\n");
+			info->flash_id += FLASH_AM320B;
+			info->sector_count = 67;
+			info->size = 0x00800000;
+			break;			/* => 8 MB		*/
+#endif
+
+		case AMD_ID_LV033C:
+			DEBUGF("Am29LV033C\n");
+			info->flash_id += FLASH_AM033C;
+			info->sector_count = 64;
+			info->size = 0x01000000;
+			break;			/* => 16Mb		*/
+
+		case STM_ID_F040B:
+			DEBUGF("M29F040B\n");
+			info->flash_id += FLASH_AM040;
+			info->sector_count = 8;
+			info->size = 0x00080000;
+			break;			/* => 512 kB		*/
+
+		default:
+			info->flash_id = FLASH_UNKNOWN;
+			flash_reset (addr);
+			flash_to_mem();
+			return (0);		/* => no or unknown flash */
+
+	}
+
+	if (info->sector_count > CFG_MAX_FLASH_SECT) {
+		mon_printf ("** ERROR: sector count %d > max (%d) **\n",
+			info->sector_count, CFG_MAX_FLASH_SECT);
+		info->sector_count = CFG_MAX_FLASH_SECT;
+	}
+
+	if (! flash_get_offsets (addr, info)) {
+		flash_reset (addr);
+		flash_to_mem();
+		return 0;
+	}
+
+	/* check for protected sectors */
+	for (i = 0; i < info->sector_count; i++) {
+		/* read sector protection at sector address, (A7 .. A0) = 0x02 */
+		/* D0 = 1 if protected */
+		value = in8(info->start[i] + 2);
+		iobarrier_rw();
+		info->protect[i] = (value & 1) != 0;
+	}
+
+	/*
+	 * Reset bank to read mode
+	 */
+	flash_reset (addr);
+
+	flash_to_mem();
+
+	return (info->size);
+}
+
+static int flash_get_offsets (ulong base, flash_info_t *info)
+{
+	unsigned int i;
+
+	switch (info->flash_id & FLASH_TYPEMASK) {
+		case FLASH_AM040:
+			/* set sector offsets for uniform sector type	*/
+			for (i = 0; i < info->sector_count; i++) {
+				info->start[i] = base + i * info->size /
+				                            info->sector_count;
+			}
+			break;
+		default:
+			return 0;
+	}
+
+	return 1;
+}
+
+int flash_erase (flash_info_t *info, int s_first, int s_last)
+{
+	volatile ulong addr = info->start[0];
+	int flag, prot, sect, l_sect;
+	ulong start, now, last;
+
+	flash_to_xd();
+
+	if (s_first < 0 || s_first > s_last) {
+		if (info->flash_id == FLASH_UNKNOWN) {
+			mon_printf ("- missing\n");
+		} else {
+			mon_printf ("- no sectors to erase\n");
+		}
+		flash_to_mem();
+		return 1;
+	}
+
+	if (info->flash_id == FLASH_UNKNOWN) {
+		mon_printf ("Can't erase unknown flash type %08lx - aborted\n",
+			info->flash_id);
+		flash_to_mem();
+		return 1;
+	}
+
+	prot = 0;
+	for (sect=s_first; sect<=s_last; ++sect) {
+		if (info->protect[sect]) {
+			prot++;
+		}
+	}
+
+	if (prot) {
+		mon_printf ("- Warning: %d protected sectors will not be erased!\n",
+			prot);
+	} else {
+		mon_printf ("");
+	}
+
+	l_sect = -1;
+
+	/* Disable interrupts which might cause a timeout here */
+	flag = disable_interrupts();
+
+	out8(addr + 0x555, 0xAA);
+	iobarrier_rw();
+	out8(addr + 0x2AA, 0x55);
+	iobarrier_rw();
+	out8(addr + 0x555, 0x80);
+	iobarrier_rw();
+	out8(addr + 0x555, 0xAA);
+	iobarrier_rw();
+	out8(addr + 0x2AA, 0x55);
+	iobarrier_rw();
+
+	/* Start erase on unprotected sectors */
+	for (sect = s_first; sect<=s_last; sect++) {
+		if (info->protect[sect] == 0) {	/* not protected */
+			addr = info->start[sect];
+			out8(addr, 0x30);
+			iobarrier_rw();
+			l_sect = sect;
+		}
+	}
+
+	/* re-enable interrupts if necessary */
+	if (flag)
+		enable_interrupts();
+
+	/* wait at least 80us - let's wait 1 ms */
+	mon_udelay (1000);
+
+	/*
+	 * We wait for the last triggered sector
+	 */
+	if (l_sect < 0)
+		goto DONE;
+
+	start = mon_get_timer (0);
+	last  = start;
+	addr = info->start[l_sect];
+
+	DEBUGF ("Start erase timeout: %d\n", CFG_FLASH_ERASE_TOUT);
+
+	while ((in8(addr) & 0x80) != 0x80) {
+		if ((now = mon_get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
+			mon_printf ("Timeout\n");
+			flash_reset (info->start[0]);
+			flash_to_mem();
+			return 1;
+		}
+		/* show that we're waiting */
+		if ((now - last) > 1000) {	/* every second */
+			mon_putc ('.');
+			last = now;
+		}
+		iobarrier_rw();
+	}
+
+DONE:
+	/* reset to read mode */
+	flash_reset (info->start[0]);
+	flash_to_mem();
+
+	mon_printf (" done\n");
+	return 0;
+}
+
+/*
+ * Copy memory to flash, returns:
+ * 0 - OK
+ * 1 - write timeout
+ * 2 - Flash not erased
+ */
+int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
+{
+	ulong cp, wp, data;
+	int i, l, rc;
+	ulong out_cnt = 0;
+
+	flash_to_xd();
+
+	wp = (addr & ~3);	/* get lower word aligned address */
+
+	/*
+	 * handle unaligned start bytes
+	 */
+	if ((l = addr - wp) != 0) {
+		data = 0;
+		for (i=0, cp=wp; i<l; ++i, ++cp) {
+			data = (data << 8) | (*(uchar *)cp);
+		}
+		for (; i<4 && cnt>0; ++i) {
+			data = (data << 8) | *src++;
+			--cnt;
+			++cp;
+		}
+		for (; cnt==0 && i<4; ++i, ++cp) {
+			data = (data << 8) | (*(uchar *)cp);
+		}
+
+		if ((rc = write_word(info, wp, data)) != 0) {
+		        flash_to_mem();
+			return (rc);
+		}
+		wp += 4;
+	}
+
+	mon_putc(219);
+
+	/*
+	 * handle word aligned part
+	 */
+	while (cnt >= 4) {
+	    if (out_cnt>26214) 
+	    {
+		mon_putc(219);
+		out_cnt = 0;
+	    }
+	    data = 0;
+	    for (i=0; i<4; ++i) {
+		data = (data << 8) | *src++;
+	    }
+	    if ((rc = write_word(info, wp, data)) != 0) {
+		flash_to_mem();
+		return (rc);
+	    }
+	    wp  += 4;
+	    cnt -= 4;
+	    out_cnt += 4;
+	}
+
+	if (cnt == 0) {
+		flash_to_mem();
+		return (0);
+	}
+
+	/*
+	 * handle unaligned tail bytes
+	 */
+	data = 0;
+	for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
+		data = (data << 8) | *src++;
+		--cnt;
+	}
+	for (; i<4; ++i, ++cp) {
+		data = (data << 8) | (*(uchar *)cp);
+	}
+
+	flash_to_mem();
+	return (write_word(info, wp, data));
+}
+
+/*
+ * Write a word to Flash, returns:
+ * 0 - OK
+ * 1 - write timeout
+ * 2 - Flash not erased
+ */
+static int write_word (flash_info_t *info, ulong dest, ulong data)
+{
+	volatile ulong addr = info->start[0];
+	ulong start;
+	int i;
+
+	flash_to_xd();
+
+	/* Check if Flash is (sufficiently) erased */
+	if ((in32(dest) & data) != data) {
+		flash_to_mem();
+		return (2);
+	}
+
+	/* write each byte out */
+	for (i = 0; i < 4; i++) {
+		char *data_ch = (char *)&data;
+		int flag = disable_interrupts();
+
+		out8(addr + 0x555, 0xAA);
+		iobarrier_rw();
+		out8(addr + 0x2AA, 0x55);
+		iobarrier_rw();
+		out8(addr + 0x555, 0xA0);
+		iobarrier_rw();
+		out8(dest+i, data_ch[i]);
+		iobarrier_rw();
+
+		/* re-enable interrupts if necessary */
+		if (flag)
+			enable_interrupts();
+
+		/* data polling for D7 */
+		start = mon_get_timer (0);
+		while ((in8(dest+i) & 0x80) != (data_ch[i] & 0x80)) {
+			if (mon_get_timer(start) > CFG_FLASH_WRITE_TOUT) {
+				flash_reset (addr);
+				flash_to_mem();
+				return (1);
+			}
+			iobarrier_rw();
+		}
+	}
+
+	flash_reset (addr);
+	flash_to_mem();
+	return (0);
+}
+
+/*
+ * Reset bank to read mode
+ */
+static void flash_reset (ulong addr)
+{
+        flash_to_xd();
+	out8(addr, 0xF0);	/* reset bank */
+	iobarrier_rw();
+	flash_to_mem();
+}
+
+void flash_print_info (flash_info_t *info)
+{
+	int i;
+
+	if (info->flash_id == FLASH_UNKNOWN) {
+		mon_printf ("missing or unknown FLASH type\n");
+		return;
+	}
+
+	switch (info->flash_id & FLASH_VENDMASK) {
+	case FLASH_MAN_AMD:	mon_printf ("AMD ");		break;
+	case FLASH_MAN_FUJ:	mon_printf ("FUJITSU ");		break;
+	case FLASH_MAN_BM:	mon_printf ("BRIGHT MICRO ");	break;
+	case FLASH_MAN_STM:	mon_printf ("SGS THOMSON ");	break;
+	default:		mon_printf ("Unknown Vendor ");	break;
+	}
+
+	switch (info->flash_id & FLASH_TYPEMASK) {
+	case FLASH_AM040:	mon_printf ("29F040 or 29LV040 (4 Mbit, uniform sectors)\n");
+				break;
+	case FLASH_AM400B:	mon_printf ("AM29LV400B (4 Mbit, bottom boot sect)\n");
+				break;
+	case FLASH_AM400T:	mon_printf ("AM29LV400T (4 Mbit, top boot sector)\n");
+				break;
+	case FLASH_AM800B:	mon_printf ("AM29LV800B (8 Mbit, bottom boot sect)\n");
+				break;
+	case FLASH_AM800T:	mon_printf ("AM29LV800T (8 Mbit, top boot sector)\n");
+				break;
+	case FLASH_AM160B:	mon_printf ("AM29LV160B (16 Mbit, bottom boot sect)\n");
+				break;
+	case FLASH_AM160T:	mon_printf ("AM29LV160T (16 Mbit, top boot sector)\n");
+				break;
+	case FLASH_AM320B:	mon_printf ("AM29LV320B (32 Mbit, bottom boot sect)\n");
+				break;
+	case FLASH_AM320T:	mon_printf ("AM29LV320T (32 Mbit, top boot sector)\n");
+				break;
+	default:		mon_printf ("Unknown Chip Type\n");
+				break;
+	}
+
+	if (info->size % 0x100000 == 0) {
+		mon_printf ("  Size: %ld MB in %d Sectors\n",
+			info->size / 0x100000, info->sector_count);
+	} else if (info->size % 0x400 == 0) {
+		mon_printf ("  Size: %ld KB in %d Sectors\n",
+		        info->size / 0x400, info->sector_count);
+	} else {
+		mon_printf ("  Size: %ld B in %d Sectors\n",
+		        info->size, info->sector_count);
+	}
+
+	mon_printf ("  Sector Start Addresses:");
+	for (i=0; i<info->sector_count; ++i) {
+		if ((i % 5) == 0)
+			mon_printf ("\n   ");
+		mon_printf (" %08lX%s",
+			info->start[i],
+			info->protect[i] ? " (RO)" : "     "
+		);
+	}
+	mon_printf ("\n");
+}
diff --git a/tools/updater/junk b/tools/updater/junk
new file mode 100644
index 00000000000..f73285a8324
--- /dev/null
+++ b/tools/updater/junk
@@ -0,0 +1 @@
+................................................................................................................................................................................................................................................................
\ No newline at end of file
diff --git a/tools/updater/ppcstring.S b/tools/updater/ppcstring.S
new file mode 100644
index 00000000000..97023a0555a
--- /dev/null
+++ b/tools/updater/ppcstring.S
@@ -0,0 +1,216 @@
+/*
+ * String handling functions for PowerPC.
+ *
+ * Copyright (C) 1996 Paul Mackerras.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+#include <ppc_asm.tmpl>
+#include <asm/errno.h>
+
+	.globl	strcpy
+strcpy:
+	addi	r5,r3,-1
+	addi	r4,r4,-1
+1:	lbzu	r0,1(r4)
+	cmpwi	0,r0,0
+	stbu	r0,1(r5)
+	bne	1b
+	blr
+
+	.globl	strncpy
+strncpy:
+	cmpwi	0,r5,0
+	beqlr
+	mtctr	r5
+	addi	r6,r3,-1
+	addi	r4,r4,-1
+1:	lbzu	r0,1(r4)
+	cmpwi	0,r0,0
+	stbu	r0,1(r6)
+	bdnzf	2,1b		/* dec ctr, branch if ctr != 0 && !cr0.eq */
+	blr
+
+	.globl	strcat
+strcat:
+	addi	r5,r3,-1
+	addi	r4,r4,-1
+1:	lbzu	r0,1(r5)
+	cmpwi	0,r0,0
+	bne	1b
+	addi	r5,r5,-1
+1:	lbzu	r0,1(r4)
+	cmpwi	0,r0,0
+	stbu	r0,1(r5)
+	bne	1b
+	blr
+
+	.globl	strcmp
+strcmp:
+	addi	r5,r3,-1
+	addi	r4,r4,-1
+1:	lbzu	r3,1(r5)
+	cmpwi	1,r3,0
+	lbzu	r0,1(r4)
+	subf.	r3,r0,r3
+	beqlr	1
+	beq	1b
+	blr
+
+	.globl	strlen
+strlen:
+	addi	r4,r3,-1
+1:	lbzu	r0,1(r4)
+	cmpwi	0,r0,0
+	bne	1b
+	subf	r3,r3,r4
+	blr
+
+	.globl	memset
+memset:
+	rlwimi	r4,r4,8,16,23
+	rlwimi	r4,r4,16,0,15
+	addi	r6,r3,-4
+	cmplwi	0,r5,4
+	blt	7f
+	stwu	r4,4(r6)
+	beqlr
+	andi.	r0,r6,3
+	add	r5,r0,r5
+	subf	r6,r0,r6
+	rlwinm	r0,r5,32-2,2,31
+	mtctr	r0
+	bdz	6f
+1:	stwu	r4,4(r6)
+	bdnz	1b
+6:	andi.	r5,r5,3
+7:	cmpwi	0,r5,0
+	beqlr
+	mtctr	r5
+	addi	r6,r6,3
+8:	stbu	r4,1(r6)
+	bdnz	8b
+	blr
+
+	.globl	bcopy
+bcopy:
+	mr	r6,r3
+	mr	r3,r4
+	mr	r4,r6
+	b	memcpy
+
+	.globl	memmove
+memmove:
+	cmplw	0,r3,r4
+	bgt	backwards_memcpy
+	/* fall through */
+
+	.globl	memcpy
+memcpy:
+	rlwinm.	r7,r5,32-3,3,31		/* r0 = r5 >> 3 */
+	addi	r6,r3,-4
+	addi	r4,r4,-4
+	beq	2f			/* if less than 8 bytes to do */
+	andi.	r0,r6,3			/* get dest word aligned */
+	mtctr	r7
+	bne	5f
+1:	lwz	r7,4(r4)
+	lwzu	r8,8(r4)
+	stw	r7,4(r6)
+	stwu	r8,8(r6)
+	bdnz	1b
+	andi.	r5,r5,7
+2:	cmplwi	0,r5,4
+	blt	3f
+	lwzu	r0,4(r4)
+	addi	r5,r5,-4
+	stwu	r0,4(r6)
+3:	cmpwi	0,r5,0
+	beqlr
+	mtctr	r5
+	addi	r4,r4,3
+	addi	r6,r6,3
+4:	lbzu	r0,1(r4)
+	stbu	r0,1(r6)
+	bdnz	4b
+	blr
+5:	subfic	r0,r0,4
+	mtctr	r0
+6:	lbz	r7,4(r4)
+	addi	r4,r4,1
+	stb	r7,4(r6)
+	addi	r6,r6,1
+	bdnz	6b
+	subf	r5,r0,r5
+	rlwinm.	r7,r5,32-3,3,31
+	beq	2b
+	mtctr	r7
+	b	1b
+
+	.globl	backwards_memcpy
+backwards_memcpy:
+	rlwinm.	r7,r5,32-3,3,31		/* r0 = r5 >> 3 */
+	add	r6,r3,r5
+	add	r4,r4,r5
+	beq	2f
+	andi.	r0,r6,3
+	mtctr	r7
+	bne	5f
+1:	lwz	r7,-4(r4)
+	lwzu	r8,-8(r4)
+	stw	r7,-4(r6)
+	stwu	r8,-8(r6)
+	bdnz	1b
+	andi.	r5,r5,7
+2:	cmplwi	0,r5,4
+	blt	3f
+	lwzu	r0,-4(r4)
+	subi	r5,r5,4
+	stwu	r0,-4(r6)
+3:	cmpwi	0,r5,0
+	beqlr
+	mtctr	r5
+4:	lbzu	r0,-1(r4)
+	stbu	r0,-1(r6)
+	bdnz	4b
+	blr
+5:	mtctr	r0
+6:	lbzu	r7,-1(r4)
+	stbu	r7,-1(r6)
+	bdnz	6b
+	subf	r5,r0,r5
+	rlwinm.	r7,r5,32-3,3,31
+	beq	2b
+	mtctr	r7
+	b	1b
+
+	.globl	memcmp
+memcmp:
+	cmpwi	0,r5,0
+	ble-	2f
+	mtctr	r5
+	addi	r6,r3,-1
+	addi	r4,r4,-1
+1:	lbzu	r3,1(r6)
+	lbzu	r0,1(r4)
+	subf.	r3,r0,r3
+	bdnzt	2,1b
+	blr
+2:	li	r3,0
+	blr
+
+	.global	memchr
+memchr:
+	cmpwi	0,r5,0
+	ble-	2f
+	mtctr	r5
+	addi	r3,r3,-1
+1:	lbzu	r0,1(r3)
+	cmpw	0,r0,r4
+	bdnzf	2,1b
+	beqlr
+2:	li	r3,0
+	blr
diff --git a/tools/updater/string.c b/tools/updater/string.c
new file mode 100644
index 00000000000..50537a65540
--- /dev/null
+++ b/tools/updater/string.c
@@ -0,0 +1,340 @@
+/*
+ *  linux/lib/string.c
+ *
+ *  Copyright (C) 1991, 1992  Linus Torvalds
+ */
+
+/*
+ * stupid library routines.. The optimized versions should generally be found
+ * as inline code in <asm-xx/string.h>
+ *
+ * These are buggy as well..
+ */
+
+#include <linux/types.h>
+#include <linux/string.h>
+#include <malloc.h>
+
+#define __HAVE_ARCH_BCOPY
+#define __HAVE_ARCH_MEMCMP
+#define __HAVE_ARCH_MEMCPY
+#define __HAVE_ARCH_MEMMOVE
+#define __HAVE_ARCH_MEMSET
+#define __HAVE_ARCH_STRCAT
+#define __HAVE_ARCH_STRCMP
+#define __HAVE_ARCH_STRCPY
+#define __HAVE_ARCH_STRLEN
+#define __HAVE_ARCH_STRNCPY
+
+char * ___strtok = NULL;
+
+#ifndef __HAVE_ARCH_STRCPY
+char * strcpy(char * dest,const char *src)
+{
+	char *tmp = dest;
+
+	while ((*dest++ = *src++) != '\0')
+		/* nothing */;
+	return tmp;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRNCPY
+char * strncpy(char * dest,const char *src,size_t count)
+{
+	char *tmp = dest;
+
+	while (count-- && (*dest++ = *src++) != '\0')
+		/* nothing */;
+
+	return tmp;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRCAT
+char * strcat(char * dest, const char * src)
+{
+	char *tmp = dest;
+
+	while (*dest)
+		dest++;
+	while ((*dest++ = *src++) != '\0')
+		;
+
+	return tmp;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRNCAT
+char * strncat(char *dest, const char *src, size_t count)
+{
+	char *tmp = dest;
+
+	if (count) {
+		while (*dest)
+			dest++;
+		while ((*dest++ = *src++)) {
+			if (--count == 0) {
+				*dest = '\0';
+				break;
+			}
+		}
+	}
+
+	return tmp;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRCMP
+int strcmp(const char * cs,const char * ct)
+{
+	register signed char __res;
+
+	while (1) {
+		if ((__res = *cs - *ct++) != 0 || !*cs++)
+			break;
+	}
+
+	return __res;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRNCMP
+int strncmp(const char * cs,const char * ct,size_t count)
+{
+	register signed char __res = 0;
+
+	while (count) {
+		if ((__res = *cs - *ct++) != 0 || !*cs++)
+			break;
+		count--;
+	}
+
+	return __res;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRCHR
+char * strchr(const char * s, int c)
+{
+	for(; *s != (char) c; ++s)
+		if (*s == '\0')
+			return NULL;
+	return (char *) s;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRRCHR
+char * strrchr(const char * s, int c)
+{
+       const char *p = s + strlen(s);
+       do {
+           if (*p == (char)c)
+               return (char *)p;
+       } while (--p >= s);
+       return NULL;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRLEN
+size_t strlen(const char * s)
+{
+	const char *sc;
+
+	for (sc = s; *sc != '\0'; ++sc)
+		/* nothing */;
+	return sc - s;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRNLEN
+size_t strnlen(const char * s, size_t count)
+{
+	const char *sc;
+
+	for (sc = s; count-- && *sc != '\0'; ++sc)
+		/* nothing */;
+	return sc - s;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRDUP
+char * strdup(const char *s)
+{
+	char *new;
+
+	if ((s == NULL)	||
+	    ((new = mon_malloc (strlen(s) + 1)) == NULL) ) {
+		return NULL;
+	}
+
+	strcpy (new, s);
+	return new;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRSPN
+size_t strspn(const char *s, const char *accept)
+{
+	const char *p;
+	const char *a;
+	size_t count = 0;
+
+	for (p = s; *p != '\0'; ++p) {
+		for (a = accept; *a != '\0'; ++a) {
+			if (*p == *a)
+				break;
+		}
+		if (*a == '\0')
+			return count;
+		++count;
+	}
+
+	return count;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRPBRK
+char * strpbrk(const char * cs,const char * ct)
+{
+	const char *sc1,*sc2;
+
+	for( sc1 = cs; *sc1 != '\0'; ++sc1) {
+		for( sc2 = ct; *sc2 != '\0'; ++sc2) {
+			if (*sc1 == *sc2)
+				return (char *) sc1;
+		}
+	}
+	return NULL;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRTOK
+char * strtok(char * s,const char * ct)
+{
+	char *sbegin, *send;
+
+	sbegin  = s ? s : ___strtok;
+	if (!sbegin) {
+		return NULL;
+	}
+	sbegin += strspn(sbegin,ct);
+	if (*sbegin == '\0') {
+		___strtok = NULL;
+		return( NULL );
+	}
+	send = strpbrk( sbegin, ct);
+	if (send && *send != '\0')
+		*send++ = '\0';
+	___strtok = send;
+	return (sbegin);
+}
+#endif
+
+#ifndef __HAVE_ARCH_MEMSET
+void * memset(void * s,char c,size_t count)
+{
+	char *xs = (char *) s;
+
+	while (count--)
+		*xs++ = c;
+
+	return s;
+}
+#endif
+
+#ifndef __HAVE_ARCH_BCOPY
+char * bcopy(const char * src, char * dest, int count)
+{
+	char *tmp = dest;
+
+	while (count--)
+		*tmp++ = *src++;
+
+	return dest;
+}
+#endif
+
+#ifndef __HAVE_ARCH_MEMCPY
+void * memcpy(void * dest,const void *src,size_t count)
+{
+	char *tmp = (char *) dest, *s = (char *) src;
+
+	while (count--)
+		*tmp++ = *s++;
+
+	return dest;
+}
+#endif
+
+#ifndef __HAVE_ARCH_MEMMOVE
+void * memmove(void * dest,const void *src,size_t count)
+{
+	char *tmp, *s;
+
+	if (dest <= src) {
+		tmp = (char *) dest;
+		s = (char *) src;
+		while (count--)
+			*tmp++ = *s++;
+		}
+	else {
+		tmp = (char *) dest + count;
+		s = (char *) src + count;
+		while (count--)
+			*--tmp = *--s;
+		}
+
+	return dest;
+}
+#endif
+
+#ifndef __HAVE_ARCH_MEMCMP
+int memcmp(const void * cs,const void * ct,size_t count)
+{
+	const unsigned char *su1, *su2;
+	signed char res = 0;
+
+	for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
+		if ((res = *su1 - *su2) != 0)
+			break;
+	return res;
+}
+#endif
+
+/*
+ * find the first occurrence of byte 'c', or 1 past the area if none
+ */
+#ifndef __HAVE_ARCH_MEMSCAN
+void * memscan(void * addr, int c, size_t size)
+{
+	unsigned char * p = (unsigned char *) addr;
+
+	while (size) {
+		if (*p == c)
+			return (void *) p;
+		p++;
+		size--;
+	}
+  	return (void *) p;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRSTR
+char * strstr(const char * s1,const char * s2)
+{
+	int l1, l2;
+
+	l2 = strlen(s2);
+	if (!l2)
+		return (char *) s1;
+	l1 = strlen(s1);
+	while (l1 >= l2) {
+		l1--;
+		if (!memcmp(s1,s2,l2))
+			return (char *) s1;
+		s1++;
+	}
+	return NULL;
+}
+#endif
diff --git a/tools/updater/update.c b/tools/updater/update.c
new file mode 100644
index 00000000000..66c6dfc30dc
--- /dev/null
+++ b/tools/updater/update.c
@@ -0,0 +1,67 @@
+#include <common.h>
+#include <syscall.h>
+
+extern unsigned long __dummy;
+void do_reset (void);
+void do_updater(void);
+
+void _main(void)
+{
+    int i;
+    mon_printf("U-Boot Firmware Updater\n\n\n");
+    mon_printf("****************************************************\n"
+	       "*  ATTENTION!! PLEASE READ THIS NOTICE CAREFULLY!  *\n"
+	       "****************************************************\n\n"
+	       "This program  will update your computer's  firmware.\n"
+	       "Do NOT  remove the disk,  reset the  machine,  or do\n"
+	       "anything that  might disrupt functionality.  If this\n");
+    mon_printf("Program fails, your computer  might be unusable, and\n"
+	       "you will  need to return your  board for reflashing.\n"
+	       "If you find this too risky,  remove the diskette and\n"
+	       "switch off your  machine now.  Otherwise  press the \n"
+	       "SPACE key now to start the process\n\n");
+    do
+    {
+	char x;
+	while (!mon_tstc());
+	x = mon_getc();
+	if (x == ' ') break;
+    } while (1);
+
+    do_updater();
+
+    i = 5;
+
+    mon_printf("\nUpdate done. Please remove diskette.\n");
+    mon_printf("The machine will automatically reset in %d seconds\n", i);
+    mon_printf("You can switch off/reset now when the floppy is removed\n\n");
+    
+    while (i)
+    {
+	mon_printf("Resetting in %d\r", i);
+	mon_udelay(1000000);
+	i--;
+    }
+    do_reset();
+    while (1);
+}
+
+int flash_sect_protect (int p, ulong addr_first, ulong addr_last);
+int flash_sect_erase (ulong addr_first, ulong addr_last);
+int flash_write (uchar *src, ulong addr, ulong cnt);
+
+void do_updater(void)
+{
+    unsigned long *addr = &__dummy + 65;
+    unsigned long flash_size = flash_init();
+    int rc;
+
+    flash_sect_protect(0, 0xFFF00000, 0xFFF7FFFF);
+    mon_printf("Erasing ");
+    flash_sect_erase(0xFFF00000, 0xFFF7FFFF);
+    mon_printf("Writing ");
+    rc = flash_write((uchar *)addr, 0xFFF00000, 0x7FFFF);
+    if (rc != 0) mon_printf("\nFlashing failed due to error %d\n", rc);
+    else mon_printf("\ndone\n");
+    flash_sect_protect(1, 0xFFF00000, 0xFFF7FFFF);
+}
diff --git a/tools/updater/utils.c b/tools/updater/utils.c
new file mode 100644
index 00000000000..e230e19f928
--- /dev/null
+++ b/tools/updater/utils.c
@@ -0,0 +1,148 @@
+#include <common.h>
+#include <asm/processor.h>
+#include <memio.h>
+#include <linux/ctype.h>
+
+static __inline__ unsigned long
+get_msr(void)
+{
+	unsigned long msr;
+
+	asm volatile("mfmsr %0" : "=r" (msr) :);
+	return msr;
+}
+
+static __inline__ void
+set_msr(unsigned long msr)
+{
+	asm volatile("mtmsr %0" : : "r" (msr)); 
+}
+
+static __inline__ unsigned long
+get_dec(void)
+{
+	unsigned long val;
+
+	asm volatile("mfdec %0" : "=r" (val) :);
+	return val;
+}
+
+
+static __inline__ void
+set_dec(unsigned long val)
+{
+	asm volatile("mtdec %0" : : "r" (val)); 
+}
+
+
+void
+enable_interrupts(void)
+{
+    set_msr (get_msr() | MSR_EE);
+}
+
+/* returns flag if MSR_EE was set before */
+int
+disable_interrupts(void)
+{
+    ulong msr;
+
+    msr = get_msr();
+    set_msr (msr & ~MSR_EE);
+    return ((msr & MSR_EE) != 0);
+}
+
+u8 in8(u32 port)
+{
+    return in_byte(port);
+}
+
+void out8(u32 port, u8 val)
+{
+    out_byte(port, val);
+}
+
+unsigned long in32(u32 port)
+{
+    return in_long(port);
+}
+
+unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
+{
+        unsigned long result = 0,value;
+
+        if (*cp == '0') {
+                cp++;
+                if ((*cp == 'x') && isxdigit(cp[1])) {
+                        base = 16;
+                        cp++;
+                }
+                if (!base) {
+                        base = 8;
+                }
+        }
+        if (!base) {
+                base = 10;
+        }
+        while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
+            ? toupper(*cp) : *cp)-'A'+10) < base) {
+                result = result*base + value;
+                cp++;
+        }
+        if (endp)
+                *endp = (char *)cp;
+        return result;
+}
+
+long simple_strtol(const char *cp,char **endp,unsigned int base)
+{
+        if(*cp=='-')
+                return -simple_strtoul(cp+1,endp,base);
+        return simple_strtoul(cp,endp,base);
+}
+
+static inline void
+soft_restart(unsigned long addr)
+{
+        /* SRR0 has system reset vector, SRR1 has default MSR value */
+        /* rfi restores MSR from SRR1 and sets the PC to the SRR0 value */
+
+        __asm__ __volatile__ ("mtspr    26, %0"         :: "r" (addr));
+        __asm__ __volatile__ ("li       4, (1 << 6)"    ::: "r4");
+        __asm__ __volatile__ ("mtspr    27, 4");
+        __asm__ __volatile__ ("rfi");
+
+        while(1);       /* not reached */
+}
+
+void
+do_reset (void)
+{
+        ulong addr;
+        /* flush and disable I/D cache */
+        __asm__ __volatile__ ("mfspr    3, 1008"        ::: "r3");
+        __asm__ __volatile__ ("ori      5, 5, 0xcc00"   ::: "r5");
+        __asm__ __volatile__ ("ori      4, 3, 0xc00"    ::: "r4");
+        __asm__ __volatile__ ("andc     5, 3, 5"        ::: "r5");
+        __asm__ __volatile__ ("sync");
+        __asm__ __volatile__ ("mtspr    1008, 4");
+        __asm__ __volatile__ ("isync");
+        __asm__ __volatile__ ("sync");
+        __asm__ __volatile__ ("mtspr    1008, 5");
+        __asm__ __volatile__ ("isync");
+        __asm__ __volatile__ ("sync");
+
+#ifdef CFG_RESET_ADDRESS
+        addr = CFG_RESET_ADDRESS;
+#else
+        /*
+         * note: when CFG_MONITOR_BASE points to a RAM address,
+         * CFG_MONITOR_BASE - sizeof (ulong) is usually a valid
+         * address. Better pick an address known to be invalid on your
+         * system and assign it to CFG_RESET_ADDRESS.
+         */
+        addr = CFG_MONITOR_BASE - sizeof (ulong);
+#endif
+        soft_restart(addr);
+        while(1);       /* not reached */
+}
-- 
GitLab