From e97d62405b02d43608d08d44c82a21cf1221e4c1 Mon Sep 17 00:00:00 2001 From: ru Date: Wed, 28 Apr 2004 10:15:31 +0000 Subject: MFi386: Use C (and CPP) style comments for assembler-with-cpp sources, for lines that start with a comment. --- sys/boot/pc98/btx/btx/btx.S | 432 +++++++++++++++++++------------------- sys/boot/pc98/btx/btxldr/btxldr.S | 148 ++++++------- 2 files changed, 290 insertions(+), 290 deletions(-) (limited to 'sys/boot/pc98/btx') diff --git a/sys/boot/pc98/btx/btx/btx.S b/sys/boot/pc98/btx/btx/btx.S index 20dfc27..9100eb3 100644 --- a/sys/boot/pc98/btx/btx/btx.S +++ b/sys/boot/pc98/btx/btx/btx.S @@ -1,23 +1,23 @@ -# -# Copyright (c) 1998 Robert Nordier -# All rights reserved. -# -# Redistribution and use in source and binary forms are freely -# permitted provided that the above copyright notice and this -# paragraph and the following disclaimer are duplicated in all -# such forms. -# -# This software is provided "AS IS" and without any express or -# implied warranties, including, without limitation, the implied -# warranties of merchantability and fitness for a particular -# purpose. -# +/* + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + * + * $FreeBSD$ + */ -# $FreeBSD$ - -# -# Memory layout. -# +/* + * Memory layout. + */ .set MEM_BTX,0x1000 # Start of BTX memory .set MEM_ESP0,0x1800 # Supervisor stack .set MEM_BUF,0x1800 # Scratch buffer @@ -29,14 +29,14 @@ .set MEM_TBL,0x5000 # Page tables .set MEM_ORG,0x9000 # BTX code .set MEM_USR,0xa000 # Start of user memory -# -# Paging control. -# +/* + * Paging control. + */ .set PAG_SIZ,0x1000 # Page size .set PAG_CNT,0x1000 # Pages to map -# -# Segment selectors. -# +/* + * Segment selectors. + */ .set SEL_SCODE,0x8 # Supervisor code .set SEL_SDATA,0x10 # Supervisor data .set SEL_RCODE,0x18 # Real mode code @@ -44,33 +44,33 @@ .set SEL_UCODE,0x28|3 # User code .set SEL_UDATA,0x30|3 # User data .set SEL_TSS,0x38 # TSS -# -# Task state segment fields. -# +/* + * Task state segment fields. + */ .set TSS_ESP0,0x4 # PL 0 ESP .set TSS_SS0,0x8 # PL 0 SS .set TSS_ESP1,0xc # PL 1 ESP .set TSS_MAP,0x66 # I/O bit map base -# -# System calls. -# +/* + * System calls. + */ .set SYS_EXIT,0x0 # Exit .set SYS_EXEC,0x1 # Exec -# -# V86 constants. -# +/* + * V86 constants. + */ .set V86_FLG,0x208eff # V86 flag mask .set V86_STK,0x400 # V86 stack allowance -# -# Dump format control bytes. -# +/* + * Dump format control bytes. + */ .set DMP_X16,0x1 # Word .set DMP_X32,0x2 # Long .set DMP_MEM,0x4 # Memory .set DMP_EOL,0x8 # End of line -# -# Screen defaults and assumptions. -# +/* + * Screen defaults and assumptions. + */ #ifdef PC98 .set SCR_MAT,0xe1 # Mode/attribute #else @@ -78,9 +78,9 @@ #endif .set SCR_COL,0x50 # Columns per row .set SCR_ROW,0x19 # Rows per screen -# -# BIOS Data Area locations. -# +/* + * BIOS Data Area locations. + */ #ifdef PC98 .set BDA_MEM,0x501 # Free memory .set BDA_KEYFLAGS,0x53a # Keyboard shift-state flags @@ -92,23 +92,23 @@ .set BDA_POS,0x450 # Cursor position .set BDA_BOOT,0x472 # Boot howto flag #endif -# -# Derivations, for brevity. -# +/* + * Derivations, for brevity. + */ .set _ESP0H,MEM_ESP0>>0x8 # Byte 1 of ESP0 .set _ESP1H,MEM_ESP1>>0x8 # Byte 1 of ESP1 .set _TSSIO,MEM_MAP-MEM_TSS # TSS I/O base .set _TSSLM,MEM_DIR-MEM_TSS-1 # TSS limit .set _IDTLM,MEM_TSS-MEM_IDT-1 # IDT limit -# -# Code segment. -# +/* + * Code segment. + */ .globl start .code16 start: # Start of code -# -# BTX header. -# +/* + * BTX header. + */ btx_hdr: .byte 0xeb # Machine ID .byte 0xe # Header size .ascii "BTX" # Magic @@ -118,9 +118,9 @@ btx_hdr: .byte 0xeb # Machine ID .word PAG_CNT-MEM_ORG>>0xc # Paging control .word break-start # Text size .long 0x0 # Entry address -# -# Initialization routine. -# +/* + * Initialization routine. + */ init: cli # Disable interrupts xor %ax,%ax # Zero/segment mov %ax,%ss # Set up @@ -129,18 +129,18 @@ init: cli # Disable interrupts mov %ax,%ds # data pushl $0x2 # Clear popfl # flags -# -# Initialize memory. -# +/* + * Initialize memory. + */ mov $MEM_IDT,%di # Memory to initialize mov $(MEM_ORG-MEM_IDT)/2,%cx # Words to zero push %di # Save rep # Zero-fill stosw # memory pop %di # Restore -# -# Create IDT. -# +/* + * Create IDT. + */ mov $idtctl,%si # Control string init.1: lodsb # Get entry cbw # count @@ -161,17 +161,17 @@ init.2: shr %bx # Handle this int? init.3: lea 0x8(%di),%di # Next entry loop init.2 # Till set done jmp init.1 # Continue -# -# Initialize TSS. -# +/* + * Initialize TSS. + */ init.4: movb $_ESP0H,TSS_ESP0+1(%di) # Set ESP0 movb $SEL_SDATA,TSS_SS0(%di) # Set SS0 movb $_ESP1H,TSS_ESP1+1(%di) # Set ESP1 movb $_TSSIO,TSS_MAP(%di) # Set I/O bit map base #ifdef PAGING -# -# Create page directory. -# +/* + * Create page directory. + */ xor %edx,%edx # Page mov $PAG_SIZ>>0x8,%dh # size xor %eax,%eax # Zero @@ -181,9 +181,9 @@ init.4: movb $_ESP0H,TSS_ESP0+1(%di) # Set ESP0 init.5: stosl # Write entry add %dx,%ax # To next loop init.5 # Till done -# -# Create page tables. -# +/* + * Create page tables. + */ mov $MEM_TBL,%di # Page table mov $PAG_CNT>>0x8,%ch # Entries xor %ax,%ax # Start address @@ -202,9 +202,9 @@ init.7: stosl # Set entry add %edx,%eax # Next address loop init.6 # Till done #endif -# -# Bring up the system. -# +/* + * Bring up the system. + */ mov $0x2820,%bx # Set protected mode callw setpic # IRQ offsets lidt idtdesc # Set IDT @@ -220,15 +220,15 @@ init.7: stosl # Set entry #else or $0x01,%eax # mode #endif - mov %eax,%cr0 # + mov %eax,%cr0 # ljmp $SEL_SCODE,$init.8 # To 32-bit code .code32 init.8: xorl %ecx,%ecx # Zero movb $SEL_SDATA,%cl # To 32-bit movw %cx,%ss # stack -# -# Launch user task. -# +/* + * Launch user task. + */ movb $SEL_TSS,%cl # Set task ltr %cx # register movl $MEM_USR,%edx # User base address @@ -265,26 +265,26 @@ init.9: push $0x0 # general popl %fs # segment popl %gs # registers iret # To user mode -# -# Exit routine. -# +/* + * Exit routine. + */ exit: cli # Disable interrupts movl $MEM_ESP0,%esp # Clear stack -# -# Turn off paging. -# +/* + * Turn off paging. + */ movl %cr0,%eax # Get CR0 andl $~0x80000000,%eax # Disable movl %eax,%cr0 # paging xorl %ecx,%ecx # Zero movl %ecx,%cr3 # Flush TLB -# -# Restore the GDT in case we caught a kernel trap. -# +/* + * Restore the GDT in case we caught a kernel trap. + */ lgdt gdtdesc # Set GDT -# -# To 16 bits. -# +/* + * To 16 bits. + */ ljmpw $SEL_RCODE,$exit.1 # Reload CS .code16 exit.1: mov $SEL_RDATA,%cl # 16-bit selector @@ -293,9 +293,9 @@ exit.1: mov $SEL_RDATA,%cl # 16-bit selector mov %cx,%es # remaining mov %cx,%fs # segment mov %cx,%gs # registers -# -# To real-address mode. -# +/* + * To real-address mode. + */ dec %ax # Switch to mov %eax,%cr0 # real mode ljmp $0x0,$exit.2 # Reload CS @@ -309,9 +309,9 @@ exit.2: xor %ax,%ax # Real mode segment #endif callw setpic # IRQ offsets lidt ivtdesc # Set IVT -# -# Reboot or await reset. -# +/* + * Reboot or await reset. + */ sti # Enable interrupts testb $0x1,btx_hdr+0x7 # Reboot? exit.3: jz exit.3 # No @@ -325,9 +325,9 @@ exit.4: jmp exit.4 movw $0x1234, BDA_BOOT # Do a warm boot ljmp $0xf000,$0xfff0 # reboot the machine #endif -# -# Set IRQ offsets by reprogramming 8259A PICs. -# +/* + * Set IRQ offsets by reprogramming 8259A PICs. + */ #ifdef PC98 setpic: in $0x02,%al # Save master push %ax # IMR @@ -378,13 +378,13 @@ setpic: in $0x21,%al # Save master #endif retw # To caller .code32 -# -# Initiate return from V86 mode to user mode. -# +/* + * Initiate return from V86 mode to user mode. + */ inthlt: hlt # To supervisor mode -# -# Exception jump table. -# +/* + * Exception jump table. + */ intx00: push $0x0 # Int 0x0: #DE jmp ex_noc # Divide error push $0x1 # Int 0x1: #DB @@ -413,20 +413,20 @@ intx00: push $0x0 # Int 0x0: #DE jmp except # Page fault intx10: push $0x10 # Int 0x10: #MF jmp ex_noc # Floating-point error -# -# Handle #GP exception. -# +/* + * Handle #GP exception. + */ ex_v86: testb $0x2,0x12(%esp,1) # V86 mode? jz except # No jmp v86mon # To monitor -# -# Save a zero error code. -# +/* + * Save a zero error code. + */ ex_noc: pushl (%esp,1) # Duplicate int no movb $0x0,0x4(%esp,1) # Fake error code -# -# Handle exception. -# +/* + * Handle exception. + */ except: cld # String ops inc pushl %ds # Save pushl %es # most @@ -500,9 +500,9 @@ wait.2: except.2a: jmp exit # Exit except.3: leal 0x8(%esp,1),%esp # Discard err, int no iret # From interrupt -# -# Return to user mode from V86 mode. -# +/* + * Return to user mode from V86 mode. + */ intrtn: cld # String ops inc pushl %ds # Address popl %es # data @@ -542,9 +542,9 @@ intrtn.2: movl %edx,%esi # Segment registers popl %fs # segment popl %gs # registers iret # To user mode -# -# V86 monitor. -# +/* + * V86 monitor. + */ v86mon: cld # String ops inc pushl $SEL_SDATA # Set up for popl %ds # flat addressing @@ -608,69 +608,69 @@ v86mon.7: subl %edi,%esi # From linear popa # Restore leal 0x8(%esp,1),%esp # Discard int no, error iret # To V86 mode -# -# Emulate MOV EAX,CR0. -# +/* + * Emulate MOV EAX,CR0. + */ v86mov: movl %cr0,%eax # CR0 to movl %eax,0x1c(%ebp) # saved EAX incl %esi # Adjust IP -# -# Return from emulating a 0x0f prefixed instruction -# +/* + * Return from emulating a 0x0f prefixed instruction + */ v86preret: incl %esi # Adjust IP jmp v86mon.7 # Finish up -# -# Emulate WBINVD -# +/* + * Emulate WBINVD + */ v86wbinvd: wbinvd # Write back and invalidate # cache jmp v86preret # Finish up -# -# Emulate WRMSR -# +/* + * Emulate WRMSR + */ v86wrmsr: movl 0x18(%ebp),%ecx # Get user's %ecx (MSR to write) movl 0x14(%ebp),%edx # Load the value movl 0x1c(%ebp),%eax # to write wrmsr # Write MSR jmp v86preret # Finish up -# -# Emulate RDMSR -# +/* + * Emulate RDMSR + */ v86rdmsr: movl 0x18(%ebp),%ecx # MSR to read rdmsr # Read the MSR movl %eax,0x1c(%ebp) # Return the value of movl %edx,0x14(%ebp) # the MSR to the user jmp v86preret # Finish up -# -# Emulate CLI. -# +/* + * Emulate CLI. + */ v86cli: andb $~0x2,0x31(%ebp) # Clear IF jmp v86mon.7 # Finish up -# -# Emulate STI. -# +/* + * Emulate STI. + */ v86sti: orb $0x2,0x31(%ebp) # Set IF jmp v86mon.7 # Finish up -# -# Emulate PUSHF/PUSHFD. -# +/* + * Emulate PUSHF/PUSHFD. + */ v86pushf: subl %ecx,%ebx # Adjust SP cmpb $0x4,%cl # 32-bit je v86pushf.1 # Yes data16 # 16-bit v86pushf.1: movl %edx,(%ebx) # Save flags jmp v86mon.6 # Finish up -# -# Emulate IRET/IRETD. -# +/* + * Emulate IRET/IRETD. + */ v86iret: movzwl (%ebx),%esi # Load V86 IP movzwl 0x2(%ebx),%edi # Load V86 CS leal 0x4(%ebx),%ebx # Adjust SP movl %edi,0x2c(%ebp) # Save V86 CS xorl %edi,%edi # No ESI adjustment -# -# Emulate POPF/POPFD (and remainder of IRET/IRETD). -# +/* + * Emulate POPF/POPFD (and remainder of IRET/IRETD). + */ v86popf: cmpb $0x4,%cl # 32-bit? je v86popf.1 # Yes movl %edx,%eax # Initialize @@ -681,19 +681,19 @@ v86popf.1: movl (%ebx),%eax # Load flags andl $~V86_FLG,%edx # the orl %eax,%edx # flags jmp v86mon.5 # Finish up -# -# trap int 15, function 87 -# reads %es:%si from saved registers on stack to find a GDT containing -# source and destination locations -# reads count of words from saved %cx -# returns success by setting %ah to 0 -# -int15_87: pushl %eax # Save - pushl %ebx # some information +/* + * trap int 15, function 87 + * reads %es:%si from saved registers on stack to find a GDT containing + * source and destination locations + * reads count of words from saved %cx + * returns success by setting %ah to 0 + */ +int15_87: pushl %eax # Save + pushl %ebx # some information pushl %esi # onto the stack. pushl %edi - xorl %eax,%eax # clean EAX - xorl %ebx,%ebx # clean EBX + xorl %eax,%eax # clean EAX + xorl %ebx,%ebx # clean EBX movl 0x4(%ebp),%esi # Get user's ESI movl 0x3C(%ebp),%ebx # store ES movw %si,%ax # store SI @@ -728,15 +728,15 @@ int15_87: pushl %eax # Save andb $0xfe,%dl # clear CF jmp v86mon.5 # Finish up -# -# Reboot the machine by setting the reboot flag and exiting -# +/* + * Reboot the machine by setting the reboot flag and exiting + */ reboot: orb $0x1,btx_hdr+0x7 # Set the reboot flag jmp exit # Terminate BTX and reboot -# -# Emulate INT imm8... also make sure to check if it's int 15/87 -# +/* + * Emulate INT imm8... also make sure to check if it's int 15/87 + */ v86intn: lodsb # Get int no cmpb $0x19,%al # is it int 19? je reboot # yes, reboot the machine @@ -775,9 +775,9 @@ v86intn.3: subl %edi,%esi # From xorl %edi,%edi # No ESI adjustment andb $~0x1,%dh # Clear TF jmp v86mon.5 # Finish up -# -# Hardware interrupt jump table. -# +/* + * Hardware interrupt jump table. + */ intx20: push $0x8 # Int 0x20: IRQ0 jmp int_hw # V86 int 0x8 push $0x9 # Int 0x21: IRQ1 @@ -829,9 +829,9 @@ intx20: push $0x8 # Int 0x20: IRQ0 push $0x77 # Int 0x2f: IRQ15 jmp int_hw # V86 int 0x77 #endif -# -# Reflect hardware interrupts. -# +/* + * Reflect hardware interrupts. + */ int_hw: testb $0x2,0xe(%esp,1) # V86 mode? jz intusr # No pushl $SEL_SDATA # Address @@ -858,14 +858,14 @@ int_hw: testb $0x2,0xe(%esp,1) # V86 mode? popl %ebp # saved popl %eax # registers iret # To V86 mode -# -# Invoke V86 interrupt from user mode, with arguments. -# +/* + * Invoke V86 interrupt from user mode, with arguments. + */ intx31: stc # Have btx_v86 pushl %eax # Missing int no -# -# Invoke V86 interrupt from user mode. -# +/* + * Invoke V86 interrupt from user mode. + */ intusr: std # String ops dec pushl %eax # Expand pushl %eax # stack @@ -950,9 +950,9 @@ intusr.5: movl %eax,%ecx # Save leal 0x10(%esp,1),%esp # Discard seg regs popa # Restore iret # To V86 mode -# -# System Call. -# +/* + * System Call. + */ intx30: cmpl $SYS_EXEC,%eax # Exec system call? jne intx30.1 # No pushl %ss # Set up @@ -977,9 +977,9 @@ intx30: cmpl $SYS_EXEC,%eax # Exec system call? call *%eax # program intx30.1: orb $0x1,%ss:btx_hdr+0x7 # Flag reboot jmp exit # Exit -# -# Dump structure [EBX] to [EDI], using format string [ESI]. -# +/* + * Dump structure [EBX] to [EDI], using format string [ESI]. + */ dump.0: stosb # Save char dump: lodsb # Load char testb %al,%al # End of string? @@ -1048,9 +1048,9 @@ dump.8: popl %esi # Restore dump.9: jmp dump.0 # Continue dump.10: stosb # Terminate string ret # To caller -# -# Convert EAX, AX, or AL to hex, saving the result to [EDI]. -# +/* + * Convert EAX, AX, or AL to hex, saving the result to [EDI]. + */ hex32: pushl %eax # Save shrl $0x10,%eax # Do upper call hex16 # 16 @@ -1068,9 +1068,9 @@ hex8.1: andb $0xf,%al # Get lower 4 orb $0x20,%al # To lower case stosb # Save char ret # (Recursive) -# -# Output zero-terminated string [ESI] to the console. -# +/* + * Output zero-terminated string [ESI] to the console. + */ putstr.0: call putchr # Output char putstr: lodsb # Load char testb %al,%al # End of string? @@ -1081,7 +1081,7 @@ putstr: lodsb # Load char .set SIO_FMT,SIOFMT # 8N1 .set SIO_DIV,(115200/SIOSPD) # 115200 / SPD -# void sio_init(void) + * void sio_init(void) sio_init: movw $SIO_PRT+0x3,%dx # Data format reg movb $SIO_FMT|0x80,%al # Set format @@ -1098,14 +1098,14 @@ sio_init: movw $SIO_PRT+0x3,%dx # Data format reg outb %al,(%dx) # DTR incl %edx # Line status reg -# void sio_flush(void) + * void sio_flush(void) sio_flush.0: call sio_getc.1 # Get character sio_flush: call sio_ischar # Check for character jnz sio_flush.0 # Till none ret # To caller -# void sio_putc(int c) + * void sio_putc(int c) sio_putc: movw $SIO_PRT+0x5,%dx # Line status reg xor %ecx,%ecx # Timeout @@ -1119,7 +1119,7 @@ sio_putc.1: inb (%dx),%al # Transmitter outb %al,(%dx) # Write character sio_putc.2: ret $0x4 # To caller -# int sio_getc(void) + * int sio_getc(void) sio_getc: call sio_ischar # Character available? jz sio_getc # No @@ -1127,7 +1127,7 @@ sio_getc.1: subb $0x5,%dl # Receiver buffer reg inb (%dx),%al # Read character ret # To caller -# int sio_ischar(void) + * int sio_ischar(void) sio_ischar: movw $SIO_PRT+0x5,%dx # Line status register xorl %eax,%eax # Zero @@ -1135,9 +1135,9 @@ sio_ischar: movw $SIO_PRT+0x5,%dx # Line status register andb $0x1,%al # ready? ret # To caller -# -# Output character AL to the serial console. -# +/* + * Output character AL to the serial console. + */ putchr: pusha # Save cmpb $10, %al # is it a newline? jne putchr.1 # no?, then leave @@ -1150,9 +1150,9 @@ putchr.1: pushl %eax # Push the character popa # Restore ret # To caller #else -# -# Output character AL to the console. -# +/* + * Output character AL to the console. + */ putchr: pusha # Save xorl %ecx,%ecx # Zero for loops movb $SCR_MAT,%ah # Mode/attribute @@ -1221,9 +1221,9 @@ putchr.4: movw %dx,(%ebx) # Update position #endif .p2align 4 -# -# Global descriptor table. -# +/* + * Global descriptor table. + */ gdt: .word 0x0,0x0,0x0,0x0 # Null entry .word 0xffff,0x0,0x9a00,0xcf # SEL_SCODE .word 0xffff,0x0,0x9200,0xcf # SEL_SDATA @@ -1233,15 +1233,15 @@ gdt: .word 0x0,0x0,0x0,0x0 # Null entry .word 0xffff,MEM_USR,0xf200,0xcf# SEL_UDATA .word _TSSLM,MEM_TSS,0x8900,0x0 # SEL_TSS gdt.1: -# -# Pseudo-descriptors. -# +/* + * Pseudo-descriptors. + */ gdtdesc: .word gdt.1-gdt-1,gdt,0x0 # GDT idtdesc: .word _IDTLM,MEM_IDT,0x0 # IDT ivtdesc: .word 0x400-0x0-1,0x0,0x0 # IVT -# -# IDT construction control string. -# +/* + * IDT construction control string. + */ idtctl: .byte 0x10, 0x8e # Int 0x0-0xf .word 0x7dfb,intx00 # (exceptions) .byte 0x10, 0x8e # Int 0x10 @@ -1253,9 +1253,9 @@ idtctl: .byte 0x10, 0x8e # Int 0x0-0xf .byte 0x2, 0xee # Int 0x31-0x32 .word 0x1, intx31 # (V86, null) .byte 0x0 # End of string -# -# Dump format string. -# +/* + * Dump format string. + */ dmpfmt: .byte '\n' # "\n" .ascii "int" # "int=" .byte 0x80|DMP_X32, 0x40 # "00000000 " @@ -1299,8 +1299,8 @@ dmpfmt: .byte '\n' # "\n" .ascii "ss:esp" # "ss:esp=" .byte 0x80|DMP_MEM|DMP_EOL,0x0 # "00 00 ... 00 00\n" .asciz "BTX halted\n" # End -# -# End of BTX memory. -# +/* + * End of BTX memory. + */ .p2align 4 break: diff --git a/sys/boot/pc98/btx/btxldr/btxldr.S b/sys/boot/pc98/btx/btxldr/btxldr.S index 7a3964d..9c414a6 100644 --- a/sys/boot/pc98/btx/btxldr/btxldr.S +++ b/sys/boot/pc98/btx/btxldr/btxldr.S @@ -1,48 +1,48 @@ -# -# Copyright (c) 1998 Robert Nordier -# All rights reserved. -# -# Redistribution and use in source and binary forms are freely -# permitted provided that the above copyright notice and this -# paragraph and the following disclaimer are duplicated in all -# such forms. -# -# This software is provided "AS IS" and without any express or -# implied warranties, including, without limitation, the implied -# warranties of merchantability and fitness for a particular -# purpose. -# +/* + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + * + * $FreeBSD$ + */ -# $FreeBSD$ +/* + * Prototype BTX loader program, written in a couple of hours. The + * real thing should probably be more flexible, and in C. + */ -# -# Prototype BTX loader program, written in a couple of hours. The -# real thing should probably be more flexible, and in C. -# - -# -# Memory locations. -# +/* + * Memory locations. + */ .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 -# -# Segment selectors. -# +/* + * Segment selectors. + */ .set SEL_SCODE,0x8 # 4GB code .set SEL_SDATA,0x10 # 4GB data .set SEL_RCODE,0x18 # 64K code .set SEL_RDATA,0x20 # 64K data -# -# Paging constants. -# +/* + * Paging constants. + */ .set PAG_SIZ,0x1000 # Page size .set PAG_ENT,0x4 # Page entry size -# -# Screen constants. -# +/* + * Screen constants. + */ #ifdef PC98 .set SCR_MAT,0xe1 # Mode/attribute #else @@ -50,9 +50,9 @@ #endif .set SCR_COL,0x50 # Columns per row .set SCR_ROW,0x19 # Rows per screen -# -# BIOS Data Area locations. -# +/* + * BIOS Data Area locations. + */ #ifdef PC98 .set BDA_MEM,0xa1501 # Free memory .set BDA_POS,0xa153e # Cursor position @@ -61,17 +61,17 @@ .set BDA_SCR,0x449 # Video mode .set BDA_POS,0x450 # Cursor position #endif -# -# Required by aout gas inadequacy. -# +/* + * Required by aout gas inadequacy. + */ .set SIZ_STUB,0x1a # Size of stub -# -# We expect to be loaded by boot2 at the origin defined in ./Makefile. -# +/* + * We expect to be loaded by boot2 at the origin defined in ./Makefile. + */ .globl start -# -# BTX program loader for ELF clients. -# +/* + * BTX program loader for ELF clients. + */ start: cld # String ops inc #ifdef PC98 cli @@ -112,9 +112,9 @@ gdcwait.2: inb $0x60,%al call putstr # base memory #endif lgdt gdtdesc # Load new GDT -# -# Relocate caller's arguments. -# +/* + * Relocate caller's arguments. + */ #ifdef BTXLDR_VERBOSE movl $m_esp,%esi # Display movl %esp,%eax # caller @@ -156,9 +156,9 @@ start_null_bi: movl $0x18,%ecx # Allocate space call hexout # relocation call putstr # message #endif -# -# Set up BTX kernel. -# +/* + * Set up BTX kernel. + */ movl $MEM_ESP,%esp # Set up new stack movl $MEM_DATA,%ebx # Data segment movl $m_vers,%esi # Display BTX @@ -210,9 +210,9 @@ start_null_bi: movl $0x18,%ecx # Allocate space call hexout # base call putstr # address #endif -# -# Set up ELF-format client program. -# +/* + * Set up ELF-format client program. + */ cmpl $0x464c457f,(%ebx) # ELF magic number? je start.3 # Yes movl $e_fmt,%esi # Display error @@ -289,9 +289,9 @@ start.8: xorw %ax,%ax # Data ljmp $0,$MEM_ENTRY # Jump to BTX entry point start.9: .code32 -# -# Output message [ESI] followed by EAX in hex. -# +/* + * Output message [ESI] followed by EAX in hex. + */ hexout: pushl %eax # Save call putstr # Display message popl %eax # Restore @@ -314,17 +314,17 @@ hexout.2: decl %esi # Adjust for inc popl %edi # Restore popl %esi # caller's ret # To caller -# -# Output zero-terminated string [ESI] to the console. -# +/* + * Output zero-terminated string [ESI] to the console. + */ putstr.0: call putchr # Output char putstr: lodsb # Load char testb %al,%al # End of string? jne putstr.0 # No ret # To caller -# -# Output character AL to the console. -# +/* + * Output character AL to the console. + */ putchr: pusha # Save xorl %ecx,%ecx # Zero for loops movb $SCR_MAT,%ah # Mode/attribute @@ -401,9 +401,9 @@ putchr.4: movw %dx,(%ebx) # Update position #endif popa # Restore ret # To caller -# -# Convert EAX, AX, or AL to hex, saving the result to [EDI]. -# +/* + * Convert EAX, AX, or AL to hex, saving the result to [EDI]. + */ hex32: pushl %eax # Save shrl $0x10,%eax # Do upper call hex16 # 16 @@ -424,9 +424,9 @@ hex8.1: andb $0xf,%al # Get lower 4 .data .p2align 4 -# -# Global descriptor table. -# +/* + * Global descriptor table. + */ gdt: .word 0x0,0x0,0x0,0x0 # Null entry .word 0xffff,0x0,0x9a00,0xcf # SEL_SCODE .word 0xffff,0x0,0x9200,0xcf # SEL_SDATA @@ -435,9 +435,9 @@ gdt: .word 0x0,0x0,0x0,0x0 # Null entry gdt.1: gdtdesc: .word gdt.1-gdt-1 # Limit .long gdt # Base -# -# Messages. -# +/* + * Messages. + */ m_logo: .asciz " \nBTX loader 1.00 " m_vers: .asciz "BTX version is \0\n" e_fmt: .asciz "Error: Client format not supported\n" @@ -465,7 +465,7 @@ m_segs: .asciz "text segment: offset=" .asciz " memsz=\0\n" m_done: .asciz "Loading complete\n" #endif -# -# Uninitialized data area. -# +/* + * Uninitialized data area. + */ buf: # Scratch buffer -- cgit v1.1