The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/osfmk/i386/genassym.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
    3  *
    4  * @APPLE_LICENSE_HEADER_START@
    5  * 
    6  * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
    7  * 
    8  * This file contains Original Code and/or Modifications of Original Code
    9  * as defined in and that are subject to the Apple Public Source License
   10  * Version 2.0 (the 'License'). You may not use this file except in
   11  * compliance with the License. Please obtain a copy of the License at
   12  * http://www.opensource.apple.com/apsl/ and read it before using this
   13  * file.
   14  * 
   15  * The Original Code and all software distributed under the License are
   16  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   17  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   18  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   19  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   20  * Please see the License for the specific language governing rights and
   21  * limitations under the License.
   22  * 
   23  * @APPLE_LICENSE_HEADER_END@
   24  */
   25 /*
   26  * @OSF_COPYRIGHT@
   27  */
   28 /* 
   29  * Mach Operating System
   30  * Copyright (c) 1991,1990 Carnegie Mellon University
   31  * All Rights Reserved.
   32  * 
   33  * Permission to use, copy, modify and distribute this software and its
   34  * documentation is hereby granted, provided that both the copyright
   35  * notice and this permission notice appear in all copies of the
   36  * software, derivative works or modified versions, and any portions
   37  * thereof, and that both notices appear in supporting documentation.
   38  * 
   39  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   40  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   41  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   42  * 
   43  * Carnegie Mellon requests users of this software to return to
   44  * 
   45  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   46  *  School of Computer Science
   47  *  Carnegie Mellon University
   48  *  Pittsburgh PA 15213-3890
   49  * 
   50  * any improvements or extensions that they make and grant Carnegie Mellon
   51  * the rights to redistribute these changes.
   52  */
   53 
   54 #include <platforms.h>
   55 #include <cpus.h>
   56 #include <mach_kdb.h>
   57 #include <mach_ldebug.h>
   58 #include <stat_time.h>
   59 
   60 /*
   61  * Pass field offsets to assembly code.
   62  */
   63 #include <kern/ast.h>
   64 #include <kern/thread.h>
   65 #include <kern/task.h>
   66 #include <kern/lock.h>
   67 #include <kern/thread_act.h>
   68 #include <ipc/ipc_space.h>
   69 #include <ipc/ipc_port.h>
   70 #include <ipc/ipc_pset.h>
   71 #include <kern/host.h>
   72 #include <kern/misc_protos.h>
   73 #include <kern/syscall_emulation.h>
   74 #include <i386/thread.h>
   75 #include <mach/i386/vm_param.h>
   76 #include <i386/seg.h>
   77 #include <i386/pmap.h>
   78 #include <i386/tss.h>
   79 #include <vm/vm_map.h>
   80 #if     NCPUS > 1
   81 #include <i386/mp_desc.h>
   82 #endif
   83 
   84 extern void   kernel_preempt_check(void);
   85 cpu_data_t    cpu_data[NCPUS];
   86 
   87 /*
   88  * genassym.c is used to produce an
   89  * assembly file which, intermingled with unuseful assembly code,
   90  * has all the necessary definitions emitted. This assembly file is
   91  * then postprocessed with sed to extract only these definitions
   92  * and thus the final assyms.s is created.
   93  *
   94  * This convoluted means is necessary since the structure alignment
   95  * and packing may be different between the host machine and the
   96  * target so we are forced into using the cross compiler to generate
   97  * the values, but we cannot run anything on the target machine.
   98  */
   99 
  100 #undef  offsetof
  101 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE)0)->MEMBER)
  102 
  103 #if  0
  104 #define DECLARE(SYM,VAL) \
  105         __asm("#DEFINITION#\t.set\t" SYM ",\t%0" : : "n" ((u_int)(VAL)))
  106 #else
  107 #define DECLARE(SYM,VAL) \
  108         __asm("#DEFINITION##define " SYM "\t%0" : : "n" ((u_int)(VAL)))
  109 #endif
  110 
  111 int     main(
  112                 int             argc,
  113                 char            ** argv);
  114 
  115 int
  116 main(
  117         int     argc,
  118         char    **argv)
  119 {
  120 
  121         DECLARE("AST_URGENT",           AST_URGENT);
  122 
  123         /* Simple Lock structure */
  124         DECLARE("SLOCK_ILK",    offsetof(usimple_lock_t, interlock));
  125 #if     MACH_LDEBUG
  126         DECLARE("SLOCK_TYPE",   offsetof(usimple_lock_t, lock_type));
  127         DECLARE("SLOCK_PC",     offsetof(usimple_lock_t, debug.lock_pc));
  128         DECLARE("SLOCK_THREAD", offsetof(usimple_lock_t, debug.lock_thread));
  129         DECLARE("SLOCK_DURATIONH",offsetof(usimple_lock_t, debug.duration[0]));
  130         DECLARE("SLOCK_DURATIONL",offsetof(usimple_lock_t, debug.duration[1]));
  131         DECLARE("USLOCK_TAG",   USLOCK_TAG);
  132 #endif  /* MACH_LDEBUG */
  133 
  134         /* Mutex structure */
  135         DECLARE("MUTEX_LOCKED", offsetof(mutex_t *, locked));
  136         DECLARE("MUTEX_WAITERS",offsetof(mutex_t *, waiters));
  137         DECLARE("MUTEX_PROMOTED_PRI",offsetof(mutex_t *, promoted_pri));
  138 #if     MACH_LDEBUG
  139         DECLARE("MUTEX_TYPE",   offsetof(mutex_t *, type));
  140         DECLARE("MUTEX_PC",     offsetof(mutex_t *, pc));
  141         DECLARE("MUTEX_THREAD", offsetof(mutex_t *, thread));
  142         DECLARE("MUTEX_TAG",    MUTEX_TAG);
  143 #endif  /* MACH_LDEBUG */
  144                                                  
  145 #if     MACH_LDEBUG
  146         DECLARE("TH_MUTEX_COUNT",       offsetof(thread_t, mutex_count));
  147 #endif  /* MACH_LDEBUG */
  148         DECLARE("TH_RECOVER",           offsetof(thread_t, recover));
  149         DECLARE("TH_CONTINUATION",      offsetof(thread_t, continuation));
  150         DECLARE("TH_TOP_ACT",           offsetof(thread_t, top_act));
  151         DECLARE("TH_KERNEL_STACK",      offsetof(thread_t, kernel_stack));
  152 
  153         DECLARE("TASK_EMUL",            offsetof(task_t, eml_dispatch));
  154         DECLARE("TASK_MACH_EXC_PORT",
  155                 offsetof(task_t, exc_actions[EXC_MACH_SYSCALL].port));
  156 
  157         /* These fields are being added on demand */
  158         DECLARE("ACT_MACH_EXC_PORT",
  159                 offsetof(thread_act_t, exc_actions[EXC_MACH_SYSCALL].port));
  160 
  161         DECLARE("ACT_THREAD",   offsetof(thread_act_t, thread));
  162         DECLARE("ACT_TASK",     offsetof(thread_act_t, task));
  163         DECLARE("ACT_PCB",      offsetof(thread_act_t, mact.pcb));
  164         DECLARE("ACT_LOWER",    offsetof(thread_act_t, lower));
  165         DECLARE("ACT_MAP",      offsetof(thread_act_t, map));
  166 
  167         DECLARE("MAP_PMAP",     offsetof(vm_map_t, pmap));
  168 
  169         DECLARE("DISP_MIN",     offsetof(eml_dispatch_t, disp_min));
  170         DECLARE("DISP_COUNT",   offsetof(eml_dispatch_t, disp_count));
  171         DECLARE("DISP_VECTOR",  offsetof(eml_dispatch_t, disp_vector[0]));
  172 
  173 #define IKS ((size_t) (STACK_IKS(0)))
  174 
  175         DECLARE("KSS_EBX", IKS + offsetof(struct i386_kernel_state *, k_ebx));
  176         DECLARE("KSS_ESP", IKS + offsetof(struct i386_kernel_state *, k_esp));
  177         DECLARE("KSS_EBP", IKS + offsetof(struct i386_kernel_state *, k_ebp));
  178         DECLARE("KSS_EDI", IKS + offsetof(struct i386_kernel_state *, k_edi));
  179         DECLARE("KSS_ESI", IKS + offsetof(struct i386_kernel_state *, k_esi));
  180         DECLARE("KSS_EIP", IKS + offsetof(struct i386_kernel_state *, k_eip));
  181 
  182         DECLARE("IKS_SIZE",     sizeof(struct i386_kernel_state));
  183         DECLARE("IEL_SIZE",     sizeof(struct i386_exception_link));
  184 
  185         DECLARE("PCB_FPS",      offsetof(pcb_t, ims.ifps));
  186         DECLARE("PCB_ISS",      offsetof(pcb_t, iss));
  187 
  188         DECLARE("FP_VALID",     offsetof(struct i386_fpsave_state *,fp_valid));
  189         DECLARE("FP_SAVE_STATE",
  190                 offsetof(struct i386_fpsave_state *, fp_save_state));
  191 
  192         DECLARE("R_CS",         offsetof(struct i386_saved_state *, cs));
  193         DECLARE("R_SS",         offsetof(struct i386_saved_state *, ss));
  194         DECLARE("R_UESP",       offsetof(struct i386_saved_state *, uesp));
  195         DECLARE("R_EBP",        offsetof(struct i386_saved_state *, ebp));
  196         DECLARE("R_EAX",        offsetof(struct i386_saved_state *, eax));
  197         DECLARE("R_EBX",        offsetof(struct i386_saved_state *, ebx));
  198         DECLARE("R_ECX",        offsetof(struct i386_saved_state *, ecx));
  199         DECLARE("R_EDX",        offsetof(struct i386_saved_state *, edx));
  200         DECLARE("R_ESI",        offsetof(struct i386_saved_state *, esi));
  201         DECLARE("R_EDI",        offsetof(struct i386_saved_state *, edi));
  202         DECLARE("R_TRAPNO",     offsetof(struct i386_saved_state *, trapno));
  203         DECLARE("R_ERR",        offsetof(struct i386_saved_state *, err));
  204         DECLARE("R_EFLAGS",     offsetof(struct i386_saved_state *, efl));
  205         DECLARE("R_EIP",        offsetof(struct i386_saved_state *, eip));
  206         DECLARE("R_CR2",        offsetof(struct i386_saved_state *, cr2));
  207         DECLARE("ISS_SIZE",     sizeof (struct i386_saved_state));
  208 
  209         DECLARE("I_ECX",        offsetof(struct i386_interrupt_state *, ecx));
  210         DECLARE("I_EIP",        offsetof(struct i386_interrupt_state *, eip));
  211         DECLARE("I_CS",         offsetof(struct i386_interrupt_state *, cs));
  212         DECLARE("I_EFL",        offsetof(struct i386_interrupt_state *, efl));
  213 
  214         DECLARE("NBPG",                 I386_PGBYTES);
  215         DECLARE("VM_MIN_ADDRESS",       VM_MIN_ADDRESS);
  216         DECLARE("VM_MAX_ADDRESS",       VM_MAX_ADDRESS);
  217         DECLARE("KERNELBASE",           VM_MIN_KERNEL_ADDRESS);
  218         DECLARE("LINEAR_KERNELBASE",    LINEAR_KERNEL_ADDRESS);
  219         DECLARE("KERNEL_STACK_SIZE",    KERNEL_STACK_SIZE);
  220 
  221         DECLARE("PDESHIFT",     PDESHIFT);
  222         DECLARE("PTESHIFT",     PTESHIFT);
  223         DECLARE("PTEMASK",      PTEMASK);
  224 
  225         DECLARE("PTE_PFN",      INTEL_PTE_PFN);
  226         DECLARE("PTE_V",        INTEL_PTE_VALID);
  227         DECLARE("PTE_W",        INTEL_PTE_WRITE);
  228         DECLARE("PTE_INVALID",  ~INTEL_PTE_VALID);
  229 
  230         DECLARE("IDTSZ",        IDTSZ);
  231         DECLARE("GDTSZ",        GDTSZ);
  232         DECLARE("LDTSZ",        LDTSZ);
  233 
  234         DECLARE("KERNEL_CS",    KERNEL_CS);
  235         DECLARE("KERNEL_DS",    KERNEL_DS);
  236         DECLARE("USER_CS",      USER_CS);
  237         DECLARE("USER_DS",      USER_DS);
  238         DECLARE("KERNEL_TSS",   KERNEL_TSS);
  239         DECLARE("KERNEL_LDT",   KERNEL_LDT);
  240 #if     MACH_KDB
  241         DECLARE("DEBUG_TSS",    DEBUG_TSS);
  242 #endif  /* MACH_KDB */
  243 
  244         DECLARE("CPU_DATA",     CPU_DATA);
  245         DECLARE("CPD_ACTIVE_THREAD",
  246                 offsetof(cpu_data_t *, active_thread));
  247 #if     MACH_RT
  248         DECLARE("CPD_PREEMPTION_LEVEL",
  249                 offsetof(cpu_data_t *, preemption_level));
  250 #endif  /* MACH_RT */
  251         DECLARE("CPD_INTERRUPT_LEVEL",
  252                 offsetof(cpu_data_t *, interrupt_level));
  253         DECLARE("CPD_SIMPLE_LOCK_COUNT",
  254                 offsetof(cpu_data_t *,simple_lock_count));
  255         DECLARE("CPD_CPU_NUMBER",
  256                 offsetof(cpu_data_t *,cpu_number));
  257         DECLARE("CPD_CPU_PHYS_NUMBER",
  258                 offsetof(cpu_data_t *,cpu_phys_number));
  259         DECLARE("CPD_CPU_STATUS",
  260                 offsetof(cpu_data_t *,cpu_status));
  261         DECLARE("CPD_MCOUNT_OFF",
  262                 offsetof(cpu_data_t *,mcount_off));
  263 
  264         DECLARE("PTES_PER_PAGE",        NPTES);
  265         DECLARE("INTEL_PTE_KERNEL",     INTEL_PTE_VALID|INTEL_PTE_WRITE);
  266 
  267         DECLARE("KERNELBASEPDE",
  268                 (LINEAR_KERNEL_ADDRESS >> PDESHIFT) *
  269                 sizeof(pt_entry_t));
  270 
  271         DECLARE("TSS_ESP0",     offsetof(struct i386_tss *, esp0));
  272         DECLARE("TSS_SS0",      offsetof(struct i386_tss *, ss0));
  273         DECLARE("TSS_LDT",      offsetof(struct i386_tss *, ldt));
  274         DECLARE("TSS_PDBR",     offsetof(struct i386_tss *, cr3));
  275         DECLARE("TSS_LINK",     offsetof(struct i386_tss *, back_link));
  276 
  277         DECLARE("K_TASK_GATE",  ACC_P|ACC_PL_K|ACC_TASK_GATE);
  278         DECLARE("K_TRAP_GATE",  ACC_P|ACC_PL_K|ACC_TRAP_GATE);
  279         DECLARE("U_TRAP_GATE",  ACC_P|ACC_PL_U|ACC_TRAP_GATE);
  280         DECLARE("K_INTR_GATE",  ACC_P|ACC_PL_K|ACC_INTR_GATE);
  281         DECLARE("K_TSS",        ACC_P|ACC_PL_K|ACC_TSS);
  282 
  283         /*
  284          *      usimple_lock fields
  285          */
  286         DECLARE("USL_INTERLOCK",        offsetof(usimple_lock_t, interlock));
  287 
  288         DECLARE("INTSTACK_SIZE",        INTSTACK_SIZE);
  289 #if     NCPUS > 1
  290         DECLARE("MP_GDT",          offsetof(struct mp_desc_table *, gdt[0]));
  291         DECLARE("MP_IDT",          offsetof(struct mp_desc_table *, idt[0]));
  292 #endif  /* NCPUS > 1 */
  293 #if     !STAT_TIME
  294         DECLARE("LOW_BITS",        offsetof(struct timer *, low_bits));
  295         DECLARE("HIGH_BITS",       offsetof(struct timer *, high_bits));
  296         DECLARE("HIGH_BITS_CHECK", offsetof(struct timer *, high_bits_check));
  297         DECLARE("TIMER_HIGH_UNIT", TIMER_HIGH_UNIT);
  298         DECLARE("TH_SYS_TIMER",    offsetof(struct timer *, system_timer));
  299         DECLARE("TH_USER_TIMER",   offsetof(struct timer *, user_timer));
  300 #endif
  301 
  302         return (0);
  303 }
  304 
  305 
  306 /* Dummy to keep linker quiet */
  307 void
  308 kernel_preempt_check(void)
  309 {
  310 }

Cache object: 421baf6b11953dd315d7cf2ff8690374


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.