1 | /* $Id: parallel.c 76553 2019-01-01 01:45:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * PC BIOS - ???
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | * --------------------------------------------------------------------
|
---|
17 | *
|
---|
18 | * This code is based on:
|
---|
19 | *
|
---|
20 | * ROM BIOS for use with Bochs/Plex86/QEMU emulation environment
|
---|
21 | *
|
---|
22 | * Copyright (C) 2002 MandrakeSoft S.A.
|
---|
23 | *
|
---|
24 | * MandrakeSoft S.A.
|
---|
25 | * 43, rue d'Aboukir
|
---|
26 | * 75002 Paris - France
|
---|
27 | * http://www.linux-mandrake.com/
|
---|
28 | * http://www.mandrakesoft.com/
|
---|
29 | *
|
---|
30 | * This library is free software; you can redistribute it and/or
|
---|
31 | * modify it under the terms of the GNU Lesser General Public
|
---|
32 | * License as published by the Free Software Foundation; either
|
---|
33 | * version 2 of the License, or (at your option) any later version.
|
---|
34 | *
|
---|
35 | * This library is distributed in the hope that it will be useful,
|
---|
36 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
37 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
38 | * Lesser General Public License for more details.
|
---|
39 | *
|
---|
40 | * You should have received a copy of the GNU Lesser General Public
|
---|
41 | * License along with this library; if not, write to the Free Software
|
---|
42 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
43 | *
|
---|
44 | */
|
---|
45 |
|
---|
46 | /*
|
---|
47 | * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
48 | * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
|
---|
49 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
50 | * a choice of LGPL license versions is made available with the language indicating
|
---|
51 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
52 | * of the LGPL is applied is otherwise unspecified.
|
---|
53 | */
|
---|
54 |
|
---|
55 |
|
---|
56 | #include <stdint.h>
|
---|
57 | #include "biosint.h"
|
---|
58 | #include "inlines.h"
|
---|
59 |
|
---|
60 | void BIOSCALL int17_function(pusha_regs_t regs, uint16_t es, uint16_t ds, volatile iret_addr_t iret_addr)
|
---|
61 | {
|
---|
62 | uint16_t addr,timeout;
|
---|
63 | uint8_t val8;
|
---|
64 |
|
---|
65 | int_enable();
|
---|
66 |
|
---|
67 | addr = read_word(0x0040, (regs.u.r16.dx << 1) + 8);
|
---|
68 | if ((regs.u.r8.ah < 3) && (regs.u.r16.dx < 3) && (addr > 0)) {
|
---|
69 | timeout = read_byte(0x0040, 0x0078 + regs.u.r16.dx) << 8;
|
---|
70 | if (regs.u.r8.ah == 0) {
|
---|
71 | outb(addr, regs.u.r8.al);
|
---|
72 | val8 = inb(addr+2);
|
---|
73 | outb(addr+2, val8 | 0x01); // send strobe
|
---|
74 | outb(addr+2, val8 & ~0x01);
|
---|
75 | while (((inb(addr+1) & 0x40) == 0x40) && (timeout)) {
|
---|
76 | timeout--;
|
---|
77 | }
|
---|
78 | }
|
---|
79 | if (regs.u.r8.ah == 1) {
|
---|
80 | val8 = inb(addr+2);
|
---|
81 | outb(addr+2, val8 & ~0x04); // send init
|
---|
82 | outb(addr+2, val8 | 0x04);
|
---|
83 | }
|
---|
84 | val8 = inb(addr+1);
|
---|
85 | regs.u.r8.ah = (val8 ^ 0x48);
|
---|
86 | if (!timeout) regs.u.r8.ah |= 0x01;
|
---|
87 | ClearCF(iret_addr.flags);
|
---|
88 | } else {
|
---|
89 | SetCF(iret_addr.flags); // Unsupported
|
---|
90 | }
|
---|
91 | }
|
---|