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