1; ----------------------------------------------------------------------- 2; 3; Copyright 2005-2008 H. Peter Anvin - All Rights Reserved 4; Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin 5; 6; This program is free software; you can redistribute it and/or modify 7; it under the terms of the GNU General Public License as published by 8; the Free Software Foundation, Inc., 53 Temple Place Ste 330, 9; Boston MA 02111-1307, USA; either version 2 of the License, or 10; (at your option) any later version; incorporated herein by reference. 11; 12; ----------------------------------------------------------------------- 13 14; 15; stack.inc 16; 17; How to reset the stack pointer 18; 19 20%ifndef _STACK_INC 21%define _STACK_INC 22 23; 24; This macro resets the stack pointer (including SS), and sets 25; DS == ES == 0, interrupts on, DF = 0. 26; 27; It takes a 16-bit register that can be safely clobbered as parameter. 28; 29%macro RESET_STACK_AND_SEGS 1 30 xor %1,%1 31 mov ds,%1 32 mov es,%1 33 lss esp,[BaseStack] 34 mov dword [PMESP],__stack_end ; Reset PM stack 35 sti 36 cld 37%endmacro 38 39 section .data16 40 alignz 4 41 global BaseStack:data hidden 42BaseStack dd StackHome ; ESP of the "home" stack pointer 43 dw 0 ; SS of the "home" stack pointer 44 45 section .text16 46 47%endif ; _STACK_INC 48