1 | ; $Id: bs3-cmn-A20Enable.asm 98103 2023-01-17 14:15:46Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - Bs3A20Enable.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2007-2023 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 | ; Enables the A20 gate.
|
---|
47 | ;
|
---|
48 | ; @uses Nothing.
|
---|
49 | ;
|
---|
50 | BS3_PROC_BEGIN_CMN Bs3A20Enable, BS3_PBC_HYBRID_0_ARGS
|
---|
51 | push xBP
|
---|
52 | mov xBP, xSP
|
---|
53 | BONLY64 sub rsp, 20h
|
---|
54 |
|
---|
55 | call BS3_CMN_NM(Bs3A20EnableViaPortA)
|
---|
56 | ;; @todo real 286 support
|
---|
57 | ; call BS3_CMN_NM(Bs3A20EnableViaKbd)
|
---|
58 |
|
---|
59 | pop xBP
|
---|
60 | BS3_HYBRID_RET
|
---|
61 | BS3_PROC_END_CMN Bs3A20Enable
|
---|
62 |
|
---|
63 |
|
---|
64 | ;;
|
---|
65 | ; Enables the A20 gate via the keyboard controller.
|
---|
66 | ;
|
---|
67 | ; @uses Nothing.
|
---|
68 | ;
|
---|
69 | BS3_PROC_BEGIN_CMN Bs3A20EnableViaKbd, BS3_PBC_HYBRID_0_ARGS
|
---|
70 | push xBP
|
---|
71 | mov xBP, xSP
|
---|
72 | push xAX
|
---|
73 | pushf
|
---|
74 | cli
|
---|
75 | BONLY64 sub rsp, 20h
|
---|
76 |
|
---|
77 | call Bs3KbdWait
|
---|
78 | push 0d0h ; KBD_CCMD_READ_OUTPORT
|
---|
79 | call Bs3KbdRead
|
---|
80 |
|
---|
81 | or al, 002h
|
---|
82 | push xAX
|
---|
83 | push 0d1h ; KBD_CCMD_WRITE_OUTPORT
|
---|
84 | call Bs3KbdWrite
|
---|
85 |
|
---|
86 | add xSP, xCB*3 ; both the above calls
|
---|
87 |
|
---|
88 | mov al, 0ffh ; KBD_CMD_RESET
|
---|
89 | out 64h, al
|
---|
90 | call Bs3KbdWait
|
---|
91 |
|
---|
92 | BONLY64 add rsp, 20h
|
---|
93 | popf
|
---|
94 | pop xAX
|
---|
95 | pop xBP
|
---|
96 | BS3_HYBRID_RET
|
---|
97 | BS3_PROC_END_CMN Bs3A20EnableViaKbd
|
---|
98 |
|
---|
99 |
|
---|
100 | ;;
|
---|
101 | ; Enables the A20 gate via control port A (PS/2 style).
|
---|
102 | ;
|
---|
103 | ; @uses Nothing.
|
---|
104 | ;
|
---|
105 | BS3_PROC_BEGIN_CMN Bs3A20EnableViaPortA, BS3_PBC_HYBRID_0_ARGS
|
---|
106 | push xBP
|
---|
107 | mov xBP, xSP
|
---|
108 | push xAX
|
---|
109 |
|
---|
110 | ; Use Control port A, assuming a PS/2 style system.
|
---|
111 | in al, 092h
|
---|
112 | test al, 02h
|
---|
113 | jnz .done ; avoid trouble writing back the same value.
|
---|
114 | or al, 2 ; enable the A20 gate.
|
---|
115 | out 092h, al
|
---|
116 |
|
---|
117 | .done:
|
---|
118 | pop xAX
|
---|
119 | pop xBP
|
---|
120 | BS3_HYBRID_RET
|
---|
121 | BS3_PROC_END_CMN Bs3A20EnableViaPortA
|
---|
122 |
|
---|