1/* $XFree86: mit/server/ddx/x386/vga256/drivers/et4000/bank.s,v 1.11 1993/02/24 10:42:32 dawes Exp $ */
2/*
3 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
4 *
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of Thomas Roell not be used in
10 * advertising or publicity pertaining to distribution of the software without
11 * specific, written prior permission.  Thomas Roell makes no representations
12 * about the suitability of this software for any purpose.  It is provided
13 * "as is" without express or implied warranty.
14 *
15 * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17 * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21 * PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Author:  Thomas Roell, roell@informatik.tu-muenchen.de
24 *
25 * $Header: /proj/X11/mit/server/ddx/x386/drivers/et4000/RCS/bank.s,v 1.1 1991/06/02 22:37:04 root Exp $
26 */
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 * first we have here a mirror for the segment register. That's because a
42 * I/O read costs so much more time, that is better to keep the value of it
43 * in memory.
44 */
45
46#include "assyntax.h"
47
48 	FILE("et4000bank.s")
49
50	AS_BEGIN
51
52	SEG_DATA
53Segment:
54	D_BYTE 0
55
56
57	SEG_TEXT
58
59	ALIGNTEXT4
60	GLOBL	GLNAME(ET4000SetRead)
61GLNAME(ET4000SetRead):
62	MOV_B	(CONTENT(Segment),AH)
63	AND_B	(CONST(0x0f),AH)
64	SHL_B	(CONST(4),AL)
65	OR_B	(AH,AL)
66	MOV_B	(AL,CONTENT(Segment))
67	MOV_L	(CONST(0x3CD),EDX)
68	OUT_B
69	RET
70
71        ALIGNTEXT4
72	GLOBL	GLNAME(ET4000SetWrite)
73GLNAME(ET4000SetWrite):
74	MOV_B	(CONTENT(Segment),AH)
75	AND_B	(CONST(0xf0),AH)
76	OR_B	(AH,AL)
77	MOV_B	(AL,CONTENT(Segment))
78	MOV_L	(CONST(0x3CD),EDX)
79	OUT_B
80	RET
81
82	ALIGNTEXT4
83	GLOBL	GLNAME(ET4000SetReadWrite)
84GLNAME(ET4000SetReadWrite):
85	MOV_B	(AL,AH)
86	SHL_B	(CONST(4),AH)
87	OR_B	(AH,AL)
88	MOV_B	(AL,CONTENT(Segment))
89	MOV_L	(CONST(0x3CD),EDX)
90        OUT_B
91        RET
92