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

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

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

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

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

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

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

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