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/ppc/savearea.h

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-2002 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 #ifndef _PPC_SAVEAREA_H_
   26 #define _PPC_SAVEAREA_H_
   27 
   28 #ifndef ASSEMBLER
   29 
   30 #include <sys/appleapiopts.h>
   31 
   32 #ifdef __APPLE_API_PRIVATE
   33 
   34 #ifdef  MACH_KERNEL_PRIVATE
   35 #include <stdint.h>
   36 #include <mach/vm_types.h>
   37 
   38 #pragma pack(4)                                                 /* Make sure the structure stays as we defined it */
   39 typedef struct savearea_comm {
   40 
   41 /*
   42  *      The following fields are common to all saveareas and are used to manage individual
   43  *      contexts.
   44  *      
   45  *      Fields that start with "save" are part of the individual saveareas.  Those that
   46  *      start with "sac" pertain to the free pool stuff and are valid only on the first slot
   47  *      in the page.
   48  */
   49 
   50 
   51 /*      Keep the save_prev, sac_next, and sac_prev in these positions, some assembler code depends upon it to
   52  *      match up with fields in saveanchor.
   53  */
   54                                                 /* offset 0x000 */
   55         addr64_t                save_prev;                                      /* The address of the previous (or next) savearea */
   56         addr64_t                sac_next;                                       /* Points to next savearea page that has a free slot  - real */
   57         addr64_t                sac_prev;                                       /* Points to previous savearea page that has a free slot  - real */
   58         unsigned int    save_level;                                     /* Context ID */
   59         unsigned int    save_01C;
   60 
   61                                                                                                 /*       0x20 */
   62         unsigned int    save_time[2];                           /* Context save time - for debugging or performance */
   63         struct thread_activation        *save_act;              /* Associated activation  */
   64     unsigned int        save_02c;
   65         uint64_t                sac_vrswap;                                     /* XOR mask to swap V to R or vice versa */
   66         unsigned int    save_flags;                                     /* Various flags */
   67         unsigned int    sac_flags;                                      /* Various flags */
   68     
   69                                                 /* offset 0x040 */
   70         uint64_t                save_misc0;                                     /* Various stuff */
   71         uint64_t                save_misc1;                                     /* Various stuff */
   72         unsigned int    sac_alloc;                                      /* Bitmap of allocated slots */
   73     unsigned int        save_054;
   74     unsigned int        save_misc2;
   75     unsigned int        save_misc3;
   76 
   77                                                                                                 /* offset 0x0060 */
   78 } savearea_comm;
   79 #pragma pack()
   80 #endif
   81 
   82 #ifdef BSD_KERNEL_PRIVATE
   83 typedef struct savearea_comm {
   84         unsigned int    save_000[24];
   85 } savearea_comm;
   86 #endif
   87 
   88 #if     defined(MACH_KERNEL_PRIVATE) || defined(BSD_KERNEL_PRIVATE)
   89 /*
   90  *      This type of savearea contains all of the general context.
   91  */
   92  
   93 #pragma pack(4)                                                 /* Make sure the structure stays as we defined it */
   94 typedef struct savearea {
   95 
   96         savearea_comm   save_hdr;                                       /* Stuff common to all saveareas */
   97 
   98         unsigned int    save_060[8];                            /* Fill 32 bytes */
   99 
  100                                                 /* offset 0x0080 */
  101         uint64_t                save_r0;
  102         uint64_t                save_r1;
  103         uint64_t                save_r2;
  104         uint64_t                save_r3;
  105                                                 /* offset 0x0A0 */
  106         uint64_t                save_r4;
  107         uint64_t                save_r5;
  108         uint64_t                save_r6;
  109         uint64_t                save_r7;
  110                                                 /* offset 0x0C0 */
  111         uint64_t                save_r8;
  112         uint64_t                save_r9;
  113         uint64_t                save_r10;
  114         uint64_t                save_r11;
  115                                                 /* offset 0x0E0 */
  116         uint64_t                save_r12;
  117         uint64_t                save_r13;
  118         uint64_t                save_r14;
  119         uint64_t                save_r15;
  120                                                 /* offset 0x100 */
  121         uint64_t                save_r16;
  122         uint64_t                save_r17;
  123         uint64_t                save_r18;
  124         uint64_t                save_r19;
  125                                                 /* offset 0x120 */
  126         uint64_t                save_r20;
  127         uint64_t                save_r21;
  128         uint64_t                save_r22;
  129         uint64_t                save_r23;
  130                                                 /* offset 0x140 */
  131         uint64_t                save_r24;
  132         uint64_t                save_r25;
  133         uint64_t                save_r26;       
  134         uint64_t                save_r27;
  135                                                 /* offset 0x160 */
  136         uint64_t                save_r28;
  137         uint64_t                save_r29;
  138         uint64_t                save_r30;
  139         uint64_t                save_r31;
  140                                                 /* offset 0x180 */
  141         uint64_t                save_srr0;
  142         uint64_t                save_srr1;
  143         uint64_t                save_xer;
  144         uint64_t                save_lr;
  145                                                 /* offset 0x1A0 */
  146         uint64_t                save_ctr;
  147         uint64_t                save_dar;
  148         unsigned int    save_cr;
  149         unsigned int    save_dsisr;
  150         unsigned int    save_exception; 
  151         unsigned int    save_vrsave;
  152                                                 /* offset 0x1C0 */
  153         unsigned int    save_vscr[4];
  154         unsigned int    save_fpscrpad;
  155         unsigned int    save_fpscr;
  156     unsigned int        save_1d8[2];
  157                                                 /* offset 0x1E0 */
  158         unsigned int    save_1E0[8];
  159                                                 /* offset 0x200 - keep on 128 byte bndry */
  160     uint32_t        save_pmc[8]; 
  161     uint64_t        save_mmcr0;                                 /* offset 0x220 */
  162     uint64_t        save_mmcr1;
  163     uint64_t        save_mmcr2;
  164 
  165         unsigned int    save_238[2];
  166                                                                                                 /* offset 0x240 */
  167         unsigned int    save_instr[16];                         /* Instrumentation */
  168                                                                                                 /* offset 0x280 */
  169 } savearea;
  170 #pragma pack()
  171 
  172 
  173 /*
  174  *      This type of savearea contains all of the floating point context.
  175  */
  176  
  177 #pragma pack(4)                                                 /* Make sure the structure stays as we defined it */
  178 typedef struct savearea_fpu {
  179 
  180         savearea_comm   save_hdr;                                       /* Stuff common to all saveareas */
  181 
  182         unsigned int    save_060[8];                            /* Fill 32 bytes */
  183                                                                                                 /* offset 0x0080 */
  184         double                  save_fp0;
  185         double                  save_fp1;
  186         double                  save_fp2;
  187         double                  save_fp3;
  188 
  189         double                  save_fp4;
  190         double                  save_fp5;
  191         double                  save_fp6;
  192         double                  save_fp7;
  193 
  194         double                  save_fp8;
  195         double                  save_fp9;
  196         double                  save_fp10;
  197         double                  save_fp11;
  198         
  199         double                  save_fp12;
  200         double                  save_fp13;
  201         double                  save_fp14;
  202         double                  save_fp15;
  203         
  204         double                  save_fp16;
  205         double                  save_fp17;
  206         double                  save_fp18;
  207         double                  save_fp19;
  208 
  209         double                  save_fp20;
  210         double                  save_fp21;
  211         double                  save_fp22;
  212         double                  save_fp23;
  213         
  214         double                  save_fp24;
  215         double                  save_fp25;
  216         double                  save_fp26;
  217         double                  save_fp27;
  218         
  219         double                  save_fp28;
  220         double                  save_fp29;
  221         double                  save_fp30;
  222         double                  save_fp31;
  223                                                                                                 /* offset 0x180 */
  224         unsigned int    save_180[8];
  225         unsigned int    save_1A0[8];
  226         unsigned int    save_1C0[8];
  227         unsigned int    save_1E0[8];
  228         unsigned int    save_200[8];
  229         unsigned int    save_220[8];
  230         unsigned int    save_240[8];
  231         unsigned int    save_260[8];
  232 
  233                                                                                                 /* offset 0x280 */
  234 } savearea_fpu;
  235 #pragma pack()
  236 
  237         
  238 
  239 /*
  240  *      This type of savearea contains all of the vector context.
  241  */
  242  
  243 #pragma pack(4)                                                 /* Make sure the structure stays as we defined it */
  244 typedef struct savearea_vec {
  245 
  246         savearea_comm   save_hdr;                                       /* Stuff common to all saveareas */
  247 
  248         unsigned int    save_060[7];                            /* Fill 32 bytes */
  249         unsigned int    save_vrvalid;                           /* Valid registers in saved context */
  250 
  251                                                                                                 /* offset 0x0080 */
  252         unsigned int    save_vr0[4];
  253         unsigned int    save_vr1[4];
  254         unsigned int    save_vr2[4];
  255         unsigned int    save_vr3[4];
  256         unsigned int    save_vr4[4];
  257         unsigned int    save_vr5[4];
  258         unsigned int    save_vr6[4];
  259         unsigned int    save_vr7[4];
  260         unsigned int    save_vr8[4];
  261         unsigned int    save_vr9[4];
  262         unsigned int    save_vr10[4];
  263         unsigned int    save_vr11[4];
  264         unsigned int    save_vr12[4];
  265         unsigned int    save_vr13[4];
  266         unsigned int    save_vr14[4];
  267         unsigned int    save_vr15[4];
  268         unsigned int    save_vr16[4];
  269         unsigned int    save_vr17[4];
  270         unsigned int    save_vr18[4];
  271         unsigned int    save_vr19[4];
  272         unsigned int    save_vr20[4];
  273         unsigned int    save_vr21[4];
  274         unsigned int    save_vr22[4];
  275         unsigned int    save_vr23[4];
  276         unsigned int    save_vr24[4];
  277         unsigned int    save_vr25[4];
  278         unsigned int    save_vr26[4];
  279         unsigned int    save_vr27[4];
  280         unsigned int    save_vr28[4];
  281         unsigned int    save_vr29[4];
  282         unsigned int    save_vr30[4];
  283         unsigned int    save_vr31[4];
  284 
  285                                                                                                 /* offset 0x280 */
  286 } savearea_vec;
  287 #pragma pack()
  288 #endif /* MACH_KERNEL_PRIVATE || BSD_KERNEL_PRIVATE */
  289 
  290 #ifdef  MACH_KERNEL_PRIVATE
  291 
  292 #pragma pack(4)                                                 /* Make sure the structure stays as we defined it */
  293 struct Saveanchor {
  294 
  295 /*      
  296  *      Note that this force aligned in aligned_data.s and must be in V=R storage.
  297  *      Also, all addresses in chains are physical.  This structure can only be 
  298  *      updated with translation and interrupts disabled. This is because it is 
  299  *      locked during exception processing and if we were to take a PTE miss while the
  300  *      lock were held, well, that would be very bad now wouldn't it? 
  301  *  Note that the first 24 bytes must be the same format as a savearea header.
  302  */
  303 
  304         unsigned int                    savelock;               /* 000 Lock word for savearea free list manipulation */
  305     int                                         saveRSVD4;              /* 004 reserved */
  306         addr64_t                                savepoolfwd;    /* 008 Forward anchor for the free pool */
  307         addr64_t                                savepoolbwd;    /* 010 Backward anchor for the free pool */
  308         volatile addr64_t               savefree;               /* 018 Anchor for the global free list */
  309         volatile unsigned int   savefreecnt;    /* 020 Number of saveareas on global free list */
  310         volatile int                    saveadjust;             /* 024 If 0 number of saveareas is ok, otherwise # to change (pos means grow, neg means shrink */
  311         volatile int                    saveinuse;              /* 028 Number of areas in use counting those on the local free list */
  312         volatile int                    savetarget;             /* 02C Number of savearea's needed */
  313         int                                             savemaxcount;   /* 030 Maximum saveareas ever allocated */
  314         unsigned int                    saveRSVD034[3]; /* 034 reserved */
  315 /*                                                                                         040 */
  316 
  317 };
  318 #pragma pack()
  319 
  320 
  321 #define sac_cnt         (4096 / sizeof(savearea))       /* Number of saveareas per page */
  322 #define sac_empty       (0xFFFFFFFF << (32 - sac_cnt))  /* Mask with all entries empty */
  323 #define sac_perm        0x40000000                              /* Page permanently assigned */
  324 #define sac_permb       1                                               /* Page permanently assigned - bit position */
  325 
  326 #define LocalSaveTarget (((8 + sac_cnt - 1) / sac_cnt) * sac_cnt)       /* Target for size of local savearea free list */
  327 #define LocalSaveMin    (LocalSaveTarget / 2)   /* Min size of local savearea free list before we grow */
  328 #define LocalSaveMax    (LocalSaveTarget * 2)   /* Max size of local savearea free list before we trim */
  329 
  330 #define FreeListMin             (2 * LocalSaveTarget * NCPUS)   /* Always make sure there are enough to fill local list twice per processor */
  331 #define SaveLowHysteresis       LocalSaveTarget /* The number off from target before we adjust upwards */
  332 #define SaveHighHysteresis      FreeListMin             /* The number off from target before we adjust downwards */
  333 #define InitialSaveAreas        (2 * FreeListMin)       /* The number of saveareas to make at boot time */
  334 #define InitialSaveTarget       FreeListMin             /* The number of saveareas for an initial target. This should be the minimum ever needed. */
  335 #define InitialSaveBloks        (InitialSaveAreas + sac_cnt - 1) / sac_cnt      /* The number of savearea blocks to allocate at boot */
  336 #define BackPocketSaveBloks     8                               /* Number of pages of back pocket saveareas */
  337 
  338 void                    save_queue(ppnum_t);            /* Add a new savearea block to the free list */
  339 addr64_t                save_get_init(void);            /* special savearea-get for cpu initialization (returns physical address) */
  340 struct savearea *save_get(void);                        /* Obtains a savearea from the free list (returns virtual address) */
  341 reg64_t                 save_get_phys_32(void);         /* Obtains a savearea from the free list (returns phys addr in r3) */
  342 reg64_t                 save_get_phys_64(void);         /* Obtains a savearea from the free list (returns phys addr in r3) */
  343 struct savearea *save_alloc(void);                      /* Obtains a savearea and allocates blocks if needed */
  344 struct savearea *save_cpv(addr64_t);            /* Converts a physical savearea address to virtual */
  345 void                    save_ret(struct savearea *);    /* Returns a savearea to the free list by virtual address */
  346 void                    save_ret_wMSR(struct savearea *, reg64_t);      /* returns a savearea and restores an MSR */
  347 void                    save_ret_phys(reg64_t);         /* Returns a savearea to the free list by physical address */
  348 void                    save_adjust(void);                      /* Adjust size of the global free list */
  349 struct savearea_comm    *save_trim_free(void);  /* Remove free pages from savearea pool */
  350 int                             save_recover(void);                     /* returns nonzero if we can recover enough from the free pool */
  351 void                    savearea_init(vm_offset_t addr);        /* Boot-time savearea initialization */
  352 
  353 
  354 #endif /* MACH_KERNEL_PRIVATE */
  355 #endif /* __APPLE_API_PRIVATE */
  356 
  357 #endif /* ndef ASSEMBLER */
  358 
  359 #define SAVattach       0x80000000                              /* Savearea has valid context */
  360 #define SAVrststk       0x00010000                              /* Indicates that the current stack should be reset to empty */
  361 #define SAVsyscall      0x00020000                              /* Indicates that the savearea is associated with a syscall */
  362 #define SAVredrive      0x00040000                              /* Indicates that the low-level fault handler associated */
  363 #define SAVredriveb     13                                              /* Indicates that the low-level fault handler associated */
  364 #define SAVinstrument 0x00080000                        /* Indicates that we should return instrumentation data */
  365 #define SAVinstrumentb 12                                       /* Indicates that we should return instrumentation data */
  366 #define SAVtype         0x0000FF00                              /* Shows type of savearea */
  367 #define SAVtypeshft     8                                               /* Shift to position type */
  368 #define SAVempty        0x86                                    /* Savearea is on free list */
  369 #define SAVgeneral      0x01                                    /* Savearea contains general context */
  370 #define SAVfloat        0x02                                    /* Savearea contains floating point context */
  371 #define SAVvector       0x03                                    /* Savearea contains vector context */
  372 
  373 
  374 
  375 #endif /* _PPC_SAVEAREA_H_ */

Cache object: bcfc917c79cec6b60a588332e5fdff56


[ 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.