DevPcArch.cpp revision 6b362bc00d2820ca57d348a77ddb1dc558dc94f8
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * DevPcArch - PC Architecture Device.
99f33ab590a3a65e0cd082dd8d67779efb9cc6c9vboxsync * Copyright (C) 2006-2012 Oracle Corporation
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * available from http://www.virtualbox.org. This file is free software;
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * you can redistribute it and/or modify it under the terms of the GNU
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * General Public License (GPL) as published by the Free Software
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync/*******************************************************************************
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync* Header Files *
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync*******************************************************************************/
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync/*******************************************************************************
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync* Structures and Typedefs *
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync*******************************************************************************/
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * PC Bios instance data structure.
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsynctypedef struct DEVPCARCH
7b4c4bb29760b28b5727231ad446462a5b0cc01avboxsync /** Pointer back to the device instance. */
5c127165d63f95b1763b4af2a2c6ae1025fc84fevboxsync * @callback_method_impl{FNIOMIOPORTIN, Math coprocessor.}
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsyncstatic DECLCALLBACK(int) pcarchIOPortFPURead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync rc = PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "Port=%#x cb=%d\n", Port, cb);
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * @callback_method_impl{FNIOMIOPORTOUT, Math coprocessor.}
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * @todo Add IGNNE support.
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsyncstatic DECLCALLBACK(int) pcarchIOPortFPUWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * Clear busy latch.
99f33ab590a3a65e0cd082dd8d67779efb9cc6c9vboxsync Log2(("PCARCH: FPU Clear busy latch u32=%#x\n", u32));
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync/* This is triggered when booting Knoppix (3.7) */
99f33ab590a3a65e0cd082dd8d67779efb9cc6c9vboxsync rc = PDMDeviceDBGFStop(pDevIns, RT_SRC_POS, "Port=%#x cb=%d u32=%#x\n", Port, cb, u32);
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* pDevIns->pHlp->pfnPICSetIrq(pDevIns, 13, 0); */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* Reset. */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync Log2(("PCARCH: FPU Reset cb=%d u32=%#x\n", Port, cb, u32));
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /** @todo figure out what the difference between FPU ports 0xf0 and 0xf1 are... */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* pDevIns->pHlp->pfnPICSetIrq(pDevIns, 13, 0); */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* opcode transfers */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync rc = PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "Port=%#x cb=%d u32=%#x\n", Port, cb, u32);
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* this works better, but probably not entirely correct. */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync rc = PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "Port=%#x cb=%d u32=%#x\n", Port, cb, u32);
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * @callback_method_impl{FNIOMIOPORTIN, PS/2 system control port A.}
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * @todo Check if the A20 enable/disable method implemented here in any way
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * should cooperate with the one implemented in the PS/2 keyboard device.
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * This probably belongs together in the PS/2 keyboard device (since that
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * is where the "port B" mentioned by Ralph Brown is implemented).
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * @remark Ralph Brown and friends have this to say about this port:
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * @verbatim
99f33ab590a3a65e0cd082dd8d67779efb9cc6c9vboxsync0092 RW PS/2 system control port A (port B is at PORT 0061h) (see #P0415)
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsyncBitfields for PS/2 system control port A:
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsyncBit(s) Description (Table P0415)
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync 7-6 any bit set to 1 turns activity light on
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync 4 watchdog timout occurred
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync 3 =0 RTC/CMOS security lock (on password area) unlocked
99f33ab590a3a65e0cd082dd8d67779efb9cc6c9vboxsync =1 CMOS locked (done by POST)
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync 1 A20 is active
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync 0 =0 system reset or write
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync =1 pulse alternate reset pin (high-speed alternate CPU reset)
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsyncNotes: once set, bit 3 may only be cleared by a power-on reset
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync on at least the C&T 82C235, bit 0 remains set through a CPU reset to
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync allow the BIOS to determine the reset method
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync on the PS/2 30-286 & "Tortuga" the INT 15h/87h memory copy does
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync not use this port for A20 control, but instead uses the keyboard
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync controller (8042). Reportedly this may cause the system to crash
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync when access to the 8042 is disabled in password server mode
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync (see #P0398).
7b4c4bb29760b28b5727231ad446462a5b0cc01avboxsyncSeeAlso: #P0416,#P0417,MSR 00001000h
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * @endverbatim
99f33ab590a3a65e0cd082dd8d67779efb9cc6c9vboxsyncpcarchIOPortPS2SysControlPortARead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "Port=%#x cb=%d\n", Port, cb);
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * @callback_method_impl{FNIOMIOPORTOUT, PS/2 system control port A.}
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * @see Remark and todo of pcarchIOPortPS2SysControlPortARead().
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsyncpcarchIOPortPS2SysControlPortAWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * Fast reset?
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * A20 is the only thing we care about of the other stuff.
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "Port=%#x cb=%d u32=%#x\n", Port, cb, u32);
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * @interface_method_impl{PDMDEVREG,pfnConstruct}
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsyncstatic DECLCALLBACK(int) pcarchConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync PDEVPCARCH pThis = PDMINS_2_DATA(pDevIns, PDEVPCARCH);
99f33ab590a3a65e0cd082dd8d67779efb9cc6c9vboxsync * Validate configuration.
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * Init the data.
7b4c4bb29760b28b5727231ad446462a5b0cc01avboxsync * Register I/O Ports
7b4c4bb29760b28b5727231ad446462a5b0cc01avboxsync rc = PDMDevHlpIOPortRegister(pDevIns, 0xF0, 0x10, NULL,
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync rc = PDMDevHlpIOPortRegister(pDevIns, 0x92, 1, NULL,
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync pcarchIOPortPS2SysControlPortAWrite, pcarchIOPortPS2SysControlPortARead,
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync NULL, NULL, "PS/2 system control port A (A20 and more)");
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync * The device registration structure.
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* u32Version */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* szName */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* szRCMod */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* szR0Mod */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* pszDescription */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync "PC Architecture Device",
99f33ab590a3a65e0cd082dd8d67779efb9cc6c9vboxsync /* fFlags */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT | PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT,
7b4c4bb29760b28b5727231ad446462a5b0cc01avboxsync /* fClass */
7b4c4bb29760b28b5727231ad446462a5b0cc01avboxsync /* cMaxInstances */
99f33ab590a3a65e0cd082dd8d67779efb9cc6c9vboxsync /* cbInstance */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* pfnConstruct */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* pfnDestruct */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* pfnRelocate */
7b4c4bb29760b28b5727231ad446462a5b0cc01avboxsync /* pfnIOCtl */
7b4c4bb29760b28b5727231ad446462a5b0cc01avboxsync /* pfnPowerOn */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* pfnReset */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* pfnSuspend */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* pfnResume */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* pfnAttach */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* pfnDetach */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* pfnQueryInterface. */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* pfnInitComplete. */
2a171646d32f8a15e9820d6fb3bf3f9b9990ca3fvboxsync /* pfnPowerOff */
822e11c896dd36c9dc3609dff676059576b7d3devboxsync /* pfnSoftReset */
822e11c896dd36c9dc3609dff676059576b7d3devboxsync /* u32VersionEnd */