Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/stand/lib KNF and explain a few things



details:   https://anonhg.NetBSD.org/src/rev/7b83b0d97be0
branches:  trunk
changeset: 349285:7b83b0d97be0
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Dec 04 08:21:08 2016 +0000

description:
KNF and explain a few things

diffstat:

 sys/arch/i386/stand/lib/biosmem.S    |   24 +++---
 sys/arch/i386/stand/lib/biosmemps2.S |   63 +++++++++---------
 sys/arch/i386/stand/lib/biosmemx.S   |   92 ++++++++++++++------------
 sys/arch/i386/stand/lib/exec.c       |   50 +++++++-------
 sys/arch/i386/stand/lib/multiboot.S  |  107 ++++++++++++++++---------------
 sys/arch/i386/stand/lib/startprog.S  |  116 +++++++++++++++++-----------------
 6 files changed, 230 insertions(+), 222 deletions(-)

diffs (truncated from 744 to 300 lines):

diff -r 31868da0bb42 -r 7b83b0d97be0 sys/arch/i386/stand/lib/biosmem.S
--- a/sys/arch/i386/stand/lib/biosmem.S Sun Dec 04 03:38:58 2016 +0000
+++ b/sys/arch/i386/stand/lib/biosmem.S Sun Dec 04 08:21:08 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: biosmem.S,v 1.9 2011/06/16 13:27:59 joerg Exp $        */
+/*     $NetBSD: biosmem.S,v 1.10 2016/12/04 08:21:08 maxv Exp $        */
 
 /*
  * Copyright (c) 1996
@@ -36,8 +36,9 @@
 
        .text
 
-/* get mem below 1M, in kByte */
-
+/*
+ * Get mem below 1M, in kByte.
+ */
 ENTRY(getbasemem)
        pusha
 
@@ -45,18 +46,19 @@
        .code16
 
        int     $0x12
-       # zero-extend 16-bit result to 32 bits.
-       movzwl  %ax, %eax
+       /* Zero-extend 16-bit result to 32 bits */
+       movzwl  %ax,%eax
 
        calll   _C_LABEL(real_to_prot)
        .code32
 
-       movl    %eax, 28(%esp)
+       movl    %eax,28(%esp)
        popa
        ret
 
-/* get mem above 1M, in kByte */
-
+/*
+ * Get mem above 1M, in kByte.
+ */
 ENTRY(getextmem1)
        pusha
 
@@ -66,13 +68,13 @@
        movb    $0x88,%ah
        int     $0x15
 
-       # zero-extend 16-bit result to 32 bits.
-       movzwl  %ax, %eax
+       /* Zero-extend 16-bit result to 32 bits */
+       movzwl  %ax,%eax
 
        calll   _C_LABEL(real_to_prot)
        .code32
 
-       movl    %eax, 28(%esp)
+       movl    %eax,28(%esp)
        popa
        ret
 
diff -r 31868da0bb42 -r 7b83b0d97be0 sys/arch/i386/stand/lib/biosmemps2.S
--- a/sys/arch/i386/stand/lib/biosmemps2.S      Sun Dec 04 03:38:58 2016 +0000
+++ b/sys/arch/i386/stand/lib/biosmemps2.S      Sun Dec 04 08:21:08 2016 +0000
@@ -1,6 +1,6 @@
-/*     $NetBSD: biosmemps2.S,v 1.6 2011/06/16 13:27:59 joerg Exp $     */
+/*     $NetBSD: biosmemps2.S,v 1.7 2016/12/04 08:21:08 maxv Exp $      */
 
-/*-
+/*
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
@@ -33,55 +33,58 @@
 
        .text
 
-/* int getextmemp2(void buffer)
-   call int 15 function 0xc7 - later PS/2s - RETURN MEMORY-MAP INFORMATION
-   return: 0=OK, nonzero=error
-   buffer: filled with memory-map table structure
-*/
+/*
+ * int getextmemps2(void *buffer)
+ *
+ * call int 15 function 0xc7 - later PS/2s - RETURN MEMORY-MAP INFORMATION
+ * return: 0=OK, nonzero=error
+ * buffer: filled with memory-map table structure
+ */
 ENTRY(getextmemps2)
        .code32
-       movl    %eax, %edx
-       xorl    %eax, %eax
+       movl    %eax,%edx
+       xorl    %eax,%eax
        pusha
 
        call    _C_LABEL(prot_to_real)
        .code16
 
-       # do int15, function 0xc0 call to discover if C7h is supported
-       movb    $0xc0, %ah
+       /* do int15, function 0xc0 call to discover if C7h is supported */
+       movb    $0xc0,%ah
        int     $0x15
        setc    %cl
-       jc      out             # 0xc0 not supported if carry set
+       jc      out             /* 0xc0 not supported if carry set */
 
-       # check feature byte 2, bit 4 to see if return memory map is supported
-       movb    %es:6(%bx), %al
-       andb    $0x10, %al
-       jnz     getmem          # 0xc7 supported
-       
-       # set %cl to indicate failure, and exit
-       movb    $2, %cl
+       /* check feature byte 2, bit 4 to see if return memory map is supported */
+       movb    %es:6(%bx),%al
+       andb    $0x10,%al
+       jnz     getmem          /* 0xc7 supported */
+
+       /* set %cl to indicate failure, and exit */
+       movb    $2,%cl
        jmp     out
 
 getmem:
-       # move the parameter to right register
+       /* move the parameter to right register */
        push    %ds
-       movl    %edx, %esi
-       andl    $0xf, %esi
-       shrl    $4, %edx
-       mov     %ds, %ax
-       add     %dx, %ax
-       mov     %ax, %ds
+       movl    %edx,%esi
+       andl    $0xf,%esi
+       shrl    $4,%edx
+       mov     %ds,%ax
+       add     %dx,%ax
+       mov     %ax,%ds
 
-       # actually call int15, function 0xc7 now
-       movb    $0xc7, %ah
+       /* actually call int15, function 0xc7 now */
+       movb    $0xc7,%ah
        int     $0x15
-       setc    %cl             # save carry
+       setc    %cl             /* save carry */
        pop     %ds
 
 out:
        calll   _C_LABEL(real_to_prot)
        .code32
 
-       movb    %cl, 28(%esp)
+       movb    %cl,28(%esp)
        popa
        ret
+
diff -r 31868da0bb42 -r 7b83b0d97be0 sys/arch/i386/stand/lib/biosmemx.S
--- a/sys/arch/i386/stand/lib/biosmemx.S        Sun Dec 04 03:38:58 2016 +0000
+++ b/sys/arch/i386/stand/lib/biosmemx.S        Sun Dec 04 08:21:08 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: biosmemx.S,v 1.9 2008/10/14 14:18:11 ad Exp $  */
+/*     $NetBSD: biosmemx.S,v 1.10 2016/12/04 08:21:08 maxv Exp $       */
 
 /*
  * Copyright (c) 1997, 1999
@@ -30,11 +30,13 @@
 
        .text
 
-/* int getextmem2(int buffer[2])
-   return: 0=OK, -1=error
-   buffer[0]: extmem kBytes below 16M (max 15M/1024)
-   buffer[1]: extmem above 16M, in 64k units
-*/
+/*
+ * int getextmem2(int buffer[2])
+ *
+ * return: 0=OK, -1=error
+ * buffer[0]: extmem kBytes below 16M (max 15M/1024)
+ * buffer[1]: extmem above 16M, in 64k units
+ */
 ENTRY(getextmem2)
        pushl   %ebp
        movl    %esp,%ebp
@@ -47,16 +49,16 @@
        call    _C_LABEL(prot_to_real)
        .code16
 
-       xorl    %ebx, %ebx
-       movl    $0xe801, %eax
+       xorl    %ebx,%ebx
+       movl    $0xe801,%eax
        int     $0x15
        pushf
 
-       movw    %si, %ax
-       orw     %si, %bx
+       movw    %si,%ax
+       orw     %si,%bx
        jz      1f              /* if zero use configured values */
-       movw    %cx, %ax        /* k below 16M (max 0x3c00 = 15MB) */
-       movw    %dx, %bx        /* 64k above 16M */
+       movw    %cx,%ax         /* k below 16M (max 0x3c00 = 15MB) */
+       movw    %dx,%bx         /* 64k above 16M */
 1:
        popf
        setc    %bl
@@ -64,13 +66,13 @@
        calll   _C_LABEL(real_to_prot)
        .code32
 
-       movl    8(%ebp), %edi
-       xorl    %eax, %eax
-       movw    %cx, %ax
+       movl    8(%ebp),%edi
+       xorl    %eax,%eax
+       movw    %cx,%ax
        stosl
-       movw    %dx, %ax
+       movw    %dx,%ax
        stosl
-       movb    %bl, %al
+       movb    %bl,%al
        cbw
 
        pop     %edi
@@ -81,12 +83,14 @@
        popl    %ebp
        ret
 
-/* int getmementry(int *iterator, buffer[5])
-   return: 0=ok, else error
-   buffer[0]: start of memory chunk
-   buffer[2]: length (bytes)
-   buffer[4]: type
-*/
+/*
+ * int getmementry(int *iterator, int buffer[5])
+ *
+ * return: 0=ok, else error
+ * buffer[0]: start of memory chunk
+ * buffer[2]: length (bytes)
+ * buffer[4]: type
+ */
 ENTRY(getmementry)
        pushl   %ebp
        movl    %esp,%ebp
@@ -96,24 +100,24 @@
        push    %esi
        push    %edi
 
-       movl    8(%ebp), %eax
-       movl    0(%eax), %ebx           /* index */
-       movl    $20, %ecx               /* Buffer size */
-       movl    $0x534d4150, %edx       /* "SMAP" */
-       movl    12(%ebp), %edi          /* buffer address */
+       movl    8(%ebp),%eax
+       movl    0(%eax),%ebx            /* index */
+       movl    $20,%ecx                /* Buffer size */
+       movl    $0x534d4150,%edx        /* "SMAP" */
+       movl    12(%ebp),%edi           /* buffer address */
 
        call    _C_LABEL(prot_to_real)
        .code16
 
        push    %di
-       shrl    $4, %edi
-       mov     %ds, %ax
-       add     %di, %ax
-       mov     %ax, %es
+       shrl    $4,%edi
+       mov     %ds,%ax
+       add     %di,%ax
+       mov     %ax,%es
        pop     %di
-       and     $0xf, %di               /* buffer addres now in ES:DI */
+       and     $0xf,%di                /* buffer addres now in ES:DI */
 
-       movl    $0xe820, %eax           /* Some BIOS check EAX value */
+       movl    $0xe820,%eax            /* Some BIOS check EAX value */
        int     $0x15
 
        setc    %cl
@@ -121,10 +125,10 @@
        calll   _C_LABEL(real_to_prot)
        .code32
 
-       movl    8(%ebp), %eax
-       movl    %ebx, 0(%eax)           /* updated index */
-       xorl    %eax, %eax
-       movb    %cl, %al
+       movl    8(%ebp),%eax
+       movl    %ebx,0(%eax)            /* updated index */
+       xorl    %eax,%eax



Home | Main Index | Thread Index | Old Index