From: Lin-bao Zhang Subject: define BOOT_TRAMPOLINE and stack based on result of probing EBDA area by INT12 Date: Wed, 31 Aug 2011 01:47:10 -0700 (PDT) Message-ID: <1314780430.48326.YahooMailNeo@web122103.mail.ne1.yahoo.com> Reply-To: Lin-bao Zhang Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "keir.xen@gmail.com" , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org Hi Keir ,=A0=0A=0Awe have discussed how to avoid to overlap with EBDA area = in subject "xen-kernel and EDD".=0Aat last, in RHEL5.7s ,we define BOOT_TRA= MPOLINE 0x7c000 ,and=A0=0A- mov $0x98000,%esp=0A+ mov = $(BOOT_TRAMPOLINE + 0x4000),%esp=0Abut some days passed, I finally feel th= at this modification is somewhat the best choice for avoid EBDA overwritten= . =0AFor EBDA , I have been always discussing with our BIOS colleagues,BIOS= guys' suggestion is like this:=0ATo guarantee to never run into this probl= em again, the e820 memory map must be=0Aparsed to find a valid memory range= before using it.=A0 Not the easiest=0Athing to do in assembly code without= a stack, which is why the early loader=0Afolks took the easy route and har= dcoded the stack.=A0 On most platforms that=0Aworks, but to guarantee it wo= rks on all, the e820 map must be parsed, and=0Areserved areas must not be c= orrupted by the OS.in fact, our xen-hypervisor has parsed e820 map successf= ully, but why we don't make use of e820 map result to judge EBDA bottom ? = =0Afrom BIOS-provided physical RAM map: BIOS-e820: 0000000000010000 - 00000= 00000090400 (usable) BIOS-e820: 0000000000090400 - 0000000000a0000 (reserve= d)We have known that EBDA area is 90400 ~ 0xa0000 . when programming, EBDA = area is certainly different on different BIOS .we can determine the size of= the EBDA by using BIOS function=A0INT 12h, or (often) by examining the wor= d at 0x40E in the BDA .Both of those methods will tell you the location of = the bottom of the EBDA.=A0http://wiki.osdev.org/Memory_Map_(x86)#.22Low.22_= memory_.28.3C_1_MiB.29=A0=A0=0A=0A1,define a variable named "EBDA_bottom". = =0A2, get EBDA_bottom by above method.=0A3, stack should equals EBDA_bottom= (or EBDA_bottom -1 safely)=0A4, mov $(EBDA_bottom -1),%esp=0Ain most c= ase , EBDA area is 1K,but we define 0x7c000(this is absolutely safe),but we= will waste too much memory space.=0A=0AI did test, it can work .Certainly,= I am familiar with assembler code, I just hard code to test:mov 0x903f= f , %esp=A0thanks for your corrections , I have not read over all histories= and stories about them, if I am wrong , I am sorry first.=0A=0Athanks very= much!=0A=0A=0A-Bob=0A