1 | /*␊ |
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_LICENSE_HEADER_START@␊ |
5 | * ␊ |
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights␊ |
7 | * Reserved. This file contains Original Code and/or Modifications of␊ |
8 | * Original Code as defined in and that are subject to the Apple Public␊ |
9 | * Source License Version 2.0 (the "License"). You may not use this file␊ |
10 | * except in compliance with the License. Please obtain a copy of the␊ |
11 | * License at http://www.apple.com/publicsource and read it before using␊ |
12 | * this file.␊ |
13 | * ␊ |
14 | * The Original Code and all software distributed under the License are␊ |
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the␊ |
19 | * License for the specific language governing rights and limitations␊ |
20 | * under the License.␊ |
21 | * ␊ |
22 | * @APPLE_LICENSE_HEADER_END@␊ |
23 | */␊ |
24 | /* ␊ |
25 | * Mach Operating System␊ |
26 | * Copyright (c) 1990 Carnegie-Mellon University␊ |
27 | * Copyright (c) 1989 Carnegie-Mellon University␊ |
28 | * All rights reserved. The CMU software License Agreement specifies␊ |
29 | * the terms and conditions for use and redistribution.␊ |
30 | */␊ |
31 | ␊ |
32 | /*␊ |
33 | * ␉␉␉INTEL CORPORATION PROPRIETARY INFORMATION␊ |
34 | *␊ |
35 | *␉This software is supplied under the terms of a license agreement or ␊ |
36 | *␉nondisclosure agreement with Intel Corporation and may not be copied ␊ |
37 | *␉nor disclosed except in accordance with the terms of that agreement.␊ |
38 | *␊ |
39 | *␉Copyright 1988, 1989 Intel Corporation␊ |
40 | */␊ |
41 | ␊ |
42 | /*␊ |
43 | * Copyright 1993 NeXT, Inc.␊ |
44 | * All rights reserved.␊ |
45 | */␊ |
46 | ␊ |
47 | //#include "libsaio.h"␊ |
48 | #include "libsa.h"␊ |
49 | #include "saio_internal.h"␊ |
50 | #include "io_inline.h"␊ |
51 | ␊ |
52 | /*␊ |
53 | * keyboard controller (8042) I/O port addresses␊ |
54 | */␊ |
55 | #define PORT_A 0x60 /* port A */␊ |
56 | #define PORT_B 0x64 /* port B */␊ |
57 | ␊ |
58 | /*␊ |
59 | * keyboard controller command␊ |
60 | */␊ |
61 | #define CMD_WOUT 0xd1 /* write controller's output port */␊ |
62 | ␊ |
63 | /*␊ |
64 | * keyboard controller status flags␊ |
65 | */␊ |
66 | #define KB_INFULL 0x2 /* input buffer full */␊ |
67 | #define KB_OUTFULL 0x1 /* output buffer full */␊ |
68 | ␊ |
69 | #define KB_A20 0x9f /* enable A20,␊ |
70 | enable output buffer full interrupt␊ |
71 | enable data line␊ |
72 | disable clock line */␊ |
73 | ␊ |
74 | //==========================================================================␊ |
75 | // Enable A20 gate to be able to access memory above 1MB␊ |
76 | ␊ |
77 | static inline void flushKeyboardInputBuffer()␊ |
78 | {␊ |
79 | unsigned char ret;␊ |
80 | /* Apparently all flags on means that they're invalid and that the code␊ |
81 | should stop trying to check them because they'll never change */␊ |
82 | do␊ |
83 | {␊ |
84 | ret = inb(PORT_B);␊ |
85 | } while( (ret != 0xff) && (ret & KB_INFULL));␊ |
86 | }␊ |
87 | ␊ |
88 | void enableA20()␊ |
89 | {␊ |
90 | /* make sure that the input buffer is empty */␊ |
91 | flushKeyboardInputBuffer();␊ |
92 | ␊ |
93 | /* make sure that the output buffer is empty */␊ |
94 | if (inb(PORT_B) & KB_OUTFULL)␊ |
95 | (void)inb(PORT_A);␊ |
96 | ␊ |
97 | /* make sure that the input buffer is empty */␊ |
98 | flushKeyboardInputBuffer();␊ |
99 | ␊ |
100 | /* write output port */␊ |
101 | outb(PORT_B, CMD_WOUT);␊ |
102 | delay(100);␊ |
103 | ␊ |
104 | /* wait until command is accepted */␊ |
105 | flushKeyboardInputBuffer();␊ |
106 | ␊ |
107 | outb(PORT_A, KB_A20);␊ |
108 | delay(100);␊ |
109 | ␊ |
110 | /* wait until done */␊ |
111 | flushKeyboardInputBuffer();␊ |
112 | }␊ |
113 | ␊ |
114 | //==========================================================================␊ |
115 | // Return the platform name for this hardware.␊ |
116 | //␊ |
117 | #ifndef BOOT1␊ |
118 | void␊ |
119 | getPlatformName(char *nameBuf)␊ |
120 | {␊ |
121 | strcpy(nameBuf, "ACPI");␊ |
122 | }␊ |
123 | #endif␊ |
124 | |