VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/BIOS/serial.c@ 69496

Last change on this file since 69496 was 69496, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette