]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/MAI/bios_emulator/scitech/src/pm/tests/callreal.c
1 /****************************************************************************
3 * SciTech OS Portability Manager Library
5 * ========================================================================
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
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.
17 * The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
19 * The Initial Developer of the Original Code is SciTech Software, Inc.
20 * All Rights Reserved.
22 * ========================================================================
27 * Description: Test program to check the ability to call a real mode
28 * procedure. We simply copy a terribly simple assembly
29 * language routine into a real mode block that we allocate,
30 * and then attempt to call the routine and verify that it
33 * Functions tested: PM_allocRealSeg()
37 ****************************************************************************/
44 /* Block of real mode code we will eventually call */
46 static unsigned char realModeCode
[] = {
47 0x93, /* xchg ax,bx */
48 0x87, 0xCA, /* xchg cx,dx */
59 printf("Program running in ");
60 switch (PM_getModeType()) {
62 printf("real mode.\n\n");
65 printf("16 bit protected mode.\n\n");
68 printf("32 bit protected mode.\n\n");
72 /* Allocate a the block of real mode memory */
73 if ((p
= PM_allocRealSeg(sizeof(realModeCode
), &r_seg
, &r_off
)) == NULL
) {
74 printf("Unable to allocate real mode memory!\n");
78 /* Copy the real mode code */
79 memcpy(p
,realModeCode
,sizeof(realModeCode
));
81 /* Now call the real mode code */
90 PM_callRealMode(r_seg
,r_off
,®s
,&sregs
);
91 if (regs
.x
.ax
!= 2 || regs
.x
.bx
!= 1 || regs
.x
.cx
!= 4 || regs
.x
.dx
!= 3
92 || regs
.x
.si
!= 5 || regs
.x
.di
!= 6 || sregs
.es
!= 7
94 printf("Real mode call failed!\n");
96 printf("ax = %04X, bx = %04X, cx = %04X, dx = %04X\n",
97 regs
.x
.ax
,regs
.x
.bx
,regs
.x
.cx
,regs
.x
.dx
);
98 printf("si = %04X, di = %04X, es = %04X, ds = %04X\n",
99 regs
.x
.si
,regs
.x
.di
,sregs
.es
,sregs
.ds
);
102 printf("Real mode call succeeded!\n");
104 /* Free the memory we allocated */