]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/MAI/bios_emulator/scitech/src/pm/tests/biosptr.c
* Patch by Thomas Frieden, 13 Nov 2002:
[karo-tx-uboot.git] / board / MAI / bios_emulator / scitech / src / pm / tests / biosptr.c
1 /****************************************************************************
2 *
3 *                   SciTech OS Portability Manager Library
4 *
5 *  ========================================================================
6 *
7 *    The contents of this file are subject to the SciTech MGL Public
8 *    License Version 1.0 (the "License"); you may not use this file
9 *    except in compliance with the License. You may obtain a copy of
10 *    the License at http://www.scitechsoft.com/mgl-license.txt
11 *
12 *    Software distributed under the License is distributed on an
13 *    "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 *    implied. See the License for the specific language governing
15 *    rights and limitations under the License.
16 *
17 *    The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
18 *
19 *    The Initial Developer of the Original Code is SciTech Software, Inc.
20 *    All Rights Reserved.
21 *
22 *  ========================================================================
23 *
24 * Language:     ANSI C
25 * Environment:  any
26 *
27 * Description:  Test program to check the ability to manipulate the
28 *               BIOS data area from protected mode using the PM
29 *               library. Compile and link with the appropriate command
30 *               line for your DOS extender.
31 *
32 *               Functions tested:   PM_getBIOSSelector()
33 *                                   PM_getLong()
34 *                                   PM_getByte()
35 *                                   PM_getWord()
36 *
37 ****************************************************************************/
38
39 #include <stdlib.h>
40 #include <stdio.h>
41 #include "pmapi.h"
42
43 /* Macros to obtain values from the BIOS data area */
44
45 #define TICKS()     PM_getLong(bios+0x6C)
46 #define KB_STAT     PM_getByte(bios+0x17)
47 #define KB_HEAD     PM_getWord(bios+0x1A)
48 #define KB_TAIL     PM_getWord(bios+0x1C)
49
50 /* Macros for working with the keyboard buffer */
51
52 #define KB_HIT()    (KB_HEAD != KB_TAIL)
53 #define CTRL()      (KB_STAT & 4)
54 #define SHIFT()     (KB_STAT & 2)
55 #define ESC         0x1B
56
57 /* Selector for BIOS data area */
58
59 uchar *bios;
60
61 int main(void)
62 {
63     int c,done = 0;
64
65     printf("Program running in ");
66     switch (PM_getModeType()) {
67         case PM_realMode:
68             printf("real mode.\n\n");
69             break;
70         case PM_286:
71             printf("16 bit protected mode.\n\n");
72             break;
73         case PM_386:
74             printf("32 bit protected mode.\n\n");
75             break;
76         }
77
78     bios = PM_getBIOSPointer();
79     printf("Hit any key to test, Ctrl-Shift-Esc to quit\n");
80     while (!done) {
81         if (KB_HIT()) {
82             c = PM_getch();
83             if (c == 0) PM_getch();
84             printf("TIME=%-8lX ST=%02X CHAR=%02X ", TICKS(), KB_STAT, c);
85             printf("\n");
86             if ((c == ESC) && SHIFT() && CTRL())/* Ctrl-Shift-Esc */
87                 break;
88             }
89         }
90
91     return 0;
92 }