1 | ; $Id: bs3-cmn-A20Disable.asm 106061 2024-09-16 14:03:52Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - Bs3A20Disable.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2007-2024 Oracle and/or its affiliates.
|
---|
8 | ;
|
---|
9 | ; This file is part of VirtualBox base platform packages, as
|
---|
10 | ; available from https://www.virtualbox.org.
|
---|
11 | ;
|
---|
12 | ; This program is free software; you can redistribute it and/or
|
---|
13 | ; modify it under the terms of the GNU General Public License
|
---|
14 | ; as published by the Free Software Foundation, in version 3 of the
|
---|
15 | ; License.
|
---|
16 | ;
|
---|
17 | ; This program is distributed in the hope that it will be useful, but
|
---|
18 | ; WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | ; General Public License for more details.
|
---|
21 | ;
|
---|
22 | ; You should have received a copy of the GNU General Public License
|
---|
23 | ; along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | ;
|
---|
25 | ; The contents of this file may alternatively be used under the terms
|
---|
26 | ; of the Common Development and Distribution License Version 1.0
|
---|
27 | ; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | ; in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | ; CDDL are applicable instead of those of the GPL.
|
---|
30 | ;
|
---|
31 | ; You may elect to license modified versions of this file under the
|
---|
32 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | ;
|
---|
34 | ; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | ;
|
---|
36 |
|
---|
37 | %include "bs3kit-template-header.mac"
|
---|
38 |
|
---|
39 |
|
---|
40 | BS3_EXTERN_CMN Bs3KbdWait
|
---|
41 | BS3_EXTERN_CMN Bs3KbdRead
|
---|
42 | BS3_EXTERN_CMN Bs3KbdWrite
|
---|
43 |
|
---|
44 |
|
---|
45 | ;;
|
---|
46 | ; Disables the A20 gate.
|
---|
47 | ;
|
---|
48 | ; @uses Nothing.
|
---|
49 | ;
|
---|
50 | BS3_PROC_BEGIN_CMN Bs3A20Disable, BS3_PBC_HYBRID_0_ARGS
|
---|
51 | ; Must call both because they may be ORed together on real HW.
|
---|
52 | BONLY64 sub rsp, 20h
|
---|
53 | call BS3_CMN_NM(Bs3A20DisableViaKbd)
|
---|
54 | call BS3_CMN_NM(Bs3A20DisableViaPortA)
|
---|
55 | BONLY64 add rsp, 20h
|
---|
56 | BS3_HYBRID_RET
|
---|
57 | BS3_PROC_END_CMN Bs3A20Disable
|
---|
58 |
|
---|
59 |
|
---|
60 | ;;
|
---|
61 | ; Disables the A20 gate via control port A (PS/2 style).
|
---|
62 | ;
|
---|
63 | ; @uses Nothing.
|
---|
64 | ;
|
---|
65 | BS3_PROC_BEGIN_CMN Bs3A20DisableViaPortA, BS3_PBC_HYBRID_0_ARGS
|
---|
66 | push xAX
|
---|
67 |
|
---|
68 | ; Use Control port A, assuming a PS/2 style system.
|
---|
69 | in al, 092h
|
---|
70 | test al, 02h
|
---|
71 | jz .done ; avoid trouble writing back the same value.
|
---|
72 | and al, 0fdh ; disable the A20 gate.
|
---|
73 | out 092h, al
|
---|
74 |
|
---|
75 | .done:
|
---|
76 | pop xAX
|
---|
77 | BS3_HYBRID_RET
|
---|
78 | BS3_PROC_END_CMN Bs3A20DisableViaPortA
|
---|
79 |
|
---|
80 |
|
---|
81 | ;;
|
---|
82 | ; Disables the A20 gate via the keyboard controller.
|
---|
83 | ;
|
---|
84 | ; @uses Nothing.
|
---|
85 | ;
|
---|
86 | BS3_PROC_BEGIN_CMN Bs3A20DisableViaKbd, BS3_PBC_HYBRID_0_ARGS
|
---|
87 | push xBP
|
---|
88 | mov xBP, xSP
|
---|
89 | push xAX
|
---|
90 | pushf
|
---|
91 | cli
|
---|
92 | BONLY64 sub rsp, 20h
|
---|
93 |
|
---|
94 | call Bs3KbdWait
|
---|
95 | push 0d0h ; KBD_CCMD_READ_OUTPORT
|
---|
96 | call Bs3KbdRead
|
---|
97 |
|
---|
98 | and al, 0fdh ; ~2
|
---|
99 | push xAX
|
---|
100 | push 0d1h ; KBD_CCMD_WRITE_OUTPORT
|
---|
101 | call Bs3KbdWrite
|
---|
102 |
|
---|
103 | add xSP, xCB*3 ; Clean up both the above calls.
|
---|
104 |
|
---|
105 | mov al, 0ffh ; KBD_CMD_RESET
|
---|
106 | out 64h, al
|
---|
107 | call Bs3KbdWait
|
---|
108 |
|
---|
109 | BONLY64 add rsp, 20h
|
---|
110 | popf
|
---|
111 | pop xAX
|
---|
112 | pop xBP
|
---|
113 | BS3_HYBRID_RET
|
---|
114 | BS3_PROC_END_CMN Bs3A20DisableViaKbd
|
---|
115 |
|
---|