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/cdboot/cdboot.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 used w/o having to fully rewrite boot[12] to handle the

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

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

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

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

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

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

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

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

--- 36 unchanged lines hidden ---