jseward | 2886b0e | 2004-01-04 03:46:11 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | This file is part of Valgrind, an extensible x86 protected-mode |
| 4 | emulator for monitoring program execution on x86-Unixes. |
| 5 | |
| 6 | Copyright (C) 2000-2004 Julian Seward |
| 7 | jseward@acm.org |
| 8 | |
| 9 | This program is free software; you can redistribute it and/or |
| 10 | modify it under the terms of the GNU General Public License as |
| 11 | published by the Free Software Foundation; either version 2 of the |
| 12 | License, or (at your option) any later version. |
| 13 | |
| 14 | This program is distributed in the hope that it will be useful, but |
| 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | General Public License for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License |
| 20 | along with this program; if not, write to the Free Software |
| 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 22 | 02111-1307, USA. |
| 23 | |
| 24 | The GNU General Public License is contained in the file COPYING. |
| 25 | */ |
| 26 | |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 27 | #include "ume_arch.h" |
| 28 | |
fitzhardinge | f86ba6d | 2004-01-19 21:47:25 +0000 | [diff] [blame] | 29 | /* |
| 30 | Jump to a particular EIP with a particular ESP. This is intended |
| 31 | to simulate the initial CPU state when the kernel starts an program |
| 32 | after exec; it therefore also clears all the other registers. |
| 33 | */ |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 34 | void ume_go(addr_t eip, addr_t esp) |
| 35 | { |
fitzhardinge | f86ba6d | 2004-01-19 21:47:25 +0000 | [diff] [blame] | 36 | asm volatile ("movl %1, %%esp;" /* set esp */ |
| 37 | "pushl %%eax;" /* push esp */ |
| 38 | "xorl %%eax,%%eax;" /* clear registers */ |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 39 | "xorl %%ebx,%%ebx;" |
| 40 | "xorl %%ecx,%%ecx;" |
| 41 | "xorl %%edx,%%edx;" |
| 42 | "xorl %%esi,%%esi;" |
| 43 | "xorl %%edi,%%edi;" |
| 44 | "xorl %%ebp,%%ebp;" |
| 45 | |
| 46 | "ret" /* return into entry */ |
| 47 | : : "a" (eip), "r" (esp)); |
| 48 | /* we should never get here */ |
| 49 | for(;;) |
fitzhardinge | f86ba6d | 2004-01-19 21:47:25 +0000 | [diff] [blame] | 50 | asm volatile("ud2"); |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 51 | } |