bootstub.S (2052B)
1 /* $Id: //depot/blt/boot/bootstub.S#1 $ 2 ** 3 ** Copyright 1999 Sidney Cammeresi. 4 ** All rights reserved. 5 ** 6 ** Redistribution and use in source and binary forms, with or without 7 ** modification, are permitted provided that the following conditions 8 ** are met: 9 ** 10 ** 1. Redistributions of source code must retain the above copyright notice, 11 ** this list of conditions and the following disclaimer. 12 ** 13 ** 2. Redistributions in binary form must reproduce the above copyright 14 ** notice, this list of conditions and the following disclaimer in the 15 ** documentation and/or other materials provided with the distribution. 16 ** 17 ** 3. The name of the author may not be used to endorse or promote products 18 ** derived from this software without specific prior written permission. 19 ** 20 ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS' AND ANY EXPRESS OR IMPLIED 21 ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 23 ** NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 25 ** TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 ** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 ** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 .globl _start 33 .globl adjust_seg_regs 34 35 _start: 36 cmpl $0x2badb002, %eax 37 je grub 38 jmp netboot 39 40 netboot: 41 pushl %ebp 42 movl %esp, %ebp 43 subl $0x18, %esp 44 movl %ebp, -4(%ebp) 45 movl 0xc(%ebp), %eax 46 pushl %eax 47 movl -4(%ebp), %eax 48 pushl %eax 49 movl 0x8(%ebp), %eax 50 pushl %eax 51 movl 0x10(%ebp), %eax 52 pushl %eax 53 call bootstrap 54 hlt 55 56 grub: 57 movl $0x90ffc, %esp 58 pushl %ebx 59 call grub_bootstrap 60 hlt 61 62 adjust_seg_regs: 63 ljmp $0x8, $new_cs 64 new_cs: 65 mov $0x10, %ax 66 mov %ax, %ds 67 mov %ax, %es 68 mov %ax, %fs 69 mov %ax, %gs 70 mov %ax, %ss 71 ret 72