Author: rdivacky
Date: Mon Apr  4 18:23:55 2011
New Revision: 220337
URL: http://svn.freebsd.org/changeset/base/220337

Log:
  Build boot2 with -mregparm=3, ie. pass upto 3 arguments via registers.
  This modifies CFLAGS and tweaks sio.S to use the new calling convention.
  The sio_init() and sio_putc() prototypes are modified so that other
  users of this code know the correct calling convention.
  
  This makes the code smaller when compiled with clang.
  
  Reviewed by:    jhb
  Tested by:      me and Freddie Cash <fjwcash gmail com>

Modified:
  head/sys/boot/i386/boot2/Makefile
  head/sys/boot/i386/boot2/lib.h
  head/sys/boot/i386/boot2/sio.S

Modified: head/sys/boot/i386/boot2/Makefile
==============================================================================
--- head/sys/boot/i386/boot2/Makefile   Mon Apr  4 17:44:26 2011        
(r220336)
+++ head/sys/boot/i386/boot2/Makefile   Mon Apr  4 18:23:55 2011        
(r220337)
@@ -31,6 +31,7 @@ CFLAGS=       -Os \
        -fno-unit-at-a-time \
        -mno-align-long-strings \
        -mrtd \
+       -mregparm=3 \
        -D${BOOT2_UFS} \
        -DFLAGS=${BOOT_BOOT1_FLAGS} \
        -DSIOPRT=${BOOT_COMCONSOLE_PORT} \

Modified: head/sys/boot/i386/boot2/lib.h
==============================================================================
--- head/sys/boot/i386/boot2/lib.h      Mon Apr  4 17:44:26 2011        
(r220336)
+++ head/sys/boot/i386/boot2/lib.h      Mon Apr  4 18:23:55 2011        
(r220337)
@@ -17,8 +17,8 @@
  * $FreeBSD$
  */
 
-void sio_init(int);
+void sio_init(int) __attribute__((regparm (3)));
 void sio_flush(void);
-void sio_putc(int);
+void sio_putc(int) __attribute__((regparm (3)));
 int sio_getc(void);
 int sio_ischar(void);

Modified: head/sys/boot/i386/boot2/sio.S
==============================================================================
--- head/sys/boot/i386/boot2/sio.S      Mon Apr  4 17:44:26 2011        
(r220336)
+++ head/sys/boot/i386/boot2/sio.S      Mon Apr  4 18:23:55 2011        
(r220337)
@@ -26,14 +26,14 @@
 
 /* void sio_init(int div) */
 
-sio_init:      movw $SIO_PRT+0x3,%dx           # Data format reg
+sio_init:      pushl %eax
+               movw $SIO_PRT+0x3,%dx           # Data format reg
                movb $SIO_FMT|0x80,%al          # Set format
                outb %al,(%dx)                  #  and DLAB
-               pushl %edx                      # Save
                subb $0x3,%dl                   # Divisor latch reg
-               movl 0x8(%esp),%eax             # Set
+               popl %eax
                outw %ax,(%dx)                  #  BPS
-               popl %edx                       # Restore
+               movw $SIO_PRT+0x3,%dx           # Data format reg
                movb $SIO_FMT,%al               # Clear
                outb %al,(%dx)                  #  DLAB
                incl %edx                       # Modem control reg
@@ -41,7 +41,7 @@ sio_init:     movw $SIO_PRT+0x3,%dx           # Data 
                outb %al,(%dx)                  #  DTR
                incl %edx                       # Line status reg
                call sio_flush
-               ret $0x4
+               ret
 
 /* void sio_flush(void) */
 
@@ -52,17 +52,18 @@ sio_flush:  call sio_ischar                 # Check for
 
 /* void sio_putc(int c) */
 
-sio_putc:      movw $SIO_PRT+0x5,%dx           # Line status reg
+sio_putc:      pushl %eax
+               movw $SIO_PRT+0x5,%dx           # Line status reg
                xor %ecx,%ecx                   # Timeout
                movb $0x40,%ch                  #  counter
 sio_putc.1:    inb (%dx),%al                   # Transmitter
                testb $0x20,%al                 #  buffer empty?
                loopz sio_putc.1                # No
                jz sio_putc.2                   # If timeout
-               movb 0x4(%esp,1),%al            # Get character
+               popl %eax                       # Get the character
                subb $0x5,%dl                   # Transmitter hold reg
                outb %al,(%dx)                  # Write character
-sio_putc.2:    ret $0x4                        # To caller
+sio_putc.2:    ret                             # To caller
 
 /* int sio_getc(void) */
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to