Deleted Added
sdiff udiff text old ( 58713 ) new ( 60821 )
full compact
1#
2# Copyright (c) 2000 John Baldwin
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms are freely
6# permitted provided that the above copyright notice and this
7# paragraph and the following disclaimer are duplicated in all
8# such forms.
9#
10# This software is provided "AS IS" and without any express or
11# implied warranties, including, without limitation, the implied
12# warranties of merchantability and fitness for a particular
13# purpose.
14#
15
16# $FreeBSD: head/sys/boot/i386/pxeldr/pxeldr.S 60821 2000-05-23 12:18:49Z jhb $
17
18#
19# This simple program is a preloader for the normal boot3 loader. It is simply
20# prepended to the beginning of a fully built and btxld'd loader. It then
21# copies the loader to the address boot2 normally loads it, emulates the
22# boot[12] environment (protected mode, a bootinfo struct, etc.), and then jumps
23# to the start of btxldr to start the boot process. This method allows a stock
24# /boot/loader to be booted over the network via PXE w/o having to write a

--- 55 unchanged lines hidden (view full) ---

80 movw %ax, %ds # setup the
81 movw %ax, %es # data segments
82 andl $0xffff, %ecx # clear upper words
83 andl $0xffff, %ebx # of %ebx and %ecx
84 shll $4, %ecx # calculate the offset of
85 addl %ebx, %ecx # the PXENV+ struct and
86 pushl %ecx # save it on the stack
87 movw $welcome_msg, %si # %ds:(%si) -> welcome message
88 callw putstr # display the welcome message
89#
90# Setup the arguments that the loader is expecting from boot[12]
91#
92 movw $bootinfo_msg, %si # %ds:(%si) -> boot args message
93 callw putstr # display the message
94 movl $MEM_ARG, %bx # %ds:(%bx) -> boot args
95 movw %bx, %di # %es:(%di) -> boot args
96 xorl %eax, %eax # zero %eax
97 movw $(MEM_ARG_SIZE/4), %cx # Size of arguments in 32-bit
98 # dwords
99 rep # Clear the arguments
100 stosl # to zero
101 orb $KARGS_FLAGS_PXE, 0x8(%bx) # kargs->bootflags |=
102 # KARGS_FLAGS_PXE
103 popl 0xc(%bx) # kargs->pxeinfo = *PXENV+
104#
105# Turn on the A20 address line
106#
107 callw seta20 # Turn A20 on
108#
109# Relocate the loader and BTX using a very lazy protected mode
110#
111 movw $relocate_msg, %si # Display the
112 callw putstr # relocation message
113 movl end+AOUT_ENTRY, %edi # %edi is the destination
114 movl $(end+AOUT_HEADER), %esi # %esi is
115 # the start of the text
116 # segment
117 movl end+AOUT_TEXT, %ecx # %ecx = length of the text
118 # segment
119 lgdt gdtdesc # setup our own gdt
120 cli # turn off interrupts
121 movl %cr0, %eax # Turn on
122 orb $0x1, %al # protected
123 movl %eax, %cr0 # mode
124 ljmp $SEL_SCODE,$pm_start # long jump to clear the
125 # instruction pre-fetch queue
126 .code32
127pm_start: movw $SEL_SDATA, %ax # Initialize
128 movw %ax, %ds # %ds and
129 movw %ax, %es # %es to a flat selector
130 rep # Relocate the
131 movsb # text segment
132 addl $(MEM_PAGE_SIZE - 1), %edi # pad %edi out to a new page
133 andl $~(MEM_PAGE_SIZE - 1), %edi # for the data segment

--- 15 unchanged lines hidden (view full) ---

149 ljmp $SEL_SCODE16,$pm_16 # Jump to 16-bit PM
150 .code16
151pm_16: movw $SEL_RDATA, %ax # Initialize
152 movw %ax, %ds # %ds and
153 movw %ax, %es # %es to a real mode selector
154 movl %cr0, %eax # Turn off
155 andb $~0x1, %al # protected
156 movl %eax, %cr0 # mode
157 ljmp $0,$pm_end # Long jump to clear the
158 # instruction pre-fetch queue
159pm_end: sti # Turn interrupts back on now
160#
161# Copy the BTX client to MEM_BTX_CLIENT
162#
163 xorw %ax, %ax # zero %ax and set
164 movw %ax, %ds # %ds and %es
165 movw %ax, %es # to segment 0
166 movw $MEM_BTX_CLIENT, %di # Prepare to relocate

--- 14 unchanged lines hidden (view full) ---

181#
182 movl end+AOUT_ENTRY, %eax # load the entry point
183 stosl # add it to the end of the
184 # arguments
185#
186# Now we just start up BTX and let it do the rest
187#
188 movw $jump_message, %si # Display the
189 callw putstr # jump message
190 ljmp $0,$MEM_BTX_ENTRY # Jump to the BTX entry point
191
192#
193# Display a null-terminated string
194#
195putstr: lodsb # load %al from %ds:(%si)
196 testb %al,%al # stop at null
197 jnz putc # if the char != null, output it
198 retw # return when null is hit
199putc: movw $0x7,%bx # attribute for output
200 movb $0xe,%ah # BIOS: put_char
201 int $0x10 # call BIOS, print char in %al
202 jmp putstr # keep looping
203
204#
205# Enable A20
206#

--- 4 unchanged lines hidden (view full) ---

211 movb $0xd1,%al # Command: Write
212 outb %al,$0x64 # output port
213seta20.2: inb $0x64,%al # Get status
214 testb $0x2,%al # Busy?
215 jnz seta20.2 # Yes
216 movb $0xdf,%al # Enable
217 outb %al,$0x60 # A20
218 sti # Enable interrupts
219 retw # To caller
220
221#
222# BTX client to start btxldr
223#
224 .code32
225btx_client: movl $(MEM_ARG_BTX-MEM_BTX_CLIENT+MEM_ARG_SIZE-4), %esi
226 # %ds:(%esi) -> end
227 # of boot[12] args

--- 36 unchanged lines hidden ---