Annotation of XNU/osfmk/i386/AT386/asm_startup.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /*
        !            23:  * @OSF_COPYRIGHT@
        !            24:  */
        !            25: /* 
        !            26:  * Mach Operating System
        !            27:  * Copyright (c) 1991,1990 Carnegie Mellon University
        !            28:  * All Rights Reserved.
        !            29:  * 
        !            30:  * Permission to use, copy, modify and distribute this software and its
        !            31:  * documentation is hereby granted, provided that both the copyright
        !            32:  * notice and this permission notice appear in all copies of the
        !            33:  * software, derivative works or modified versions, and any portions
        !            34:  * thereof, and that both notices appear in supporting documentation.
        !            35:  * 
        !            36:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            37:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !            38:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            39:  * 
        !            40:  * Carnegie Mellon requests users of this software to return to
        !            41:  * 
        !            42:  *  Software Distribution Coordinator  or  [email protected]
        !            43:  *  School of Computer Science
        !            44:  *  Carnegie Mellon University
        !            45:  *  Pittsburgh PA 15213-3890
        !            46:  * 
        !            47:  * any improvements or extensions that they make and grant Carnegie Mellon
        !            48:  * the rights to redistribute these changes.
        !            49:  */
        !            50: 
        !            51: #ifndef        __MACHO__
        !            52: /*
        !            53:  * Startup code for an i386 on an AT.
        !            54:  * Kernel is loaded starting at 1MB.
        !            55:  * Protected mode, paging disabled.
        !            56:  */
        !            57: 
        !            58:        popl    %eax
        !            59:        cmpl    $-1,%eax                /* new calling convention */
        !            60:        je      0f
        !            61: 
        !            62: /*
        !            63:  * Old calling convention
        !            64:  *
        !            65:  * %esp ->     boottype (deprecated)
        !            66:  *             size of extended memory (K)
        !            67:  *             size of conventional memory (K)
        !            68:  *             boothowto (deprecated)
        !            69:  *             esym (if KDB set up)
        !            70:  */
        !            71: #define SYS_REBOOT_COMPAT      1
        !            72: #if    SYS_REBOOT_COMPAT
        !            73:        movl    %eax,PA(EXT(boottype))
        !            74: #endif
        !            75:        popl    PA(EXT(extmem))         /* extended memory, in K */
        !            76:        popl    PA(EXT(cnvmem))         /* conventional memory, in K */
        !            77:        popl    %edx                    /* old boothowto */
        !            78: #if    SYS_REBOOT_COMPAT
        !            79: #define RB_SINGLE      0x2
        !            80: #define RB_HALT                0x8
        !            81: #define RB_ALTBOOT     0x40
        !            82:        testb   $(RB_SINGLE),%edx       /* old RB_SINGLE flag ? */
        !            83:        je      2f
        !            84:        incl    PA(EXT(startup_single_user))
        !            85: 2:     testb   $(RB_HALT),%edx         /* old RB_HALT flag ? */
        !            86:        je      2f
        !            87:        incl    PA(EXT(halt_in_debugger))
        !            88: 2:     testb   $(RB_ALTBOOT),%edx      /* old RB_ALTBOOT flag ? */
        !            89:        je      2f
        !            90:        incl    PA(EXT(cons_is_com1))
        !            91: 2:     
        !            92: #if    NCPUS   > 1
        !            93:        shrl    $0x8,%edx
        !            94:        movb    %edx,PA(EXT(wncpu))     /* old want ncpus flag */
        !            95: #endif
        !            96: #endif
        !            97: 
        !            98:        popl    %eax                    /* get boot_string & esym */
        !            99: #if    SYS_REBOOT_COMPAT
        !           100:        movl    %eax, %esi
        !           101:        lea     PA(EXT(boot_string_store)), %edi
        !           102:        movl    PA(EXT(boot_string_sz)), %ecx
        !           103:        cld
        !           104:        rep
        !           105:        movsb
        !           106: #endif
        !           107: 
        !           108: /*
        !           109:  * Move symbol table out of the way of BSS.
        !           110:  *
        !           111:  * When kernel is loaded, at the start of BSS we have:
        !           112:  * _edata:
        !           113:  *             .long   kern_sym_size
        !           114:  *             .long   boot_image_size
        !           115:  *             .long   load_info_size
        !           116:  * sym_start:
        !           117:  *             kernel symbols
        !           118:  *             .align  ALIGN
        !           119:  * boot_start:
        !           120:  *             bootstrap image
        !           121:  *             .align  ALIGN
        !           122:  * load_info_start:
        !           123:  *             bootstrap load information
        !           124:  *
        !           125:  * all of which must be moved somewhere else, since it
        !           126:  * is sitting in the kernel BSS.  In addition, the bootstrap
        !           127:  * image must be moved to a machine page boundary, so that we get:
        !           128:  *
        !           129:  * _edata:
        !           130:  *             BSS
        !           131:  * _end:                       <-      kern_sym_start (VA)
        !           132:  *             kernel symbols          . (kern_sym_size)
        !           133:  * <next page boundary>:       <-      boot_start (VA)
        !           134:  *             bootstrap image
        !           135:  *                             <-      load_info_start (VA)
        !           136:  *             load information
        !           137:  *                             <-      %ebx (PA)
        !           138:  *
        !           139:  */
        !           140:        lea     PA(EXT(edata))+4-1,%esi /* point to symbol size word */
        !           141:        andl    $~0x3,%esi
        !           142:        movl    (%esi),%edx             /* get symbol size */
        !           143: 
        !           144:        lea     PA(EXT(end))+NBPG-1(%edx),%edi
        !           145:                                        /* point after BSS, add symbol */
        !           146:                                        /* size, and round up to */
        !           147:        andl    $-NBPG,%edi             /* machine page boundary */
        !           148: 
        !           149:        lea     -KVTOPHYS(%edi),%eax    /* save virtual address */
        !           150:        movl    %eax,PA(EXT(boot_start)) /* of start of bootstrap */
        !           151:        movl    4(%esi),%ecx            /* get size of bootstrap */
        !           152:        movl    %ecx,PA(EXT(boot_size)) /* save size of bootstrap */
        !           153:        lea     -KVTOPHYS(%edi,%ecx),%eax
        !           154:        movl    %eax,PA(EXT(load_info_start))
        !           155:                                        /* save virtual address */
        !           156:                                        /* of start of loader info */
        !           157:        movl    8(%esi),%eax            /* get size of loader info */
        !           158:        movl    %eax,PA(EXT(load_info_size))
        !           159:                                        /* save size of loader info */
        !           160:        addl    %eax,%ecx               /* get total size to move */
        !           161: 
        !           162:        leal    12(%esi,%edx),%esi      /* point to start of boot image - source */
        !           163: 
        !           164:        leal    (%edi,%ecx),%ebx        /* point to new location of */
        !           165:                                        /* end of bootstrap - next */
        !           166:                                        /* available physical address */
        !           167: 
        !           168:        lea     -4(%esi,%ecx),%esi      /* point to end of src - 4 */
        !           169:        lea     -4(%edi,%ecx),%edi      /* point to end of dst - 4 */
        !           170:        shrl    $2,%ecx                 /* move by longs */
        !           171:        std                             /* move backwards */
        !           172:        rep
        !           173:        movsl                           /* move bootstrap and loader_info */
        !           174:        cld                             /* reset direction flag */
        !           175: 
        !           176:        movl    $EXT(end),PA(EXT(kern_sym_start))
        !           177:                                        /* save virtual address */
        !           178:                                        /* of start of symbols */
        !           179:        movl    %edx,PA(EXT(kern_sym_size)) /* save symbol table size */
        !           180:        testl   %edx,%edx               /* any symbols? */
        !           181:        jz      1f                      /* if so: */
        !           182: 
        !           183:                                        /* %esi points to start of boot-4 */
        !           184:                                        /* == end of symbol table (source) - 4 */
        !           185:        leal    PA(EXT(end))-4(%edx),%edi /* point to end of dst - 4 */
        !           186:        movl    %edx,%ecx               /* copy size */
        !           187:        shrl    $2,%ecx                 /* move by longs */
        !           188:        std                             /* move backwards */
        !           189:        rep
        !           190:        movsl                           /* move symbols */
        !           191:        cld                             /* reset direction flag */
        !           192: 
        !           193:        jmp     1f
        !           194: 
        !           195: /*
        !           196:  * New calling convention
        !           197:  *
        !           198:  * %esp ->     -1
        !           199:  *             size of extended memory (K)
        !           200:  *             size of conventional memory (K)
        !           201:  *             kern_sym_start
        !           202:  *             kern_sym_size
        !           203:  *             kern_args_start
        !           204:  *             kern_args_size
        !           205:  *             boot_sym_start
        !           206:  *             boot_sym_size
        !           207:  *             boot_args_start
        !           208:  *             boot_args_size
        !           209:  *             boot_start
        !           210:  *             boot_size
        !           211:  *             boot_region_desc
        !           212:  *             boot_region_count
        !           213:  *             boot_thread_state_flavor
        !           214:  *             boot_thread_state
        !           215:  *             boot_thread_state_count
        !           216:  *             env_start
        !           217:  *             env_size
        !           218:  *             top of loaded memory
        !           219:  */
        !           220: 
        !           221: #define MEM_BASE 0
        !           222: 
        !           223: #define BOOT_TO_VIRT   (MEM_BASE-(KVTOPHYS))
        !           224:        .globl  EXT(boot_start)
        !           225: 
        !           226: 0:
        !           227:        popl    PA(EXT(extmem))         /* extended memory, in K */
        !           228:        popl    PA(EXT(cnvmem))         /* conventional memory, in K */
        !           229:        popl    %eax
        !           230:        addl    $BOOT_TO_VIRT,%eax      /* convert to virtual address */
        !           231:        movl    %eax,PA(EXT(kern_sym_start))
        !           232:        popl    PA(EXT(kern_sym_size))
        !           233:        popl    %eax
        !           234:        addl    $BOOT_TO_VIRT,%eax      /* convert to virtual address */
        !           235:        movl    %eax,PA(EXT(kern_args_start))
        !           236:        popl    PA(EXT(kern_args_size))
        !           237:        popl    %eax
        !           238:        addl    $BOOT_TO_VIRT,%eax      /* convert to virtual address */
        !           239:        movl    %eax,PA(EXT(boot_sym_start))
        !           240:        popl    PA(EXT(boot_sym_size))
        !           241:        popl    %eax
        !           242:        addl    $BOOT_TO_VIRT,%eax      /* convert to virtual address */
        !           243:        movl    %eax,PA(EXT(boot_args_start))
        !           244:        popl    PA(EXT(boot_args_size))
        !           245:        popl    %eax
        !           246:        addl    $BOOT_TO_VIRT,%eax      /* convert to virtual address */
        !           247:        movl    %eax,PA(EXT(boot_start))
        !           248:        popl    PA(EXT(boot_size))
        !           249:        popl    %eax
        !           250:        addl    $BOOT_TO_VIRT,%eax      /* convert to virtual address */
        !           251:        movl    %eax,PA(EXT(boot_region_desc))
        !           252:        popl    PA(EXT(boot_region_count))
        !           253:        popl    PA(EXT(boot_thread_state_flavor))
        !           254:        popl    %eax
        !           255:        addl    $BOOT_TO_VIRT,%eax      /* convert to virtual address */
        !           256:        movl    %eax,PA(EXT(boot_thread_state))
        !           257:        popl    PA(EXT(boot_thread_state_count))
        !           258:        popl    %eax
        !           259:        addl    $BOOT_TO_VIRT,%eax      /* convert to virtual address */
        !           260:        movl    %eax,PA(EXT(env_start))
        !           261:        popl    PA(EXT(env_size))
        !           262:        popl    %ebx                    /* mem top  */
        !           263:        addl    $MEM_BASE,%ebx          /* translate */
        !           264: 1:
        !           265: #else
        !           266:        cld
        !           267:        call    PA(EXT(i386_preinit))
        !           268:        movl    %eax,%ebx
        !           269: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.