]> git.saurik.com Git - apple/boot.git/blob - i386/libsaio/misc.c
boot-111.tar.gz
[apple/boot.git] / i386 / libsaio / misc.c
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * Mach Operating System
27 * Copyright (c) 1990 Carnegie-Mellon University
28 * Copyright (c) 1989 Carnegie-Mellon University
29 * All rights reserved. The CMU software License Agreement specifies
30 * the terms and conditions for use and redistribution.
31 */
32
33 /*
34 * INTEL CORPORATION PROPRIETARY INFORMATION
35 *
36 * This software is supplied under the terms of a license agreement or
37 * nondisclosure agreement with Intel Corporation and may not be copied
38 * nor disclosed except in accordance with the terms of that agreement.
39 *
40 * Copyright 1988, 1989 Intel Corporation
41 */
42
43 /*
44 * Copyright 1993 NeXT, Inc.
45 * All rights reserved.
46 */
47
48 #include "libsaio.h"
49
50 /*
51 * keyboard controller (8042) I/O port addresses
52 */
53 #define PORT_A 0x60 /* port A */
54 #define PORT_B 0x64 /* port B */
55
56 /*
57 * keyboard controller command
58 */
59 #define CMD_WOUT 0xd1 /* write controller's output port */
60
61 /*
62 * keyboard controller status flags
63 */
64 #define KB_INFULL 0x2 /* input buffer full */
65 #define KB_OUTFULL 0x1 /* output buffer full */
66
67 #define KB_A20 0x9f /* enable A20,
68 enable output buffer full interrupt
69 enable data line
70 disable clock line */
71
72 //==========================================================================
73 // Enable A20 gate to be able to access memory above 1MB
74
75 void enableA20()
76 {
77 /* make sure that the input buffer is empty */
78 while (inb(PORT_B) & KB_INFULL);
79
80 /* make sure that the output buffer is empty */
81 if (inb(PORT_B) & KB_OUTFULL)
82 (void)inb(PORT_A);
83
84 /* make sure that the input buffer is empty */
85 while (inb(PORT_B) & KB_INFULL);
86
87 /* write output port */
88 outb(PORT_B, CMD_WOUT);
89 delay(100);
90
91 /* wait until command is accepted */
92 while (inb(PORT_B) & KB_INFULL);
93
94 outb(PORT_A, KB_A20);
95 delay(100);
96
97 while (inb(PORT_B) & KB_INFULL); /* wait until done */
98 }