1/* 2 * Copyright (c) 1998 Robert Nordier 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are freely 6 * permitted provided that the above copyright notice and this 7 * paragraph and the following disclaimer are duplicated in all 8 * such forms. 9 * 10 * This software is provided "AS IS" and without any express or 11 * implied warranties, including, without limitation, the implied 12 * warranties of merchantability and fitness for a particular 13 * purpose. 14 * 15 * 16 * $FreeBSD: src/sys/boot/i386/btx/lib/btxv86.s,v 1.3 1999/08/28 00:40:08 peter Exp $ 17 * $DragonFly: src/sys/boot/pc32/btx/lib/btxv86.S,v 1.4 2004/07/19 01:25:02 dillon Exp $ 18 */ 19 20/* 21 * BTX V86 interface. 22 */ 23 24#include "../../bootasm.h" 25 26 /* 27 * Globals. 28 */ 29 .global __v86int 30 31 /* 32 * Fields in V86 interface structure. 33 */ 34 .set V86_CTL,0x0 # Control flags 35 .set V86_ADDR,0x4 # Int number/address 36 .set V86_ES,0x8 # V86 ES 37 .set V86_DS,0xc # V86 DS 38 .set V86_FS,0x10 # V86 FS 39 .set V86_GS,0x14 # V86 GS 40 .set V86_EAX,0x18 # V86 EAX 41 .set V86_ECX,0x1c # V86 ECX 42 .set V86_EDX,0x20 # V86 EDX 43 .set V86_EBX,0x24 # V86 EBX 44 .set V86_EFL,0x28 # V86 eflags 45 .set V86_EBP,0x2c # V86 EBP 46 .set V86_ESI,0x30 # V86 ESI 47 .set V86_EDI,0x34 # V86 EDI 48 49 /* 50 * Other constants. 51 */ 52 .set INT_V86,0x31 # Interrupt number 53 .set SIZ_V86,0x38 # Size of V86 structure 54 55 /* 56 * V86 interface function. 57 */ 58__v86int: popl __v86ret # Save return address 59 pushl $__v86 # Push pointer 60 call __v86_swap # Load V86 registers 61 int $INT_V86 # To BTX 62 call __v86_swap # Load user registers 63 addl $0x4,%esp # Discard pointer 64 pushl __v86ret # Restore return address 65 ret # To user 66 67 /* 68 * Swap V86 and user registers. 69 */ 70__v86_swap: xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP 71 xchgl %eax,V86_EAX(%ebp) # Swap EAX 72 xchgl %ecx,V86_ECX(%ebp) # Swap ECX 73 xchgl %edx,V86_EDX(%ebp) # Swap EDX 74 xchgl %ebx,V86_EBX(%ebp) # Swap EBX 75 pushl %eax # Save 76 pushf # Put eflags 77 popl %eax # in EAX 78 xchgl %eax,V86_EFL(%ebp) # Swap 79 pushl %eax # Put EAX 80 popf # in eflags 81 movl 0x8(%esp,1),%eax # Load EBP 82 xchgl %eax,V86_EBP(%ebp) # Swap 83 movl %eax,0x8(%esp,1) # Save EBP 84 popl %eax # Restore 85 xchgl %esi,V86_ESI(%ebp) # Swap ESI 86 xchgl %edi,V86_EDI(%ebp) # Swap EDI 87 xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP 88 ret # To caller 89 90 /* 91 * V86 interface structure. 92 */ 93 .comm __v86,SIZ_V86 94 .comm __v86ret,4 95 96