Deleted Added
full compact
pxeldr.S (58713) pxeldr.S (60821)
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
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 58713 2000-03-28 01:19:53Z jhb $
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
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 call putstr # display the 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
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 call putstr # display the message
94 movl $MEM_ARG, %ebx # %ds:(%ebx) -> boot args
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
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(%ebx) # kargs->bootflags |=
101 orb $KARGS_FLAGS_PXE, 0x8(%bx) # kargs->bootflags |=
102 # KARGS_FLAGS_PXE
102 # KARGS_FLAGS_PXE
103 popl 0xc(%ebx) # kargs->pxeinfo = *PXENV+
103 popl 0xc(%bx) # kargs->pxeinfo = *PXENV+
104#
105# Turn on the A20 address line
106#
104#
105# Turn on the A20 address line
106#
107 call seta20 # Turn A20 on
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
108#
109# Relocate the loader and BTX using a very lazy protected mode
110#
111 movw $relocate_msg, %si # Display the
112 call putstr # relocation message
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
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 .byte 0xea # long jump to
125 .word pm_start # clear the instruction
126 .word SEL_SCODE # pre-fetch queue
124 ljmp $SEL_SCODE,$pm_start # long jump to clear the
125 # instruction pre-fetch queue
127 .code32
128pm_start: movw $SEL_SDATA, %ax # Initialize
129 movw %ax, %ds # %ds and
130 movw %ax, %es # %es to a flat selector
131 rep # Relocate the
132 movsb # text segment
133 addl $(MEM_PAGE_SIZE - 1), %edi # pad %edi out to a new page
134 andl $~(MEM_PAGE_SIZE - 1), %edi # for the data segment

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

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

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

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

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

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

--- 36 unchanged lines hidden ---
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 ---