Deleted Added
full compact
15c15
< * $FreeBSD: head/sys/boot/i386/btx/btxldr/btxldr.S 128716 2004-04-28 14:31:44Z ru $
---
> * $FreeBSD: head/sys/boot/i386/btx/btxldr/btxldr.S 129240 2004-05-14 20:29:30Z ru $
26,30c26,30
< .set MEM_STUB,0x600 // Real mode stub
< .set MEM_ESP,0x1000 // New stack pointer
< .set MEM_TBL,0x5000 // BTX page tables
< .set MEM_ENTRY,0x9010 // BTX entry point
< .set MEM_DATA,start+0x1000 // Data segment
---
> .set MEM_STUB,0x600 # Real mode stub
> .set MEM_ESP,0x1000 # New stack pointer
> .set MEM_TBL,0x5000 # BTX page tables
> .set MEM_ENTRY,0x9010 # BTX entry point
> .set MEM_DATA,start+0x1000 # Data segment
34,37c34,37
< .set SEL_SCODE,0x8 // 4GB code
< .set SEL_SDATA,0x10 // 4GB data
< .set SEL_RCODE,0x18 // 64K code
< .set SEL_RDATA,0x20 // 64K data
---
> .set SEL_SCODE,0x8 # 4GB code
> .set SEL_SDATA,0x10 # 4GB data
> .set SEL_RCODE,0x18 # 64K code
> .set SEL_RDATA,0x20 # 64K data
41,42c41,42
< .set PAG_SIZ,0x1000 // Page size
< .set PAG_ENT,0x4 // Page entry size
---
> .set PAG_SIZ,0x1000 # Page size
> .set PAG_ENT,0x4 # Page entry size
46,48c46,48
< .set SCR_MAT,0x7 // Mode/attribute
< .set SCR_COL,0x50 // Columns per row
< .set SCR_ROW,0x19 // Rows per screen
---
> .set SCR_MAT,0x7 # Mode/attribute
> .set SCR_COL,0x50 # Columns per row
> .set SCR_ROW,0x19 # Rows per screen
52,54c52,54
< .set BDA_MEM,0x413 // Free memory
< .set BDA_SCR,0x449 // Video mode
< .set BDA_POS,0x450 // Cursor position
---
> .set BDA_MEM,0x413 # Free memory
> .set BDA_SCR,0x449 # Video mode
> .set BDA_POS,0x450 # Cursor position
58c58
< .set SIZ_STUB,0x1a // Size of stub
---
> .set SIZ_STUB,0x1a # Size of stub
66,71c66,71
< start: cld // String ops inc
< movl $m_logo,%esi // Identify
< call putstr // ourselves
< movzwl BDA_MEM,%eax // Get base memory
< shll $0xa,%eax // in bytes
< movl %eax,%ebp // Base of user stack
---
> start: cld # String ops inc
> movl $m_logo,%esi # Identify
> call putstr # ourselves
> movzwl BDA_MEM,%eax # Get base memory
> shll $0xa,%eax # in bytes
> movl %eax,%ebp # Base of user stack
73,75c73,75
< movl $m_mem,%esi // Display
< call hexout // amount of
< call putstr // base memory
---
> movl $m_mem,%esi # Display
> call hexout # amount of
> call putstr # base memory
77c77
< lgdt gdtdesc // Load new GDT
---
> lgdt gdtdesc # Load new GDT
82,93c82,93
< movl $m_esp,%esi // Display
< movl %esp,%eax // caller
< call hexout // stack
< call putstr // pointer
< movl $m_args,%esi // Format string
< leal 0x4(%esp,1),%ebx // First argument
< movl $0x6,%ecx // Count
< start.1: movl (%ebx),%eax // Get argument and
< addl $0x4,%ebx // bump pointer
< call hexout // Display it
< loop start.1 // Till done
< call putstr // End message
---
> movl $m_esp,%esi # Display
> movl %esp,%eax # caller
> call hexout # stack
> call putstr # pointer
> movl $m_args,%esi # Format string
> leal 0x4(%esp,1),%ebx # First argument
> movl $0x6,%ecx # Count
> start.1: movl (%ebx),%eax # Get argument and
> addl $0x4,%ebx # bump pointer
> call hexout # Display it
> loop start.1 # Till done
> call putstr # End message
95,103c95,103
< movl $0x48,%ecx // Allocate space
< subl %ecx,%ebp // for bootinfo
< movl 0x18(%esp,1),%esi // Source: bootinfo
< cmpl $0x0, %esi // If the bootinfo pointer
< je start_null_bi // is null, don't copy it
< movl %ebp,%edi // Destination
< rep // Copy
< movsb // it
< movl %ebp,0x18(%esp,1) // Update pointer
---
> movl $0x48,%ecx # Allocate space
> subl %ecx,%ebp # for bootinfo
> movl 0x18(%esp,1),%esi # Source: bootinfo
> cmpl $0x0, %esi # If the bootinfo pointer
> je start_null_bi # is null, don't copy it
> movl %ebp,%edi # Destination
> rep # Copy
> movsb # it
> movl %ebp,0x18(%esp,1) # Update pointer
105,108c105,108
< movl $m_rel_bi,%esi // Display
< movl %ebp,%eax // bootinfo
< call hexout // relocation
< call putstr // message
---
> movl $m_rel_bi,%esi # Display
> movl %ebp,%eax # bootinfo
> call hexout # relocation
> call putstr # message
110,115c110,115
< start_null_bi: movl $0x18,%ecx // Allocate space
< subl %ecx,%ebp // for arguments
< leal 0x4(%esp,1),%esi // Source
< movl %ebp,%edi // Destination
< rep // Copy
< movsb // them
---
> start_null_bi: movl $0x18,%ecx # Allocate space
> subl %ecx,%ebp # for arguments
> leal 0x4(%esp,1),%esi # Source
> movl %ebp,%edi # Destination
> rep # Copy
> movsb # them
117,120c117,120
< movl $m_rel_args,%esi // Display
< movl %ebp,%eax // argument
< call hexout // relocation
< call putstr // message
---
> movl $m_rel_args,%esi # Display
> movl %ebp,%eax # argument
> call hexout # relocation
> call putstr # message
125,151c125,151
< movl $MEM_ESP,%esp // Set up new stack
< movl $MEM_DATA,%ebx // Data segment
< movl $m_vers,%esi // Display BTX
< call putstr // version message
< movb 0x5(%ebx),%al // Get major version
< addb $'0',%al // Display
< call putchr // it
< movb $'.',%al // And a
< call putchr // dot
< movb 0x6(%ebx),%al // Get minor
< xorb %ah,%ah // version
< movb $0xa,%dl // Divide
< divb %dl,%al // by 10
< addb $'0',%al // Display
< call putchr // tens
< movb %ah,%al // Get units
< addb $'0',%al // Display
< call putchr // units
< call putstr // End message
< movl %ebx,%esi // BTX image
< movzwl 0x8(%ebx),%edi // Compute
< orl $PAG_SIZ/PAG_ENT-1,%edi // the
< incl %edi // BTX
< shll $0x2,%edi // load
< addl $MEM_TBL,%edi // address
< pushl %edi // Save load address
< movzwl 0xa(%ebx),%ecx // Image size
---
> movl $MEM_ESP,%esp # Set up new stack
> movl $MEM_DATA,%ebx # Data segment
> movl $m_vers,%esi # Display BTX
> call putstr # version message
> movb 0x5(%ebx),%al # Get major version
> addb $'0',%al # Display
> call putchr # it
> movb $'.',%al # And a
> call putchr # dot
> movb 0x6(%ebx),%al # Get minor
> xorb %ah,%ah # version
> movb $0xa,%dl # Divide
> divb %dl,%al # by 10
> addb $'0',%al # Display
> call putchr # tens
> movb %ah,%al # Get units
> addb $'0',%al # Display
> call putchr # units
> call putstr # End message
> movl %ebx,%esi # BTX image
> movzwl 0x8(%ebx),%edi # Compute
> orl $PAG_SIZ/PAG_ENT-1,%edi # the
> incl %edi # BTX
> shll $0x2,%edi # load
> addl $MEM_TBL,%edi # address
> pushl %edi # Save load address
> movzwl 0xa(%ebx),%ecx # Image size
153c153
< pushl %ecx // Save image size
---
> pushl %ecx # Save image size
155,157c155,157
< rep // Relocate
< movsb // BTX
< movl %esi,%ebx // Keep place
---
> rep # Relocate
> movsb # BTX
> movl %esi,%ebx # Keep place
159,161c159,161
< movl $m_rel_btx,%esi // Restore
< popl %eax // parameters
< call hexout // and
---
> movl $m_rel_btx,%esi # Restore
> popl %eax # parameters
> call hexout # and
163c163
< popl %ebp // display
---
> popl %ebp # display
165,167c165,167
< movl %ebp,%eax // the
< call hexout // relocation
< call putstr // message
---
> movl %ebp,%eax # the
> call hexout # relocation
> call putstr # message
169c169
< addl $PAG_SIZ,%ebp // Display
---
> addl $PAG_SIZ,%ebp # Display
171,174c171,174
< movl $m_base,%esi // the
< movl %ebp,%eax // user
< call hexout // base
< call putstr // address
---
> movl $m_base,%esi # the
> movl %ebp,%eax # user
> call hexout # base
> call putstr # address
179,183c179,183
< cmpl $0x464c457f,(%ebx) // ELF magic number?
< je start.3 // Yes
< movl $e_fmt,%esi // Display error
< call putstr // message
< start.2: jmp start.2 // Hang
---
> cmpl $0x464c457f,(%ebx) # ELF magic number?
> je start.3 # Yes
> movl $e_fmt,%esi # Display error
> call putstr # message
> start.2: jmp start.2 # Hang
186,188c186,188
< movl $m_elf,%esi // Display ELF
< call putstr // message
< movl $m_segs,%esi // Format string
---
> movl $m_elf,%esi # Display ELF
> call putstr # message
> movl $m_segs,%esi # Format string
190,195c190,195
< movl $0x2,%edi // Segment count
< movl 0x1c(%ebx),%edx // Get e_phoff
< addl %ebx,%edx // To pointer
< movzwl 0x2c(%ebx),%ecx // Get e_phnum
< start.4: cmpl $0x1,(%edx) // Is p_type PT_LOAD?
< jne start.6 // No
---
> movl $0x2,%edi # Segment count
> movl 0x1c(%ebx),%edx # Get e_phoff
> addl %ebx,%edx # To pointer
> movzwl 0x2c(%ebx),%ecx # Get e_phnum
> start.4: cmpl $0x1,(%edx) # Is p_type PT_LOAD?
> jne start.6 # No
197,205c197,205
< movl 0x4(%edx),%eax // Display
< call hexout // p_offset
< movl 0x8(%edx),%eax // Display
< call hexout // p_vaddr
< movl 0x10(%edx),%eax // Display
< call hexout // p_filesz
< movl 0x14(%edx),%eax // Display
< call hexout // p_memsz
< call putstr // End message
---
> movl 0x4(%edx),%eax # Display
> call hexout # p_offset
> movl 0x8(%edx),%eax # Display
> call hexout # p_vaddr
> movl 0x10(%edx),%eax # Display
> call hexout # p_filesz
> movl 0x14(%edx),%eax # Display
> call hexout # p_memsz
> call putstr # End message
207,229c207,229
< pushl %esi // Save
< pushl %edi // working
< pushl %ecx // registers
< movl 0x4(%edx),%esi // Get p_offset
< addl %ebx,%esi // as pointer
< movl 0x8(%edx),%edi // Get p_vaddr
< addl %ebp,%edi // as pointer
< movl 0x10(%edx),%ecx // Get p_filesz
< rep // Set up
< movsb // segment
< movl 0x14(%edx),%ecx // Any bytes
< subl 0x10(%edx),%ecx // to zero?
< jz start.5 // No
< xorb %al,%al // Then
< rep // zero
< stosb // them
< start.5: popl %ecx // Restore
< popl %edi // working
< popl %esi // registers
< decl %edi // Segments to do
< je start.7 // If none
< start.6: addl $0x20,%edx // To next entry
< loop start.4 // Till done
---
> pushl %esi # Save
> pushl %edi # working
> pushl %ecx # registers
> movl 0x4(%edx),%esi # Get p_offset
> addl %ebx,%esi # as pointer
> movl 0x8(%edx),%edi # Get p_vaddr
> addl %ebp,%edi # as pointer
> movl 0x10(%edx),%ecx # Get p_filesz
> rep # Set up
> movsb # segment
> movl 0x14(%edx),%ecx # Any bytes
> subl 0x10(%edx),%ecx # to zero?
> jz start.5 # No
> xorb %al,%al # Then
> rep # zero
> stosb # them
> start.5: popl %ecx # Restore
> popl %edi # working
> popl %esi # registers
> decl %edi # Segments to do
> je start.7 # If none
> start.6: addl $0x20,%edx # To next entry
> loop start.4 # Till done
232,233c232,233
< movl $m_done,%esi // Display done
< call putstr // message
---
> movl $m_done,%esi # Display done
> call putstr # message
235,240c235,240
< movl $start.8,%esi // Real mode stub
< movl $MEM_STUB,%edi // Destination
< movl $start.9-start.8,%ecx // Size
< rep // Relocate
< movsb // it
< ljmp $SEL_RCODE,$MEM_STUB // To 16-bit code
---
> movl $start.8,%esi # Real mode stub
> movl $MEM_STUB,%edi # Destination
> movl $start.9-start.8,%ecx # Size
> rep # Relocate
> movsb # it
> ljmp $SEL_RCODE,$MEM_STUB # To 16-bit code
242,252c242,252
< start.8: xorw %ax,%ax // Data
< movb $SEL_RDATA,%al // selector
< movw %ax,%ss // Reload SS
< movw %ax,%ds // Reset
< movw %ax,%es // other
< movw %ax,%fs // segment
< movw %ax,%gs // limits
< movl %cr0,%eax // Switch to
< decw %ax // real
< movl %eax,%cr0 // mode
< ljmp $0,$MEM_ENTRY // Jump to BTX entry point
---
> start.8: xorw %ax,%ax # Data
> movb $SEL_RDATA,%al # selector
> movw %ax,%ss # Reload SS
> movw %ax,%ds # Reset
> movw %ax,%es # other
> movw %ax,%fs # segment
> movw %ax,%gs # limits
> movl %cr0,%eax # Switch to
> decw %ax # real
> movl %eax,%cr0 # mode
> ljmp $0,$MEM_ENTRY # Jump to BTX entry point
258,279c258,279
< hexout: pushl %eax // Save
< call putstr // Display message
< popl %eax // Restore
< pushl %esi // Save
< pushl %edi // caller's
< movl $buf,%edi // Buffer
< pushl %edi // Save
< call hex32 // To hex
< xorb %al,%al // Terminate
< stosb // string
< popl %esi // Restore
< hexout.1: lodsb // Get a char
< cmpb $'0',%al // Leading zero?
< je hexout.1 // Yes
< testb %al,%al // End of string?
< jne hexout.2 // No
< decl %esi // Undo
< hexout.2: decl %esi // Adjust for inc
< call putstr // Display hex
< popl %edi // Restore
< popl %esi // caller's
< ret // To caller
---
> hexout: pushl %eax # Save
> call putstr # Display message
> popl %eax # Restore
> pushl %esi # Save
> pushl %edi # caller's
> movl $buf,%edi # Buffer
> pushl %edi # Save
> call hex32 # To hex
> xorb %al,%al # Terminate
> stosb # string
> popl %esi # Restore
> hexout.1: lodsb # Get a char
> cmpb $'0',%al # Leading zero?
> je hexout.1 # Yes
> testb %al,%al # End of string?
> jne hexout.2 # No
> decl %esi # Undo
> hexout.2: decl %esi # Adjust for inc
> call putstr # Display hex
> popl %edi # Restore
> popl %esi # caller's
> ret # To caller
283,287c283,287
< putstr.0: call putchr // Output char
< putstr: lodsb // Load char
< testb %al,%al // End of string?
< jne putstr.0 // No
< ret // To caller
---
> putstr.0: call putchr # Output char
> putstr: lodsb # Load char
> testb %al,%al # End of string?
> jne putstr.0 # No
> ret # To caller
291,328c291,328
< putchr: pusha // Save
< xorl %ecx,%ecx // Zero for loops
< movb $SCR_MAT,%ah // Mode/attribute
< movl $BDA_POS,%ebx // BDA pointer
< movw (%ebx),%dx // Cursor position
< movl $0xb8000,%edi // Regen buffer (color)
< cmpb %ah,BDA_SCR-BDA_POS(%ebx) // Mono mode?
< jne putchr.1 // No
< xorw %di,%di // Regen buffer (mono)
< putchr.1: cmpb $0xa,%al // New line?
< je putchr.2 // Yes
< xchgl %eax,%ecx // Save char
< movb $SCR_COL,%al // Columns per row
< mulb %dh // * row position
< addb %dl,%al // + column
< adcb $0x0,%ah // position
< shll %eax // * 2
< xchgl %eax,%ecx // Swap char, offset
< movw %ax,(%edi,%ecx,1) // Write attr:char
< incl %edx // Bump cursor
< cmpb $SCR_COL,%dl // Beyond row?
< jb putchr.3 // No
< putchr.2: xorb %dl,%dl // Zero column
< incb %dh // Bump row
< putchr.3: cmpb $SCR_ROW,%dh // Beyond screen?
< jb putchr.4 // No
< leal 2*SCR_COL(%edi),%esi // New top line
< movw $(SCR_ROW-1)*SCR_COL/2,%cx // Words to move
< rep // Scroll
< movsl // screen
< movb $' ',%al // Space
< movb $SCR_COL,%cl // Columns to clear
< rep // Clear
< stosw // line
< movb $SCR_ROW-1,%dh // Bottom line
< putchr.4: movw %dx,(%ebx) // Update position
< popa // Restore
< ret // To caller
---
> putchr: pusha # Save
> xorl %ecx,%ecx # Zero for loops
> movb $SCR_MAT,%ah # Mode/attribute
> movl $BDA_POS,%ebx # BDA pointer
> movw (%ebx),%dx # Cursor position
> movl $0xb8000,%edi # Regen buffer (color)
> cmpb %ah,BDA_SCR-BDA_POS(%ebx) # Mono mode?
> jne putchr.1 # No
> xorw %di,%di # Regen buffer (mono)
> putchr.1: cmpb $0xa,%al # New line?
> je putchr.2 # Yes
> xchgl %eax,%ecx # Save char
> movb $SCR_COL,%al # Columns per row
> mulb %dh # * row position
> addb %dl,%al # + column
> adcb $0x0,%ah # position
> shll %eax # * 2
> xchgl %eax,%ecx # Swap char, offset
> movw %ax,(%edi,%ecx,1) # Write attr:char
> incl %edx # Bump cursor
> cmpb $SCR_COL,%dl # Beyond row?
> jb putchr.3 # No
> putchr.2: xorb %dl,%dl # Zero column
> incb %dh # Bump row
> putchr.3: cmpb $SCR_ROW,%dh # Beyond screen?
> jb putchr.4 # No
> leal 2*SCR_COL(%edi),%esi # New top line
> movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move
> rep # Scroll
> movsl # screen
> movb $' ',%al # Space
> movb $SCR_COL,%cl # Columns to clear
> rep # Clear
> stosw # line
> movb $SCR_ROW-1,%dh # Bottom line
> putchr.4: movw %dx,(%ebx) # Update position
> popa # Restore
> ret # To caller
332,348c332,348
< hex32: pushl %eax // Save
< shrl $0x10,%eax // Do upper
< call hex16 // 16
< popl %eax // Restore
< hex16: call hex16.1 // Do upper 8
< hex16.1: xchgb %ah,%al // Save/restore
< hex8: pushl %eax // Save
< shrb $0x4,%al // Do upper
< call hex8.1 // 4
< popl %eax // Restore
< hex8.1: andb $0xf,%al // Get lower 4
< cmpb $0xa,%al // Convert
< sbbb $0x69,%al // to hex
< das // digit
< orb $0x20,%al // To lower case
< stosb // Save char
< ret // (Recursive)
---
> hex32: pushl %eax # Save
> shrl $0x10,%eax # Do upper
> call hex16 # 16
> popl %eax # Restore
> hex16: call hex16.1 # Do upper 8
> hex16.1: xchgb %ah,%al # Save/restore
> hex8: pushl %eax # Save
> shrb $0x4,%al # Do upper
> call hex8.1 # 4
> popl %eax # Restore
> hex8.1: andb $0xf,%al # Get lower 4
> cmpb $0xa,%al # Convert
> sbbb $0x69,%al # to hex
> das # digit
> orb $0x20,%al # To lower case
> stosb # Save char
> ret # (Recursive)
355,359c355,359
< gdt: .word 0x0,0x0,0x0,0x0 // Null entry
< .word 0xffff,0x0,0x9a00,0xcf // SEL_SCODE
< .word 0xffff,0x0,0x9200,0xcf // SEL_SDATA
< .word 0xffff,0x0,0x9a00,0x0 // SEL_RCODE
< .word 0xffff,0x0,0x9200,0x0 // SEL_RDATA
---
> gdt: .word 0x0,0x0,0x0,0x0 # Null entry
> .word 0xffff,0x0,0x9a00,0xcf # SEL_SCODE
> .word 0xffff,0x0,0x9200,0xcf # SEL_SDATA
> .word 0xffff,0x0,0x9a00,0x0 # SEL_RCODE
> .word 0xffff,0x0,0x9200,0x0 # SEL_RDATA
361,362c361,362
< gdtdesc: .word gdt.1-gdt-1 // Limit
< .long gdt // Base
---
> gdtdesc: .word gdt.1-gdt-1 # Limit
> .long gdt # Base
396c396
< buf: // Scratch buffer
---
> buf: # Scratch buffer