VirtualBox

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

Last change on this file since 93115 was 93115, checked in by vboxsync, 2 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/* $Id: serial.c 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * PC BIOS - ???
4 */
5
6/*
7 * Copyright (C) 2006-2022 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 "inlines.h"
58#include "biosint.h"
59
60void BIOSCALL int14_function(pusha_regs_t regs, uint16_t es, uint16_t ds, volatile iret_addr_t iret_addr)
61{
62 uint16_t addr, timer, val16;
63 uint8_t timeout;
64
65 int_enable();
66
67 addr = read_word(0x0040, (regs.u.r16.dx << 1));
68 timeout = read_byte(0x0040, 0x007C + regs.u.r16.dx);
69 if ((regs.u.r16.dx < 4) && (addr > 0)) {
70 switch (regs.u.r8.ah) {
71 case 0:
72 outb(addr+3, inb(addr+3) | 0x80);
73 if ((regs.u.r8.al & 0xE0) == 0) {
74 outb(addr, 0x17);
75 outb(addr+1, 0x04);
76 } else {
77 val16 = 0x600 >> ((regs.u.r8.al & 0xE0) >> 5);
78 outb(addr, val16 & 0xFF);
79 outb(addr+1, val16 >> 8);
80 }
81 outb(addr+3, regs.u.r8.al & 0x1F);
82 regs.u.r8.ah = inb(addr+5);
83 regs.u.r8.al = inb(addr+6);
84 ClearCF(iret_addr.flags);
85 break;
86 case 1:
87 timer = read_word(0x0040, 0x006C);
88 while (((inb(addr+5) & 0x60) != 0x60) && (timeout)) {
89 val16 = read_word(0x0040, 0x006C);
90 if (val16 != timer) {
91 timer = val16;
92 timeout--;
93 }
94 }
95 if (timeout) outb(addr, regs.u.r8.al);
96 regs.u.r8.ah = inb(addr+5);
97 if (!timeout) regs.u.r8.ah |= 0x80;
98 ClearCF(iret_addr.flags);
99 break;
100 case 2:
101 timer = read_word(0x0040, 0x006C);
102 while (((inb(addr+5) & 0x01) == 0) && (timeout)) {
103 val16 = read_word(0x0040, 0x006C);
104 if (val16 != timer) {
105 timer = val16;
106 timeout--;
107 }
108 }
109 if (timeout) {
110 regs.u.r8.ah = 0;
111 regs.u.r8.al = inb(addr);
112 } else {
113 regs.u.r8.ah = inb(addr+5);
114 }
115 ClearCF(iret_addr.flags);
116 break;
117 case 3:
118 regs.u.r8.ah = inb(addr+5);
119 regs.u.r8.al = inb(addr+6);
120 ClearCF(iret_addr.flags);
121 break;
122 default:
123 SetCF(iret_addr.flags); // Unsupported
124 }
125 } else {
126 SetCF(iret_addr.flags); // Unsupported
127 }
128}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use