start_pxe.S revision 1.5
11.5Sjakllsch/* $NetBSD: start_pxe.S,v 1.5 2010/12/20 01:12:45 jakllsch Exp $ */ 21.1Sdsl 31.1Sdsl/* 41.1Sdsl * Copyright 2001 Wasabi Systems, Inc. 51.1Sdsl * All rights reserved. 61.1Sdsl * 71.1Sdsl * Written by Jason R. Thorpe for Wasabi Systems, Inc. 81.1Sdsl * 91.1Sdsl * Redistribution and use in source and binary forms, with or without 101.1Sdsl * modification, are permitted provided that the following conditions 111.1Sdsl * are met: 121.1Sdsl * 1. Redistributions of source code must retain the above copyright 131.1Sdsl * notice, this list of conditions and the following disclaimer. 141.1Sdsl * 2. Redistributions in binary form must reproduce the above copyright 151.1Sdsl * notice, this list of conditions and the following disclaimer in the 161.1Sdsl * documentation and/or other materials provided with the distribution. 171.1Sdsl * 3. All advertising materials mentioning features or use of this software 181.1Sdsl * must display the following acknowledgement: 191.1Sdsl * This product includes software developed for the NetBSD Project by 201.1Sdsl * Wasabi Systems, Inc. 211.1Sdsl * 4. The name of Wasabi Systems, Inc. may not be used to endorse 221.1Sdsl * or promote products derived from this software without specific prior 231.1Sdsl * written permission. 241.1Sdsl * 251.1Sdsl * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 261.1Sdsl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 271.1Sdsl * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 281.1Sdsl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 291.1Sdsl * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 301.1Sdsl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 311.1Sdsl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 321.1Sdsl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 331.1Sdsl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 341.1Sdsl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 351.1Sdsl * POSSIBILITY OF SUCH DAMAGE. 361.1Sdsl */ 371.1Sdsl 381.1Sdsl/* 391.1Sdsl * PXE startup 401.1Sdsl * parts from sys/arch/i386/stand/lib/crt/bootsect/start_bootsect.S 411.1Sdsl * 421.1Sdsl * See PXE SPEC 4.4.5 (pdf page 88) 431.1Sdsl */ 441.1Sdsl 451.1Sdsl#include <machine/asm.h> 461.2Sdsl#include <sys/bootblock.h> 471.1Sdsl 481.1Sdsl .text 491.1SdslENTRY(start) 501.1Sdsl .code16 511.2Sdsl /* Boot parameter area in same format as boot and bootxx */ 521.2Sdsl jmp 1f 531.2Sdsl .balign 4 541.2Sdsl .long X86_BOOT_MAGIC_PXE 551.4Sdsl .globl _C_LABEL(boot_params) 561.4Sdsl_C_LABEL(boot_params): 571.4Sdsl .long 1f - _C_LABEL(boot_params) 581.2Sdsl#include <boot_params.S> 591.2Sdsl .space 4 * 4 /* some spare */ 601.2Sdsl1: 611.1Sdsl # start is loaded at 0x0:0x7c00 but we want 0x7c0:0x0 621.1Sdsl # ljmp to the next instruction to adjust %cs 631.2Sdsl ljmp $0x7c0, $2f 641.2Sdsl2: 651.1Sdsl # set up %ds 661.1Sdsl xorl %eax, %eax 671.1Sdsl mov %cs, %ax 681.1Sdsl mov %ax, %ds 691.1Sdsl 701.1Sdsl # set up %ss and %esp 711.1Sdsl mov %ax, %ss 721.1Sdsl movl $0xfffc, %esp /* stack at top of 64k segment */ 731.1Sdsl 741.2Sdsl call gdt_fixup 751.1Sdsl 761.1Sdsl /* change to protected mode */ 771.1Sdsl calll _C_LABEL(real_to_prot) 781.1Sdsl .code32 791.1Sdsl 801.1Sdsl /* clear bss */ 811.1Sdsl xorl %eax, %eax 821.1Sdsl movl $_C_LABEL(edata), %edi 831.1Sdsl movl $_C_LABEL(end), %ecx 841.1Sdsl subl %edi, %ecx 851.1Sdsl cld 861.1Sdsl rep 871.1Sdsl stosb 881.1Sdsl 891.1Sdsl /* ...and call main()! */ 901.1Sdsl call _C_LABEL(main) 911.1Sdsl 921.5SjakllschENTRY(_rtt) 931.1Sdsl call _C_LABEL(prot_to_real) 941.1Sdsl .code16 951.1Sdsl movw $efail, %si 961.1Sdsl call message 971.1Sdsl 981.1Sdsl#ifdef notyet 991.1Sdsl /* sleep for 3s = 0x2dc6c0 us */ 1001.1Sdsl movb $0x86, %ah 1011.1Sdsl mov $0x002d, %cx 1021.1Sdsl mov $0xc6c0, %dx 1031.1Sdsl int $0x15 1041.1Sdsl 1051.1Sdsl /* call ROM BASIC */ 1061.1Sdsl int $0x18 1071.1Sdsl#else 1081.2Sdsl10: 1091.1Sdsl cli 1101.1Sdsl hlt 1111.2Sdsl jmp 10b 1121.1Sdsl#endif 1131.1Sdsl 1141.1Sdslefail: .asciz "Boot fail\r\n" 115