3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* $Id: mda.c,v 1.3 2002/09/08 10:23:27 chorns Exp $
21 * PROJECT: ReactOS kernel
22 * FILE: ntoskrnl/kd/mda.c
23 * PURPOSE: Support for debugging using an MDA card.
24 * PROGRAMMER: David Welch <welch@cwcom.net>
27 /* INCLUDES ******************************************************************/
29 #include <ddk/ntddk.h>
30 #include <internal/ntoskrnl.h>
31 #include <internal/kd.h>
32 #include <internal/mm.h>
34 #include "../dbg/kdb.h"
36 /* VARIABLES ***************************************************************/
38 STATIC ULONG MdaIndexPort
;
39 STATIC ULONG MdaValuePort
;
40 STATIC ULONG MdaStatusPort
;
41 STATIC ULONG MdaGfxPort
;
42 STATIC ULONG MdaModePort
;
43 STATIC PUSHORT VideoBuffer
;
45 #define MDA_COLUMNS (80)
46 #define MDA_LINES (25)
48 STATIC ULONG MdaCursorX
, MdaCursorY
;
50 /* PRIVATE FUNCTIONS ********************************************************/
54 KdWriteByteMDA(ULONG Reg
, ULONG Value
)
56 WRITE_PORT_UCHAR((PUCHAR
)MdaIndexPort
, (CHAR
)Reg
);
57 WRITE_PORT_UCHAR((PUCHAR
)MdaValuePort
, (CHAR
)Value
);
61 KdWriteWordMDA(ULONG Reg
, ULONG Value
)
63 WRITE_PORT_UCHAR((PUCHAR
)MdaIndexPort
, (CHAR
)Reg
);
64 WRITE_PORT_UCHAR((PUCHAR
)MdaValuePort
, (CHAR
)(Value
>> 8));
65 WRITE_PORT_UCHAR((PUCHAR
)MdaIndexPort
, (CHAR
)(Reg
+ 1));
66 WRITE_PORT_UCHAR((PUCHAR
)MdaValuePort
, (CHAR
)(Value
& 0xFF));
73 /* Setup the variables for the various port addresses. */
77 MdaStatusPort
= 0x3ba;
80 VideoBuffer
= (PUSHORT
)(0xd0000000 + 0xb0000);
82 MdaCursorX
= MdaCursorY
= 0;
88 memmove(&VideoBuffer
[(MDA_COLUMNS
* 0) + 0],
89 &VideoBuffer
[(MDA_COLUMNS
* 1) + 0],
90 MDA_COLUMNS
* (MDA_LINES
- 1) * 2);
91 memset(&VideoBuffer
[(MDA_COLUMNS
* (MDA_LINES
- 1)) + 0], 0,
100 if (MdaCursorY
== (MDA_LINES
- 1))
111 VideoBuffer
[(MdaCursorY
* MDA_COLUMNS
) + MdaCursorX
] = (Ch
& 0xFF) | 0x0700;
113 if (MdaCursorX
== (MDA_COLUMNS
- 1))
115 if (MdaCursorY
== (MDA_LINES
- 1))