1 | /*
|
---|
2 | * Copyright (C) 2006-2017 Oracle Corporation
|
---|
3 | *
|
---|
4 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
5 | * available from http://www.virtualbox.org. This file is free software;
|
---|
6 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
7 | * General Public License (GPL) as published by the Free Software
|
---|
8 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
9 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
10 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
11 | * --------------------------------------------------------------------
|
---|
12 | *
|
---|
13 | * This code is based on:
|
---|
14 | *
|
---|
15 | * ROM BIOS for use with Bochs/Plex86/QEMU emulation environment
|
---|
16 | *
|
---|
17 | * Copyright (C) 2002 MandrakeSoft S.A.
|
---|
18 | *
|
---|
19 | * MandrakeSoft S.A.
|
---|
20 | * 43, rue d'Aboukir
|
---|
21 | * 75002 Paris - France
|
---|
22 | * http://www.linux-mandrake.com/
|
---|
23 | * http://www.mandrakesoft.com/
|
---|
24 | *
|
---|
25 | * This library is free software; you can redistribute it and/or
|
---|
26 | * modify it under the terms of the GNU Lesser General Public
|
---|
27 | * License as published by the Free Software Foundation; either
|
---|
28 | * version 2 of the License, or (at your option) any later version.
|
---|
29 | *
|
---|
30 | * This library is distributed in the hope that it will be useful,
|
---|
31 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
32 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
33 | * Lesser General Public License for more details.
|
---|
34 | *
|
---|
35 | * You should have received a copy of the GNU Lesser General Public
|
---|
36 | * License along with this library; if not, write to the Free Software
|
---|
37 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
38 | *
|
---|
39 | */
|
---|
40 |
|
---|
41 |
|
---|
42 | #include <stdint.h>
|
---|
43 | #include "inlines.h"
|
---|
44 | #include "biosint.h"
|
---|
45 |
|
---|
46 | void BIOSCALL int14_function(pusha_regs_t regs, uint16_t es, uint16_t ds, volatile iret_addr_t iret_addr)
|
---|
47 | {
|
---|
48 | uint16_t addr, timer, val16;
|
---|
49 | uint8_t timeout;
|
---|
50 |
|
---|
51 | int_enable();
|
---|
52 |
|
---|
53 | addr = read_word(0x0040, (regs.u.r16.dx << 1));
|
---|
54 | timeout = read_byte(0x0040, 0x007C + regs.u.r16.dx);
|
---|
55 | if ((regs.u.r16.dx < 4) && (addr > 0)) {
|
---|
56 | switch (regs.u.r8.ah) {
|
---|
57 | case 0:
|
---|
58 | outb(addr+3, inb(addr+3) | 0x80);
|
---|
59 | if ((regs.u.r8.al & 0xE0) == 0) {
|
---|
60 | outb(addr, 0x17);
|
---|
61 | outb(addr+1, 0x04);
|
---|
62 | } else {
|
---|
63 | val16 = 0x600 >> ((regs.u.r8.al & 0xE0) >> 5);
|
---|
64 | outb(addr, val16 & 0xFF);
|
---|
65 | outb(addr+1, val16 >> 8);
|
---|
66 | }
|
---|
67 | outb(addr+3, regs.u.r8.al & 0x1F);
|
---|
68 | regs.u.r8.ah = inb(addr+5);
|
---|
69 | regs.u.r8.al = inb(addr+6);
|
---|
70 | ClearCF(iret_addr.flags);
|
---|
71 | break;
|
---|
72 | case 1:
|
---|
73 | timer = read_word(0x0040, 0x006C);
|
---|
74 | while (((inb(addr+5) & 0x60) != 0x60) && (timeout)) {
|
---|
75 | val16 = read_word(0x0040, 0x006C);
|
---|
76 | if (val16 != timer) {
|
---|
77 | timer = val16;
|
---|
78 | timeout--;
|
---|
79 | }
|
---|
80 | }
|
---|
81 | if (timeout) outb(addr, regs.u.r8.al);
|
---|
82 | regs.u.r8.ah = inb(addr+5);
|
---|
83 | if (!timeout) regs.u.r8.ah |= 0x80;
|
---|
84 | ClearCF(iret_addr.flags);
|
---|
85 | break;
|
---|
86 | case 2:
|
---|
87 | timer = read_word(0x0040, 0x006C);
|
---|
88 | while (((inb(addr+5) & 0x01) == 0) && (timeout)) {
|
---|
89 | val16 = read_word(0x0040, 0x006C);
|
---|
90 | if (val16 != timer) {
|
---|
91 | timer = val16;
|
---|
92 | timeout--;
|
---|
93 | }
|
---|
94 | }
|
---|
95 | if (timeout) {
|
---|
96 | regs.u.r8.ah = 0;
|
---|
97 | regs.u.r8.al = inb(addr);
|
---|
98 | } else {
|
---|
99 | regs.u.r8.ah = inb(addr+5);
|
---|
100 | }
|
---|
101 | ClearCF(iret_addr.flags);
|
---|
102 | break;
|
---|
103 | case 3:
|
---|
104 | regs.u.r8.ah = inb(addr+5);
|
---|
105 | regs.u.r8.al = inb(addr+6);
|
---|
106 | ClearCF(iret_addr.flags);
|
---|
107 | break;
|
---|
108 | default:
|
---|
109 | SetCF(iret_addr.flags); // Unsupported
|
---|
110 | }
|
---|
111 | } else {
|
---|
112 | SetCF(iret_addr.flags); // Unsupported
|
---|
113 | }
|
---|
114 | }
|
---|