1/*	Copyright 1992 NCR Corporation - Dayton, Ohio, USA */
2
3/* $XFree86: mit/server/ddx/x386/vga256/drivers/ncr/ncr_bank.s,v 1.1 1993/03/08 12:09:02 dawes Exp $ */
4
5/*
6 * Copyright 1992,1993 NCR Corporation, Inc.
7 *
8 * Permission to use, copy, modify, and distribute this software and
9 * it's documentation for any purpose and without fee is hereby
10 * granted, provided that the above copyright notice appear in all
11 * copies and that both that copyright notice and this permission
12 * notice appear in supporting documentation, and that the name of
13 * NCR not be used in advertising or publicity
14 * pertaining to distribution of the software without specific,
15 * written prior permission.  NCR makes no
16 * representations about the suitability of this software for any
17 * purpose.  It is provided "as is" without express or implied
18 * warranty.
19 *
20 * NCR DISCLAIMs ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
21 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
22 * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL,
23 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
24 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
25 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
26 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 */
28
29/*
30 * These are here the very lowlevel VGA bankswitching routines.
31 * The segment to switch to is passed via %eax. Only %eax and %edx my be used
32 * without saving the original contents.
33 *
34 * WHY ASSEMBLY LANGUAGE ???
35 *
36 * These routines must be callable by other assembly routines. But I don't
37 * want to have the overhead of pushing and poping the normal stack-frame.
38 */
39
40/*
41 * what happens really here ?
42 *
43 * Primary Host Offset and Secondary Host Offset are segmentpointers to
44 * two segments.  One for Read (Secondary) and one for Write (Primary).
45 *
46 * Window size of 128K is being used. This results in a shift of 13 bits
47 * to put the segment number in the higest 3 bits of the Offset register.
48 * Because we are also using Extended chain 4 mode (CHX4), there is already
49 * a two bit shift in place. This means that we only have to shift 11 bit
50 * to get everything right.
51 */
52
53#include "assyntax.h"
54
55	FILE("ncr_bank.s")
56
57	AS_BEGIN
58
59	SEG_TEXT
60
61/*
62 * for Read operations, we are using Secondary offset address as write pointer
63 * to a 128k window.
64 * for Write operations, we are using Primary offset address as write pointer
65 * to a 128k window.
66 */
67	ALIGNTEXT4
68	GLOBL GLNAME(NCRSetReadWrite)
69GLNAME(NCRSetReadWrite):
70	SHL_L	(CONST(11),EAX)       /* combined %al*32 & movb %al,%ah */
71	MOV_B	(CONST(0x18),AL)
72	MOV_L	(CONST(0x3C4),EDX)
73	OUT_W
74	MOV_B	(CONST(0x1C),AL)
75	MOV_L	(CONST(0x3C4),EDX)
76	OUT_W
77	RET
78
79/*
80 * for Write operations, we are using Primary offset address as write pointer
81 * to a 128k window.
82 */
83	ALIGNTEXT4
84	GLOBL GLNAME(NCRSetWrite)
85GLNAME(NCRSetWrite):
86	SHL_L	(CONST(11),EAX)
87	MOV_B	(CONST(0x18),AL)
88	MOV_L	(CONST(0x3C4),EDX)
89	OUT_W
90	RET
91
92/*
93 * for Read operations, we are using Secondary offset address as write pointer
94 * to a 128k window.
95 */
96	ALIGNTEXT4
97	GLOBL GLNAME(NCRSetRead)
98GLNAME(NCRSetRead):
99	SHL_L	(CONST(11),EAX)
100	MOV_B	(CONST(0x1C),AL)
101	MOV_L	(CONST(0x3C4),EDX)
102	OUT_W
103	RET
104