Annotation of driverkit/libDriver/ppc/IOPEFInternals.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: /*
                     25:  * Copyright (c) 1997 Apple Computer, Inc.
                     26:  *
                     27:  *
                     28:  * HISTORY
                     29:  *
                     30:  * Simon Douglas  22 Oct 97
                     31:  * - first checked in.
                     32:  */
                     33: 
                     34: 
                     35: /*
                     36:     File:       zPEF.h
                     37: 
                     38:     Contains:   PEF format declarations.
                     39: 
                     40:     Version:    Maxwell
                     41: 
                     42:     Copyright:  � 1992-1996 by Apple Computer, Inc., all rights reserved.
                     43: 
                     44:     File Ownership:
                     45: 
                     46:         DRI:                Alan Lillich
                     47: 
                     48:         Other Contact:      <<unknown>>
                     49: 
                     50:         Technology:         Core Runtime
                     51: 
                     52:     Writers:
                     53: 
                     54:         (AWL)   Alan Lillich
                     55:         (ELE)   Erik Eidt
                     56: 
                     57:      Change History (most recent first):
                     58: 
                     59:          <7>     2/28/96    AWL     Adapt for new container handler model.
                     60:          <6>     4/12/95    AWL     Fix bit field problem.
                     61:          <5>     8/29/94    AWL     Remove "never" share mode.
                     62:          <4>     8/23/94    AWL     Update section sharing constants.
                     63:          <3>     4/28/94    AWL     Simplify cross address space use for booting.
                     64:          <2>     4/11/94    AWL     Use 68K alignment for the export symbol structure.
                     65:          <1>     2/15/94    AWL     Initial checkin for kernel based CFM.
                     66: 
                     67:          -------------------------------------------------------------------------------------
                     68: 
                     69:             <7>   8/26/93    AWL        Move CFTypes.h and CFLoader.h up with other Apple private headers.
                     70:             <5>     7/8/93   AWL        (&ELE) Fixed version field names in import file IDs
                     71:             <4>     6/9/93   JRG        ELE & AWL Changes:
                     72:             <4>  06/08/93    AWL        (&ELE) Added more standard section types and packed data opcodes.
                     73:             <3>   9/23/92    ELE        added precomputed hash table for improved runtime performance.
                     74: 
                     75:      Version 1.3 Erik Eidt 9/23/92  updated for new hash table capabilities
                     76:      Version 1.2 Erik Eidt 7/8/92   updated for new relocations and other loader section size optimizations
                     77:      Version 1.1 Cheryl Lins 5/27/92 updated for PEF 1.2 definition
                     78:      Version 1.0 Cheryl Lins 4/7/92 initial version
                     79: */
                     80: 
                     81: 
                     82: #ifndef __IOPEFINTERNALS__
                     83: #define __IOPEFINTERNALS__ 1
                     84: 
                     85: #include  <driverkit/ppc/IOMacOSTypes.h>
                     86: #include "IOPEFLoader.h"
                     87: 
                     88: 
                     89: typedef signed int      PEF_SBits32;    // ! Can't use SInt32, it is "signed long".
                     90: typedef unsigned int    PEF_UBits32;    // ! Can't use UInt32, it is "unsigned long".
                     91: 
                     92: 
                     93: #pragma options align=mac68k
                     94: 
                     95: /*========== File Header ==========*/
                     96: 
                     97: typedef struct {
                     98:      UInt16 magic1;                 /* magic flag describing execution machine and environment */
                     99:      UInt16 magic2;                 /* magic flag describing execution machine and environment */
                    100:      OSType  fileTypeID;            /* OSType identifier = 'pef' */
                    101:      OSType  architectureID;        /* OSType identifier = 'pwpc' */
                    102:      UInt32  versionNumber;     /* version number of this file format */
                    103:      UInt32  dateTimeStamp;     /* Macintosh date/time stamp */
                    104:      UInt32  oldDefVersion;     /* old definition version number */
                    105:      UInt32  oldImpVersion;     /* old implementation version number */
                    106:      UInt32  currentVersion;        /* current version number */
                    107:      SInt16  numberSections;        /* number of sections */
                    108:      SInt16  loadableSections;  /* number of sections that are loadable for execution,
                    109:                                                     also the section # of first non-loadable section */
                    110:      BytePtr    memoryAddress;      /* the location this container was last loaded */
                    111: } FileHeader, *FileHeaderPtr;
                    112: 
                    113: #define kPEFVersion 1               /* current version number */
                    114: #define kPEFMagic1  0x4A6F          /* value of magic1 for PEF */
                    115: #define kPEFMagic2  0x7921          /* value of magic2 for PEF */
                    116: #define kPEFTypeID  0x70656666      /* value of fileTypeID for 'peff' */
                    117: #define kPowerPCID  0x70777063      /* value of architecture ID 'pwpc' */
                    118: 
                    119: /*========== Section Header ==========*/
                    120: 
                    121: typedef struct {
                    122:      ByteCount        sectionName;  /* offset into global string table for section name */
                    123:      BytePtr          sectionAddress; /* preferred base address for the section */
                    124:      ByteCount        execSize;         /* section size in bytes during execution in memory including zero initialization */
                    125:      ByteCount        initSize;         /* section size in bytes during execution in memory before zero initialization */
                    126:      ByteCount        rawSize;          /* section size in bytes in container before loading */
                    127:      ByteCount        containerOffset;/* container offest to section's raw data */
                    128:      UInt8  regionKind;     /* section/region classification */
                    129:      UInt8   shareKind;     /* sharing classification */
                    130:      UInt8    alignment;        /* execution alignment requirement (0=byte,1=half,2=word,3=doubleword,4=quadword..) */
                    131:      UInt8    reservedA;
                    132: } SectionHeader, *SectionHeaderPtr;
                    133: 
                    134: /* TCFLSectionKind */
                    135: #define kPEFCodeSection 0
                    136: #define kPEFDataSection 1
                    137: #define kPEFPIDataSection 2
                    138: #define kPEFConstantSection 3
                    139: #define kPEFLoaderSection 4
                    140: #define kPEFDebugSection 5
                    141: #define kPEFExecDataSection 6
                    142: #define kPEFExceptionSection 7
                    143: #define kPEFTracebackSection 8
                    144: 
                    145: /* TCFLShareKind */
                    146: #define kPEFContextShare 1
                    147: #define kPEFGlobalShare 4
                    148: #define kPEFProtectedShare 5
                    149: 
                    150: /* Defines for PIDataSections */
                    151: #define kPEFZero 0
                    152: #define kPEFBlock 1
                    153: #define kPEFRepeat 2
                    154: #define kPEFRepeatBlock 3
                    155: #define kPEFRepeatZero  4
                    156: #define kPEFNoOpcode 0x0fff
                    157: #define kPEFOpcodeShift 5
                    158: #define kPEFFirstOperandMask 31
                    159: 
                    160: 
                    161: /*========== Loader Header ==========*/
                    162: 
                    163: typedef struct {
                    164:      SInt32      entryPointSection;      /* section number containing entry point descriptor */
                    165:      ByteCount   entryPointOffset;       /* offset to entry point descriptor within section */
                    166: 
                    167:      SInt32      initPointSection;       /* section number containing entry point descriptor */
                    168:      ByteCount   initPointOffset;        /* offset to entry point descriptor within section */
                    169: 
                    170:      SInt32      termPointSection;       /* section number containing entry point descriptor */
                    171:      ByteCount   termPointOffset;        /* offset to entry point descriptor within section */
                    172: 
                    173:      ItemCount       numImportFiles;             /* number of import file id entries */
                    174:      ItemCount       numImportSyms;          /* number of import symbol table entries */
                    175:      ItemCount       numSections;                /* number of sections with load-time relocations */
                    176:      ByteCount   relocationsOffset;      /* offset to relocation descriptions table */
                    177: 
                    178:      ByteCount   stringsOffset;          /* offset to loader string table */
                    179: 
                    180:      ByteCount   hashSlotTable;          /* offset to hash slot table */
                    181:      ItemCount       hashSlotTabSize;        /* number of hash slot entries */
                    182:      ItemCount       numExportSyms;          /* number of export symbol table entries */
                    183: } LoaderHeader, *LoaderHeaderPtr;
                    184: 
                    185: /*========== Loader Section Header ==========*/
                    186: 
                    187: typedef struct {
                    188:      SInt16  sectionNumber;          /* reference to primary section number */
                    189:      SInt16  reservedA;                  /* if TSectNum were 16 bits, which it isn't */
                    190:      ItemCount       numRelocations;             /* number of loader relocations for this section */
                    191:      ByteCount   relocationsOffset;      /* offset to relocation descriptions for this section */
                    192: } LoaderRelExpHeader, *LoaderRelExpHeaderPtr;
                    193: 
                    194: /*========== Loader Import File ID's Entry ==========*/
                    195: 
                    196: typedef struct {
                    197:      ByteCount    fileNameOffset;         /* offset into loader string table for file name */
                    198:      UInt32       oldImpVersion;              /* oldest compatible implementation library */
                    199:      UInt32       linkedVersion;              /* current version at link time */
                    200:      ItemCount            numImports;                 /* number of imports from this file */
                    201:      ItemCount            impFirst;                   /* number of the first imports from this file (relative to all imports) */
                    202:      UInt8    options;                /* call this libraries initialization routine before mine */
                    203:      UInt8    reservedA;
                    204:      UInt16   reservedB;
                    205: } LoaderImportFileID, *LoaderImportFileIDPtr;
                    206: 
                    207: #define kPEFInitBeforeMask      0x80
                    208: #define kPEFWeakLibraryMask     0x40
                    209: #define kPEFDeferredBindMask    0x20
                    210: 
                    211: /*========== Loader Import Symbol Table Entry ==========*/
                    212: 
                    213: typedef struct {
                    214:      PEF_UBits32    symClass    :  8;   // Actually ot type TCFLSymbolClass.
                    215:      PEF_UBits32    nameOffset  : 24;
                    216: } LoaderImport, *LoaderImportPtr;
                    217: 
                    218: #define kPEFWeakSymbolMask  0x80
                    219: 
                    220: /*========== Loader Export Hash Slot Table Entry ==========*/
                    221: 
                    222: typedef struct {
                    223:     PEF_UBits32 chainCount : 14;
                    224:     PEF_UBits32 chainIndex : 18;
                    225: } HashSlotEntry, *HashSlotEntryPtr;
                    226: 
                    227: #define PEFHashHighBits(hashword,bitCount)  ((hashword) >> (bitCount))
                    228: #define PEFHashMaskBits(hashword,bitCount)  (((UInt32)(1) << (bitCount)) - 1)
                    229: 
                    230: #define GetPEFHashSlot(hashword,bitCount)   \
                    231:     ( (ItemCount) (((hashword) ^ PEFHashHighBits((hashword),(bitCount))) & PEFHashMaskBits((hashword),(bitCount))) )
                    232: 
                    233: /*========== Loader Export Hash Chain Table Entry ==========*/
                    234: 
                    235: typedef struct {
                    236:      UInt32  hashword;                        /* (hashword >> 16) == nameLength !! */
                    237: } HashChainEntry, *HashChainEntryPtr;
                    238: 
                    239: /*========== Loader Export Symbol Table Entry ==========*/
                    240: 
                    241: /*  Section number controls how 'address' is interpreted.
                    242:      >=0: section number exporting the symbol; 'address' is offset from start of the section to
                    243:             the symbol being exported (ie address of a routine or data item)
                    244:      -1:    value is absolute (non-relocatable)
                    245:      -2:    value is a physical address (non-relocatable)
                    246:      -3:    re-export imported symbol whose number is in 'address'
                    247: */
                    248: 
                    249: /* this struct is stored in the file, non-aligned: size = 10 */
                    250: typedef struct {
                    251:      PEF_UBits32    symClass    :  8;   // Actually ot type TCFLSymbolClass.
                    252:      PEF_UBits32    nameOffset  : 24;
                    253:      ByteCount      offset;                                       /* offset into section to exported symbol */
                    254:      SInt16         sectionNumber;
                    255: } LoaderExport, *LoaderExportPtr;
                    256: 
                    257: #define SIZEOF_LoaderExport (sizeof (TUnsigned32)*2 + sizeof (SInt16))
                    258: 
                    259: 
                    260: #define kPEFAbsoluteExport -1
                    261: #define kPEFPhysicalExport -2
                    262: #define kPEFReExportImport -3
                    263: 
                    264: /*========== Loader Relocation Entry ==========*/
                    265: 
                    266: typedef UInt16 RelocInstr;
                    267: 
                    268: typedef union {
                    269:     struct { unsigned op:7, rest:9;                  } opcode;
                    270:     struct { unsigned op:2, delta_d4:8, cnt:6;   } deltadata;
                    271:     struct { unsigned op:7, cnt_m1:9;                } run;
                    272:     struct { unsigned op:7, idx:9;                   } glp;
                    273:     struct { unsigned op:4, delta_m1:12;             } delta;
                    274:     struct { unsigned op:4, icnt_m1:4, rcnt_m1:8; } rpt;
                    275:     struct { unsigned op:6, idx_top:10;              } large1;
                    276:     struct { unsigned op:6, cnt_m1:4, idx_top:6;  } large2;
                    277:     UInt16 instr;
                    278:     UInt16 bot;
                    279: } Relocation;
                    280: 
                    281: // opcode definitions which can be used with
                    282: // Relocation.opcode.op:7, if masked properly
                    283: // by the up coming table
                    284: // (NOTE: a half word of 0 is garunteed to be an unused relocation instruction)
                    285: 
                    286: #define krDDAT 0x00 // type deltadata
                    287: 
                    288: #define krCODE 0x20 // type run
                    289: #define krDATA 0x21 // type run
                    290: #define krDESC 0x22 // type run
                    291: #define krDSC2 0x23 // type run
                    292: #define krVTBL 0x24 // type run
                    293: #define krSYMR 0x25 // type run
                    294: //              0x26
                    295: //              0x2F
                    296: 
                    297: #define krSYMB 0x30 // type glp
                    298: #define krCDIS 0x31 // type glp
                    299: #define krDTIS 0x32 // type glp
                    300: #define krSECN 0x33 // type glp
                    301: //              0x34
                    302: //              0x3F
                    303: 
                    304: #define krDELT 0x40 // type delta
                    305: #define krRPT   0x48 // type rpt
                    306: 
                    307: #define krLABS 0x50 // type large1
                    308: #define krLSYM 0x52 // type large1
                    309: //              0x54
                    310: //              0x56
                    311: 
                    312: #define krLRPT 0x58 // type large2
                    313: #define krLSEC 0x5A // type large2
                    314: //              0x5C
                    315: //              0x5E
                    316: 
                    317:             // LSEC usage:
                    318:             // LSEC 0, n         -- Long SECN
                    319:             // LSEC 1, n         -- Long CDIS
                    320:             // LSEC 2, n         -- Long DTIS
                    321:             // LSEC 3, n         -- free
                    322:             // LSEC 15, n        -- free
                    323: 
                    324: // constants that indicate the maximum sizes of fields
                    325: // (before packing, ie: subtracting one, in some cases)
                    326: 
                    327: #define ksDELTA 4096        // delta max for DELTA from
                    328: 
                    329: #define ksDDDMAX 1023       // delta max for DELTA-DAT (DDAT) form
                    330: #define ksDDRMAX 63         // run max for DELTA-DAT (DDAT) form
                    331: 
                    332: #define ksCODE   512        // count max for CODE form
                    333: #define ksDATA   512        // count max for DATA form
                    334: #define ksDEMAX  512        // count max for DESC form
                    335: #define ksVTMAX  512        // count max for VTBL form
                    336: #define ksISMAX  512        // count max for IMPS form
                    337: #define ksRPTMAX 256        // count max for RPT form
                    338: 
                    339: #define IsLARG(op) (((op) & 0x70) == 0x50)
                    340: 
                    341: #define RELOPSHFT 9
                    342: 
                    343: #define ksDVDMAX 0          // (63) delta max for DELTA-VTBL (DVBL) form
                    344: #define ksDVRMAX 0          // (256)  run max for DELTA-VTBL (DVBL) form
                    345: 
                    346: #define krXXXX 0xff
                    347: 
                    348: 
                    349: /*
                    350:                 From:               PEFBinaryFormat.i
                    351:                     Revision:       9
                    352: */
                    353: 
                    354: enum {
                    355:                                                                 /* The packed data opcodes. */
                    356:     kPEFPkDataZero              = 0,                            /* Zero fill "count" bytes. */
                    357:     kPEFPkDataBlock             = 1,                            /* Block copy "count" bytes. */
                    358:     kPEFPkDataRepeat            = 2,                            /* Repeat "count" bytes "count2"+1 times. */
                    359:     kPEFPkDataRepeatBlock       = 3,                            /* Interleaved repeated and unique data. */
                    360:     kPEFPkDataRepeatZero        = 4                             /* Interleaved zero and unique data. */
                    361: };
                    362: 
                    363: 
                    364: enum {
                    365:     kPEFPkDataOpcodeShift       = 5,
                    366:     kPEFPkDataCount5Mask        = 0x1F,
                    367:     kPEFPkDataMaxCount5         = 31,
                    368:     kPEFPkDataVCountShift       = 7,
                    369:     kPEFPkDataVCountMask        = 0x7F,
                    370:     kPEFPkDataVCountEndMask     = 0x80
                    371: };
                    372: 
                    373: #define PEFPkDataOpcode(byte) ( ((UInt8)(byte)) >> kPEFPkDataOpcodeShift )
                    374: 
                    375: #define PEFPkDataCount5(byte) ( ((UInt8)(byte)) & kPEFPkDataCount5Mask )
                    376: 
                    377: #define PEFPkDataComposeInstr(opcode,count5)        \
                    378:             ( (((UInt8)(opcode)) << kPEFPkDataOpcodeShift) | ((UInt8)(count5)) )
                    379: 
                    380: 
                    381: 
                    382: 
                    383: 
                    384: /*
                    385:     File:       CodeFragmentContainerPriv.h
                    386:  
                    387:     Contains:   Physical container routines of the ModernOS version of CFM.
                    388:  
                    389:     Version:    Maxwell
                    390:  
                    391:     DRI:        Alan Lillich
                    392:  
                    393:     Copyright:  � 1984-1996 by Apple Computer, Inc.
                    394:                 All rights reserved.
                    395:  
                    396:     Warning:    *** APPLE INTERNAL USE ONLY ***
                    397:                 This file contains unreleased SPI's
                    398:  
                    399:     BuildInfo:  Built by:           Simon Douglas
                    400:                 With Interfacer:    2.0d13   (PowerPC native)
                    401:                 From:               CodeFragmentContainerPriv.i
                    402:                     Revision:       9
                    403:                     Dated:          10/9/96
                    404:                     Last change by: AWL
                    405:                     Last comment:   Remove special SMP sharing, using prepare option instead.
                    406:  
                    407:     Bugs:       Report bugs to Radar component �System Interfaces�, �Latest�
                    408:                 List the version information (from above) in the Problem Description.
                    409:  
                    410: */
                    411: /*
                    412:  -------------------------------------------------------------------------------------------
                    413:  This file contains what used to be called the CFLoader interface.  The name was changed to
                    414:  fit the newer convention of having CodeFragment as a common prefix, and to reduce pervasive
                    415:  confusion between the Code Fragment Manager and the Code Fragment Loaders, promulgated by
                    416:  the long history of the Segment Loader.  This file defines the abstract interface to the
                    417:  physical representation of code fragments.
                    418:  !!! This version has minimal comments, the main purpose is to get things compiled.
                    419: */
                    420: 
                    421: 
                    422: /*
                    423:  �
                    424:  ===========================================================================================
                    425:  General Types and Constants
                    426:  ===========================
                    427: */
                    428: typedef SInt32 CFContSignedIndex;
                    429: typedef UInt32 CFContStringHash;
                    430: #define CFContStringHashLength(hashValue)   ((hashValue) >> 16)
                    431: struct CFContHashedName {
                    432:     CFContStringHash                nameHash;                   /* ! Includes the name length.*/
                    433:     BytePtr                         nameText;
                    434: };
                    435: typedef struct CFContHashedName CFContHashedName;
                    436: 
                    437: /*
                    438:  ------------------------------------------
                    439:  Declarations for code fragment containers.
                    440: */
                    441: 
                    442: enum {
                    443:     kCFContContainerInfoVersion = 0x00010001
                    444: };
                    445: 
                    446: struct CFContContainerInfo {
                    447:     CFContHashedName                cfragName;
                    448:     UInt32                          modDate;                    /* !!! Abstract type?*/
                    449:     OSType                          architecture;
                    450:     CFragVersionNumber              currentVersion;
                    451:     CFragVersionNumber              oldImpVersion;
                    452:     CFragVersionNumber              oldDefVersion;
                    453:     UInt32                          reservedA;
                    454:     void *                          reservedB;
                    455: };
                    456: typedef struct CFContContainerInfo CFContContainerInfo;
                    457: 
                    458: /*
                    459:  ----------------------------------------
                    460:  Declarations for code fragment sections.
                    461: */
                    462: struct CFContLogicalLocation {
                    463:     CFContSignedIndex               section;                    /* "Real" sections use zero based indices, special ones are negative.*/
                    464:     ByteCount                       offset;
                    465: };
                    466: typedef struct CFContLogicalLocation CFContLogicalLocation;
                    467: 
                    468: 
                    469: enum {
                    470:     kCFContNoSectionIndex       = -1,
                    471:     kCFContAbsoluteSectionIndex = -2,
                    472:     kCFContReexportSectionIndex = -3
                    473: };
                    474: 
                    475: typedef UInt8 CFContSectionSharing;
                    476: 
                    477: enum {
                    478:     kCFContShareSectionInClosure = 0,                           /* ! Not supported at present!*/
                    479:     kCFContShareSectionInProcess = 1,
                    480:     kCFContShareSectionAcrossSystem = 4,
                    481:     kCFContShareSectionWithProtection = 5
                    482: };
                    483: 
                    484: typedef UInt8 CFContMemoryAccess;
                    485: 
                    486: enum {
                    487:     kCFContMemReadMask          = 0x01,                         /* Readable memory can also be executed.*/
                    488:     kCFContMemWriteMask         = 0x02,
                    489:     kCFContMemExecuteMask       = 0x04,                         /* ! Affects cache actions, not protection!*/
                    490:     kCFContReadOnlyData         = kCFContMemReadMask,
                    491:     kCFContWriteableData        = kCFContMemReadMask | kCFContMemWriteMask,
                    492:     kCFContNormalCode           = kCFContMemReadMask | kCFContMemExecuteMask,
                    493:     kCFContExcludedMemory       = 0
                    494: };
                    495: 
                    496: typedef UInt32 CFContSectionOptions;
                    497: 
                    498: enum {
                    499:                                                                 /* Values for CFContSectionOptions.*/
                    500:     kPackedCFContSectionMask    = 0x01,                         /* Stored contents are compressed.*/
                    501:     kRelocatedCFContSectionMask = 0x02,                         /* Section contents have relocations.*/
                    502:     kEmptyFillCFContSectionMask = 0x04,                         /* The extension part may be left untouched.*/
                    503:     kResidentCFContSectionMask  = 0x08,
                    504:     kPrefaultCFContSectionMask  = 0x10
                    505: };
                    506: 
                    507: 
                    508: enum {
                    509:     kCFContSectionInfoVersion   = 0x00010001
                    510: };
                    511: 
                    512: struct CFContSectionInfo {
                    513:     CFContHashedName                sectionName;
                    514:     CFContMemoryAccess              access;
                    515:     CFContSectionSharing            sharing;
                    516:     UInt8                           alignment;                  /* ! The power of 2, a.k.a. number of low order zero bits.*/
                    517:     UInt8                           reservedA;
                    518:     CFContSectionOptions            options;
                    519:     ByteCount                       containerOffset;
                    520:     ByteCount                       containerLength;
                    521:     ByteCount                       unpackedLength;
                    522:     ByteCount                       totalLength;
                    523:     LogicalAddress                  defaultAddress;
                    524:     UInt32                          reservedB;
                    525:     void *                          reservedC;
                    526: };
                    527: typedef struct CFContSectionInfo CFContSectionInfo;
                    528: 
                    529: /*
                    530:  ----------------------------------
                    531:  Declarations for exported symbols.
                    532: */
                    533: typedef UInt32 CFContExportedSymbolOptions;
                    534: /*
                    535:  ! enum {   // Values for CFContExportedSymbolOptions.
                    536:  !  // ! No options at present.
                    537:  ! };
                    538: */
                    539: 
                    540: enum {
                    541:     kCFContExportedSymbolInfoVersion = 0x00010001
                    542: };
                    543: 
                    544: struct CFContExportedSymbolInfo {
                    545:     CFContHashedName                symbolName;
                    546:     CFContLogicalLocation           location;
                    547:     CFContExportedSymbolOptions     options;
                    548:     CFragSymbolClass                symbolClass;
                    549:     UInt8                           reservedA;
                    550:     UInt16                          reservedB;
                    551:     UInt32                          reservedC;
                    552:     void *                          reservedD;
                    553: };
                    554: typedef struct CFContExportedSymbolInfo CFContExportedSymbolInfo;
                    555: 
                    556: /*
                    557:  ------------------------------------------------
                    558:  Declarations for imported libraries and symbols.
                    559: */
                    560: typedef UInt32 CFContImportedLibraryOptions;
                    561: 
                    562: enum {
                    563:                                                                 /* Values for CFContImportedLibraryOptions.*/
                    564:     kCFContWeakLibraryMask      = 0x01,                         /* ! Same as kCFContWeakSymbolMask to reduce errors.*/
                    565:     kCFContInitBeforeMask       = 0x02,
                    566:     kCFContDeferredBindMask     = 0x04
                    567: };
                    568: 
                    569: 
                    570: enum {
                    571:     kCFContImportedLibraryInfoVersion = 0x00010001
                    572: };
                    573: 
                    574: struct CFContImportedLibraryInfo {
                    575:     CFContHashedName                libraryName;
                    576:     CFragVersionNumber              linkedVersion;
                    577:     CFragVersionNumber              oldImpVersion;
                    578:     CFContImportedLibraryOptions    options;
                    579: };
                    580: typedef struct CFContImportedLibraryInfo CFContImportedLibraryInfo;
                    581: 
                    582: typedef UInt32 CFContImportedSymbolOptions;
                    583: 
                    584: enum {
                    585:                                                                 /* Values for CFContImportedSymbolOptions.*/
                    586:     kCFContWeakSymbolMask       = 0x01                          /* ! Same as kCFContWeakLibraryMask to reduce errors.*/
                    587: };
                    588: 
                    589: 
                    590: enum {
                    591:     kCFContImportedSymbolInfoVersion = 0x00010001
                    592: };
                    593: 
                    594: struct CFContImportedSymbolInfo {
                    595:     CFContHashedName                symbolName;
                    596:     ItemCount                       libraryIndex;
                    597:     CFContImportedSymbolOptions     options;
                    598:     CFragSymbolClass                symbolClass;
                    599:     UInt8                           reservedA;
                    600:     UInt16                          reservedB;
                    601:     UInt32                          reservedC;
                    602:     void *                          reservedD;
                    603: };
                    604: typedef struct CFContImportedSymbolInfo CFContImportedSymbolInfo;
                    605: 
                    606: /*
                    607:  -------------------------------------------------
                    608:  Declarations for dealing with container handlers.
                    609: */
                    610: typedef UInt32 CFContOpenOptions;
                    611: 
                    612: enum {
                    613:                                                                 /* Values for CFContOpenOptions.*/
                    614:     kCFContPrepareInPlaceMask   = 0x01,
                    615:     kCFContMinimalOpenMask      = 0x02
                    616: };
                    617: 
                    618: typedef UInt32 CFContCloseOptions;
                    619: 
                    620: enum {
                    621:                                                                 /* Values for CFContCloseOptions.*/
                    622:     kCFContPartialCloseMask     = 0x01
                    623: };
                    624: 
                    625: typedef struct OpaqueCFContHandlerRef* CFContHandlerRef;
                    626: typedef struct CFContHandlerProcs CFContHandlerProcs;
                    627: typedef CFContHandlerProcs *CFContHandlerProcsPtr;
                    628: typedef LogicalAddress (*CFContAllocateMem)(ByteCount size);
                    629: typedef void (*CFContReleaseMem)(LogicalAddress address);
                    630: /*
                    631:  �
                    632:  ===========================================================================================
                    633:  Container Handler Routines
                    634:  ==========================
                    635: */
                    636: typedef OSStatus (*CFCont_OpenContainer)(LogicalAddress mappedAddress, LogicalAddress runningAddress, ByteCount containerLength, KernelProcessID runningProcessID, const CFContHashedName *cfragName, CFContOpenOptions options, CFContAllocateMem Allocate, CFContReleaseMem Release, CFContHandlerRef *containerRef, CFContHandlerProcsPtr *handlerProcs);
                    637: typedef OSStatus (*CFCont_CloseContainer)(CFContHandlerRef containerRef, CFContCloseOptions options);
                    638: typedef OSStatus (*CFCont_GetContainerInfo)(CFContHandlerRef containerRef, PBVersion infoVersion, CFContContainerInfo *containerInfo);
                    639: /* -------------------------------------------------------------------------------------------*/
                    640: typedef OSStatus (*CFCont_GetSectionCount)(CFContHandlerRef containerRef, ItemCount *sectionCount);
                    641: typedef OSStatus (*CFCont_GetSectionInfo)(CFContHandlerRef containerRef, ItemCount sectionIndex, PBVersion infoVersion, CFContSectionInfo *sectionInfo);
                    642: typedef OSStatus (*CFCont_FindSectionInfo)(CFContHandlerRef containerRef, const CFContHashedName *sectionName, PBVersion infoVersion, ItemCount *sectionIndex, CFContSectionInfo *sectionInfo);
                    643: typedef OSStatus (*CFCont_SetSectionAddress)(CFContHandlerRef containerRef, ItemCount sectionIndex, LogicalAddress mappedAddress, LogicalAddress runningAddress);
                    644: /* -------------------------------------------------------------------------------------------*/
                    645: typedef OSStatus (*CFCont_GetAnonymousSymbolLocations)(CFContHandlerRef containerRef, CFContLogicalLocation *mainLocation, CFContLogicalLocation *initLocation, CFContLogicalLocation *termLocation);
                    646: /* -------------------------------------------------------------------------------------------*/
                    647: typedef OSStatus (*CFCont_GetExportedSymbolCount)(CFContHandlerRef containerRef, ItemCount *exportCount);
                    648: typedef OSStatus (*CFCont_GetExportedSymbolInfo)(CFContHandlerRef containerRef, CFContSignedIndex exportedIndex, PBVersion infoVersion, CFContExportedSymbolInfo *exportInfo);
                    649: typedef OSStatus (*CFCont_FindExportedSymbolInfo)(CFContHandlerRef containerRef, const CFContHashedName *exportName, PBVersion infoVersion, ItemCount *exportIndex, CFContExportedSymbolInfo *exportInfo);
                    650: /* -------------------------------------------------------------------------------------------*/
                    651: typedef OSStatus (*CFCont_GetImportCounts)(CFContHandlerRef containerRef, ItemCount *libraryCount, ItemCount *symbolCount);
                    652: typedef OSStatus (*CFCont_GetImportedLibraryInfo)(CFContHandlerRef containerRef, ItemCount libraryIndex, PBVersion infoVersion, CFContImportedLibraryInfo *libraryInfo);
                    653: typedef OSStatus (*CFCont_GetImportedSymbolInfo)(CFContHandlerRef containerRef, ItemCount symbolIndex, PBVersion infoVersion, CFContImportedSymbolInfo *symbolInfo);
                    654: typedef OSStatus (*CFCont_SetImportedSymbolAddress)(CFContHandlerRef containerRef, ItemCount symbolIndex, LogicalAddress symbolAddress);
                    655: /* -------------------------------------------------------------------------------------------*/
                    656: typedef OSStatus (*CFCont_UnpackSection)(CFContHandlerRef containerRef, ItemCount sectionIndex, ByteCount sectionOffset, LogicalAddress bufferAddress, ByteCount bufferLength);
                    657: typedef OSStatus (*CFCont_RelocateSection)(CFContHandlerRef containerRef, ItemCount sectionIndex);
                    658: typedef OSStatus (*CFCont_RelocateImportsOnly)(CFContHandlerRef containerRef, ItemCount sectionIndex, ItemCount libraryIndex);
                    659: typedef OSStatus (*CFCont_MakeSectionExecutable)(CFContHandlerRef containerRef, ItemCount sectionIndex);
                    660: typedef OSStatus (*CFCont_AllocateSection)(CFContHandlerRef containerRef, ItemCount sectionIndex, LogicalAddress *mappedAddress, LogicalAddress *runningAddress);
                    661: typedef OSStatus (*CFCont_ReleaseSection)(CFContHandlerRef containerRef, ItemCount sectionIndex);
                    662: /* -------------------------------------------------------------------------------------------*/
                    663: 
                    664: #if 0
                    665: struct CFContHandlerInfo {
                    666:     OrderedItemName                 orderedName;
                    667:     OrderRequirements               orderedReq;
                    668:     CFCont_OpenContainer            OpenHandler;
                    669: };
                    670: typedef struct CFContHandlerInfo CFContHandlerInfo;
                    671: #endif
                    672: 
                    673: struct CFContHandlerProcs {
                    674:     ItemCount                       procCount;
                    675:     CFragShortVersionPair           abiVersion;
                    676: 
                    677:     CFCont_OpenContainer            OpenContainer;              /*  1*/
                    678:     CFCont_CloseContainer           CloseContainer;             /*  2*/
                    679:     CFCont_GetContainerInfo         GetContainerInfo;           /*  3*/
                    680: 
                    681:     CFCont_GetSectionCount          GetSectionCount;            /*  4*/
                    682:     CFCont_GetSectionInfo           GetSectionInfo;             /*  5*/
                    683:     CFCont_FindSectionInfo          FindSectionInfo;            /*  6*/
                    684:     CFCont_SetSectionAddress        SetSectionAddress;          /*  7*/
                    685: 
                    686:     CFCont_GetAnonymousSymbolLocations  GetAnonymousSymbolLocations; /*  8*/
                    687: 
                    688:     CFCont_GetExportedSymbolCount   GetExportedSymbolCount;     /*  9*/
                    689:     CFCont_GetExportedSymbolInfo    GetExportedSymbolInfo;      /* 10*/
                    690:     CFCont_FindExportedSymbolInfo   FindExportedSymbolInfo;     /* 11*/
                    691: 
                    692:     CFCont_GetImportCounts          GetImportCounts;            /* 12*/
                    693:     CFCont_GetImportedLibraryInfo   GetImportedLibraryInfo;     /* 13*/
                    694:     CFCont_GetImportedSymbolInfo    GetImportedSymbolInfo;      /* 14*/
                    695:     CFCont_SetImportedSymbolAddress  SetImportedSymbolAddress;  /* 15*/
                    696: 
                    697:     CFCont_UnpackSection            UnpackSection;              /* 16*/
                    698:     CFCont_RelocateSection          RelocateSection;            /* 17*/
                    699:     CFCont_RelocateImportsOnly      RelocateImportsOnly;        /* 18*/
                    700:     CFCont_MakeSectionExecutable    MakeSectionExecutable;      /* 19   (Opt.)*/
                    701:     CFCont_AllocateSection          AllocateSection;            /* 20   (Opt.)*/
                    702:     CFCont_ReleaseSection           ReleaseSection;             /* 21   (Opt.)*/
                    703: };
                    704: 
                    705: 
                    706: enum {
                    707:     kCFContMinimumProcCount     = 18,
                    708:     kCFContCurrentProcCount     = 21,
                    709:     kCFContHandlerABIVersion    = 0x00010001
                    710: };
                    711: 
                    712: /*
                    713:  -----------------------------------------------------------------------------------------
                    714:  The ABI version is a pair of UInt16s used as simple counters.  The high order part is the
                    715:  current version number, the low order part is the oldest compatible definition version.
                    716:  number.  This pair is to be used by the specific container handlers to describe what
                    717:  version of the container handler ABI they support.
                    718:     0x00010001
                    719:     ----------
                    720:     The initial release of this ABI.  (The old CFLoader ABI does not count.)
                    721:  �
                    722:  ===========================================================================================
                    723:  General Routines
                    724:  ================
                    725: */
                    726: extern CFContStringHash CFContHashName(BytePtr nameText, ByteCount nameLength);
                    727: 
                    728: #if 0
                    729: 
                    730: /* -------------------------------------------------------------------------------------------*/
                    731: extern OSStatus CFContOpenContainer(LogicalAddress mappedAddress, LogicalAddress runningAddress, ByteCount containerLength, KernelProcessID runningProcessID, const CFContHashedName *cfragName, CFContOpenOptions options, CFContAllocateMem Allocate, CFContReleaseMem Release, CFContHandlerRef *containerRef, CFContHandlerProcsPtr *handlerProcs);
                    732: 
                    733: /* -------------------------------------------------------------------------------------------*/
                    734: extern OSStatus CFContRegisterContainerHandler(const OrderedItemName *orderedName, const OrderRequirements *orderedReq, CFCont_OpenContainer OpenHandler, OrderedItemName *rejectingHandler);
                    735: 
                    736: extern OSStatus CFContUnregisterContainerHandler(const OrderedItemName *orderedName);
                    737: 
                    738: extern OSStatus CFContGetContainerHandlers(ItemCount requestedCount, ItemCount *totalCount, CFContHandlerInfo *handlers);
                    739: 
                    740: /* -------------------------------------------------------------------------------------------*/
                    741: #endif
                    742: 
                    743: 
                    744: 
                    745: 
                    746: 
                    747: 
                    748: /*
                    749:     File:       PEFLoader.h
                    750: 
                    751:     Contains:   PEF Loader Interface.
                    752: 
                    753:     Version:    Maxwell
                    754: 
                    755:     Copyright:  � 1992-1996 by Apple Computer, Inc., all rights reserved.
                    756: 
                    757:     File Ownership:
                    758: 
                    759:         DRI:                Alan Lillich
                    760: 
                    761:         Other Contact:      <<unknown>>
                    762: 
                    763:         Technology:         Core Runtime
                    764: 
                    765:     Writers:
                    766: 
                    767:         (AWL)   Alan Lillich
                    768:         (ELE)   Erik Eidt
                    769: 
                    770:      Change History (most recent first):
                    771: 
                    772:          <7>     8/23/96    AWL     (1379028) Propagate changes from CodeFragmentContainerPriv.
                    773:          <6>     2/28/96    AWL     Adapt for new container handler model.
                    774:          <5>     6/20/94    AWL     Move private PEF loader info struct here to be visible to the
                    775:                                     booting "wacky" PEF loader.
                    776:          <4>      6/8/94    AWL     Make all CFL routines visible for direct use in special cases
                    777:                                     such as booting.
                    778:          <3>     5/16/94    AWL     Fix typo.
                    779:          <2>     2/25/94    AWL     Update for Q&D solution to loading across address spaces.
                    780:          <1>     2/15/94    AWL     Initial checkin for kernel based CFM.
                    781: */
                    782: 
                    783: // ===========================================================================================
                    784: 
                    785: enum {
                    786:     kBuiltinSectionArraySize    = 4
                    787: };
                    788: 
                    789: struct PEFPrivateInfo { // !!! Clean up field names, collapse Booleans, etc.
                    790:     CFContAllocateMem       Allocate;
                    791:     CFContReleaseMem        Release;
                    792:     BytePtr                 mappedContainer;
                    793:     BytePtr                 runningContainer;
                    794:     ItemCount               sectionCount;       // Just the instantiated sections.
                    795:     SectionHeader *         sections;
                    796:     BytePtr                 stringTable;
                    797:     ItemCount               ldrSectionNo;
                    798:     LoaderHeader *          ldrHeader;
                    799:     BytePtr                 ldrStringTable;
                    800:     LoaderRelExpHeader *    ldrSections;
                    801:     LoaderImportFileID *    ldrImportFiles;
                    802:     LoaderImport *          ldrImportSymbols;
                    803:     HashSlotEntry *         ldrHashSlot;
                    804:     HashChainEntry *        ldrHashChain;
                    805:     LoaderExport *          ldrExportSymbols;
                    806:     BytePtr                 ldrRelocations;
                    807:     BytePtr *               mappedOrigins;      // Mapped base address for each section.
                    808:     ByteCount *             runningOffsets;     // Running offset from presumed address.
                    809:     BytePtr *               imports;
                    810:     BytePtr                 originArray [kBuiltinSectionArraySize]; // ! Only used if big enough.
                    811:     ByteCount               offsetArray [kBuiltinSectionArraySize]; // ! Only used if big enough.
                    812:     Boolean                 loadInPlace;
                    813:     Boolean                 resolved;
                    814: };
                    815: 
                    816: typedef struct PEFPrivateInfo   PEFPrivateInfo;
                    817: 
                    818: 
                    819: // ===========================================================================================
                    820: 
                    821: 
                    822: extern OSStatus PEF_OpenContainer       ( LogicalAddress            mappedAddress,
                    823:                                           LogicalAddress            runningAddress,
                    824:                                           ByteCount                 containerLength,
                    825:                                           KernelProcessID           runningProcessID,
                    826:                                           const CFContHashedName *  cfragName,
                    827:                                           CFContOpenOptions         options,
                    828:                                           CFContAllocateMem         Allocate,
                    829:                                           CFContReleaseMem          Release,
                    830:                                           CFContHandlerRef *        containerRef_o,
                    831:                                           CFContHandlerProcs * *    handlerProcs_o );
                    832: 
                    833: extern OSStatus PEF_CloseContainer      ( CFContHandlerRef          containerRef,
                    834:                                           CFContCloseOptions        options );
                    835: 
                    836: extern OSStatus PEF_GetContainerInfo    ( CFContHandlerRef          containerRef,
                    837:                                           PBVersion                 infoVersion,
                    838:                                           CFContContainerInfo *     containerInfo );
                    839: 
                    840: // -------------------------------------------------------------------------------------------
                    841: 
                    842: extern OSStatus PEF_GetSectionCount     ( CFContHandlerRef          containerRef,
                    843:                                           ItemCount *               sectionCount );
                    844: 
                    845: extern OSStatus PEF_GetSectionInfo      ( CFContHandlerRef          containerRef,
                    846:                                           ItemCount                 sectionIndex,
                    847:                                           PBVersion                 infoVersion,
                    848:                                           CFContSectionInfo *       sectionInfo );
                    849: 
                    850: extern OSStatus PEF_FindSectionInfo     ( CFContHandlerRef          containerRef,
                    851:                                           const CFContHashedName *  sectionName,
                    852:                                           PBVersion                 infoVersion,
                    853:                                           ItemCount *               sectionIndex,   // May be null.
                    854:                                           CFContSectionInfo *       sectionInfo );  // May be null.
                    855: 
                    856: extern OSStatus PEF_SetSectionAddress   ( CFContHandlerRef          containerRef,
                    857:                                           ItemCount                 sectionIndex,
                    858:                                           LogicalAddress            mappedAddress,
                    859:                                           LogicalAddress            runningAddress );
                    860: 
                    861: // -------------------------------------------------------------------------------------------
                    862: 
                    863: extern OSStatus PEF_GetAnonymousSymbolLocations ( CFContHandlerRef          containerRef,
                    864:                                                   CFContLogicalLocation *   mainLocation,   // May be null.
                    865:                                                   CFContLogicalLocation *   initLocation,   // May be null.
                    866:                                                   CFContLogicalLocation *   termLocation ); // May be null.
                    867: 
                    868: // -------------------------------------------------------------------------------------------
                    869: 
                    870: extern OSStatus PEF_GetExportedSymbolCount  ( CFContHandlerRef              containerRef,
                    871:                                               ItemCount *                   exportCount );
                    872: 
                    873: extern OSStatus PEF_GetExportedSymbolInfo   ( CFContHandlerRef              containerRef,
                    874:                                               CFContSignedIndex             exportIndex,
                    875:                                               PBVersion                     infoVersion,
                    876:                                               CFContExportedSymbolInfo *    exportInfo );
                    877: 
                    878: extern OSStatus PEF_FindExportedSymbolInfo  ( CFContHandlerRef              containerRef,
                    879:                                               const CFContHashedName *      exportName,
                    880:                                               PBVersion                     infoVersion,
                    881:                                               ItemCount *                   exportIndex,    // May be null.
                    882:                                               CFContExportedSymbolInfo *    exportInfo );   // May be null.
                    883: 
                    884: // -------------------------------------------------------------------------------------------
                    885: 
                    886: extern OSStatus PEF_GetImportCounts             ( CFContHandlerRef              containerRef,
                    887:                                                   ItemCount *                   libraryCount,   // May be null.
                    888:                                                   ItemCount *                   symbolCount );  // May be null.
                    889: 
                    890: extern OSStatus PEF_GetImportedLibraryInfo      ( CFContHandlerRef              containerRef,
                    891:                                                   ItemCount                     libraryIndex,
                    892:                                                   PBVersion                     infoVersion,
                    893:                                                   CFContImportedLibraryInfo *   libraryInfo );
                    894: 
                    895: extern OSStatus PEF_GetImportedSymbolInfo       ( CFContHandlerRef              containerRef,
                    896:                                                   ItemCount                     symbolIndex,
                    897:                                                   PBVersion                     infoVersion,
                    898:                                                   CFContImportedSymbolInfo *    symbolInfo );
                    899: 
                    900: extern OSStatus PEF_SetImportedSymbolAddress    ( CFContHandlerRef              containerRef,
                    901:                                                   ItemCount                     symbolIndex,
                    902:                                                   LogicalAddress                symbolAddress );
                    903: 
                    904: // -------------------------------------------------------------------------------------------
                    905: 
                    906: extern OSStatus PEF_UnpackSection           ( CFContHandlerRef      containerRef,
                    907:                                               ItemCount             sectionIndex,
                    908:                                               ByteCount             sectionOffset,
                    909:                                               LogicalAddress        bufferAddress,
                    910:                                               ByteCount             bufferLength );
                    911: 
                    912: extern OSStatus PEF_RelocateSection         ( CFContHandlerRef      containerRef,
                    913:                                               ItemCount             sectionIndex );
                    914: 
                    915: extern OSStatus PEF_RelocateImportsOnly     ( CFContHandlerRef      containerRef,
                    916:                                               ItemCount             sectionIndex,
                    917:                                               ItemCount             libraryIndex );
                    918: 
                    919: struct CFragInitBlock {
                    920:        void *          contextID;
                    921:        void *          closureID;
                    922:        void *          connectionID;
                    923:        SInt32          where;                  // locator rec
                    924:        LogicalAddress  address;
                    925:        ByteCount       length;
                    926:        Boolean         inPlace;
                    927:        UInt8           resvA;
                    928:        UInt16          resvB;
                    929:        char *          libName;
                    930:        UInt32          resvC;
                    931: };
                    932: typedef struct CFragInitBlock CFragInitBlock;
                    933: 
                    934: #pragma options align=reset
                    935: 
                    936: #endif  // __IOPEFINTERNALS__
                    937: 

unix.superglobalmegacorp.com

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