start_pxe.S revision 1.6
11.6Sjakllsch/* $NetBSD: start_pxe.S,v 1.6 2011/03/18 17:46:26 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.6Sjakllsch 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 mov %cs, %ax 671.1Sdsl mov %ax, %ds 681.1Sdsl 691.6Sjakllsch # set up %ss and %sp 701.6Sjakllsch movl $_end, %eax /* top of bss */ 711.6Sjakllsch shrl $4, %eax /* as a segment */ 721.6Sjakllsch addw $0x1001, %ax /* and + 64k */ 731.6Sjakllsch movw %ax, %ss /* for stack */ 741.6Sjakllsch movw $0xfffc, %sp /* %sp at top of it */ 751.1Sdsl 761.2Sdsl call gdt_fixup 771.1Sdsl 781.1Sdsl /* change to protected mode */ 791.1Sdsl calll _C_LABEL(real_to_prot) 801.1Sdsl .code32 811.1Sdsl 821.1Sdsl /* clear bss */ 831.1Sdsl xorl %eax, %eax 841.1Sdsl movl $_C_LABEL(edata), %edi 851.1Sdsl movl $_C_LABEL(end), %ecx 861.1Sdsl subl %edi, %ecx 871.1Sdsl cld 881.1Sdsl rep 891.1Sdsl stosb 901.1Sdsl 911.1Sdsl /* ...and call main()! */ 921.1Sdsl call _C_LABEL(main) 931.1Sdsl 941.5SjakllschENTRY(_rtt) 951.1Sdsl call _C_LABEL(prot_to_real) 961.1Sdsl .code16 971.1Sdsl movw $efail, %si 981.1Sdsl call message 991.1Sdsl 1001.1Sdsl#ifdef notyet 1011.1Sdsl /* sleep for 3s = 0x2dc6c0 us */ 1021.1Sdsl movb $0x86, %ah 1031.1Sdsl mov $0x002d, %cx 1041.1Sdsl mov $0xc6c0, %dx 1051.1Sdsl int $0x15 1061.1Sdsl 1071.1Sdsl /* call ROM BASIC */ 1081.1Sdsl int $0x18 1091.1Sdsl#else 1101.2Sdsl10: 1111.1Sdsl cli 1121.1Sdsl hlt 1131.2Sdsl jmp 10b 1141.1Sdsl#endif 1151.1Sdsl 1161.1Sdslefail: .asciz "Boot fail\r\n" 117