2 * Copyright (c) 2002-2018 The UbixOS Project.
5 * This was developed by Christopher W. Olsen for the UbixOS Project.
7 * Redistribution and use in source and binary forms, with or without modification, are permitted
8 * provided that the following conditions are met:
10 * 1) Redistributions of source code must retain the above copyright notice, this list of
11 * conditions, the following disclaimer and the list of authors.
12 * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13 * conditions, the following disclaimer and the list of authors in the documentation and/or
14 * other materials provided with the distribution.
15 * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16 * endorse or promote products derived from this software without specific prior written
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #define BI_VERSION 0x0
30 #define BI_KERNELNAME 0x4
31 #define BI_ENDCOMMON 12
33 #define BOOTINFO_SIZE 135
34 #define RB_BOOTINFO 0x80000000 /* have `struct bootinfo *' arg */
49 movl $(__bss_start),%edi
81 ljmp $0x08,$start_next
88 pushl $0xDEAD; // Stack
89 pushl $0xBEEF; // Marker
94 * The old style disk boot blocks fake a frame on the stack and
95 * did an lret to get here. The frame on the stack has a return
103 * We have some form of return address, so this is either the
104 * old diskless netboot code, or the new uniform code. That can
105 * be detected by looking at the 5th argument, if it is 0
106 * we are being booted by the new uniform boot code.
113 movl 28(%ebp),%ebx /* &bootinfo.version */
114 movl BI_VERSION(%ebx),%eax
115 cmpl $1,%eax /* We only understand version 1 */
117 movl $1,%eax /* Return status */
120 * XXX this returns to our caller's caller (as is required) since
121 * we didn't set up a frame and our caller did.
127 * If we have a kernelname copy it in
129 movl BI_KERNELNAME(%ebx),%esi
131 je 2f /* No kernelname */
132 movl 512,%ecx /* Brute force!!! */
133 movl $_kernelname,%edi
134 cmpb $'/',(%esi) /* Make sure it starts with a slash */
146 * Determine the size of the boot loader's copy of the bootinfo
147 * struct. This is impossible to do properly because old versions
148 * of the struct don't contain a size field and there are 2 old
149 * versions with the same version number.
151 movl $BI_ENDCOMMON,%ecx /* prepare for sizeless version */
152 testl $RB_BOOTINFO,8(%ebp) /* bi_size (and bootinfo) valid? */
153 je got_bi_size /* no, sizeless version */
154 movl BI_SIZE(%ebx),%ecx
158 * Copy the common part of the bootinfo struct
162 cmpl $BOOTINFO_SIZE,%ecx
163 jbe got_common_bi_size
164 movl $BOOTINFO_SIZE,%ecx
171 movl %eax,(_boothowto)