]> git.saurik.com Git - apple/xnu.git/blob - iokit/Families/IONDRVSupport/IOPEFInternals.h
xnu-124.13.tar.gz
[apple/xnu.git] / iokit / Families / IONDRVSupport / IOPEFInternals.h
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 BuildInfo: Built by: Simon Douglas
394 With Interfacer: 2.0d13 (PowerPC native)
395 From: CodeFragmentContainerPriv.i
396 Revision: 9
397 Dated: 10/9/96
398 Last change by: AWL
399 Last comment: Remove special SMP sharing, using prepare option instead.
400
401 Bugs: Report bugs to Radar component ÒSystem InterfacesÓ, ÒLatestÓ
402 List the version information (from above) in the Problem Description.
403
404 */
405 /*
406 -------------------------------------------------------------------------------------------
407 This file contains what used to be called the CFLoader interface. The name was changed to
408 fit the newer convention of having CodeFragment as a common prefix, and to reduce pervasive
409 confusion between the Code Fragment Manager and the Code Fragment Loaders, promulgated by
410 the long history of the Segment Loader. This file defines the abstract interface to the
411 physical representation of code fragments.
412 !!! This version has minimal comments, the main purpose is to get things compiled.
413 */
414
415
416 /*
417 ¤
418 ===========================================================================================
419 General Types and Constants
420 ===========================
421 */
422 typedef SInt32 CFContSignedIndex;
423 typedef UInt32 CFContStringHash;
424 #define CFContStringHashLength(hashValue) ((hashValue) >> 16)
425 struct CFContHashedName {
426 CFContStringHash nameHash; /* ! Includes the name length.*/
427 BytePtr nameText;
428 };
429 typedef struct CFContHashedName CFContHashedName;
430
431 /*
432 ------------------------------------------
433 Declarations for code fragment containers.
434 */
435
436 enum {
437 kCFContContainerInfoVersion = 0x00010001
438 };
439
440 struct CFContContainerInfo {
441 CFContHashedName cfragName;
442 UInt32 modDate; /* !!! Abstract type?*/
443 OSType architecture;
444 CFragVersionNumber currentVersion;
445 CFragVersionNumber oldImpVersion;
446 CFragVersionNumber oldDefVersion;
447 UInt32 reservedA;
448 void * reservedB;
449 };
450 typedef struct CFContContainerInfo CFContContainerInfo;
451
452 /*
453 ----------------------------------------
454 Declarations for code fragment sections.
455 */
456 struct CFContLogicalLocation {
457 CFContSignedIndex section; /* "Real" sections use zero based indices, special ones are negative.*/
458 ByteCount offset;
459 };
460 typedef struct CFContLogicalLocation CFContLogicalLocation;
461
462
463 enum {
464 kCFContNoSectionIndex = -1,
465 kCFContAbsoluteSectionIndex = -2,
466 kCFContReexportSectionIndex = -3
467 };
468
469 typedef UInt8 CFContSectionSharing;
470
471 enum {
472 kCFContShareSectionInClosure = 0, /* ! Not supported at present!*/
473 kCFContShareSectionInProcess = 1,
474 kCFContShareSectionAcrossSystem = 4,
475 kCFContShareSectionWithProtection = 5
476 };
477
478 typedef UInt8 CFContMemoryAccess;
479
480 enum {
481 kCFContMemReadMask = 0x01, /* Readable memory can also be executed.*/
482 kCFContMemWriteMask = 0x02,
483 kCFContMemExecuteMask = 0x04, /* ! Affects cache actions, not protection!*/
484 kCFContReadOnlyData = kCFContMemReadMask,
485 kCFContWriteableData = kCFContMemReadMask | kCFContMemWriteMask,
486 kCFContNormalCode = kCFContMemReadMask | kCFContMemExecuteMask,
487 kCFContExcludedMemory = 0
488 };
489
490 typedef UInt32 CFContSectionOptions;
491
492 enum {
493 /* Values for CFContSectionOptions.*/
494 kPackedCFContSectionMask = 0x01, /* Stored contents are compressed.*/
495 kRelocatedCFContSectionMask = 0x02, /* Section contents have relocations.*/
496 kEmptyFillCFContSectionMask = 0x04, /* The extension part may be left untouched.*/
497 kResidentCFContSectionMask = 0x08,
498 kPrefaultCFContSectionMask = 0x10
499 };
500
501
502 enum {
503 kCFContSectionInfoVersion = 0x00010001
504 };
505
506 struct CFContSectionInfo {
507 CFContHashedName sectionName;
508 CFContMemoryAccess access;
509 CFContSectionSharing sharing;
510 UInt8 alignment; /* ! The power of 2, a.k.a. number of low order zero bits.*/
511 UInt8 reservedA;
512 CFContSectionOptions options;
513 ByteCount containerOffset;
514 ByteCount containerLength;
515 ByteCount unpackedLength;
516 ByteCount totalLength;
517 LogicalAddress defaultAddress;
518 UInt32 reservedB;
519 void * reservedC;
520 };
521 typedef struct CFContSectionInfo CFContSectionInfo;
522
523 /*
524 ----------------------------------
525 Declarations for exported symbols.
526 */
527 typedef UInt32 CFContExportedSymbolOptions;
528 /*
529 ! enum { // Values for CFContExportedSymbolOptions.
530 ! // ! No options at present.
531 ! };
532 */
533
534 enum {
535 kCFContExportedSymbolInfoVersion = 0x00010001
536 };
537
538 struct CFContExportedSymbolInfo {
539 CFContHashedName symbolName;
540 CFContLogicalLocation location;
541 CFContExportedSymbolOptions options;
542 CFragSymbolClass symbolClass;
543 UInt8 reservedA;
544 UInt16 reservedB;
545 UInt32 reservedC;
546 void * reservedD;
547 };
548 typedef struct CFContExportedSymbolInfo CFContExportedSymbolInfo;
549
550 /*
551 ------------------------------------------------
552 Declarations for imported libraries and symbols.
553 */
554 typedef UInt32 CFContImportedLibraryOptions;
555
556 enum {
557 /* Values for CFContImportedLibraryOptions.*/
558 kCFContWeakLibraryMask = 0x01, /* ! Same as kCFContWeakSymbolMask to reduce errors.*/
559 kCFContInitBeforeMask = 0x02,
560 kCFContDeferredBindMask = 0x04
561 };
562
563
564 enum {
565 kCFContImportedLibraryInfoVersion = 0x00010001
566 };
567
568 struct CFContImportedLibraryInfo {
569 CFContHashedName libraryName;
570 CFragVersionNumber linkedVersion;
571 CFragVersionNumber oldImpVersion;
572 CFContImportedLibraryOptions options;
573 };
574 typedef struct CFContImportedLibraryInfo CFContImportedLibraryInfo;
575
576 typedef UInt32 CFContImportedSymbolOptions;
577
578 enum {
579 /* Values for CFContImportedSymbolOptions.*/
580 kCFContWeakSymbolMask = 0x01 /* ! Same as kCFContWeakLibraryMask to reduce errors.*/
581 };
582
583
584 enum {
585 kCFContImportedSymbolInfoVersion = 0x00010001
586 };
587
588 struct CFContImportedSymbolInfo {
589 CFContHashedName symbolName;
590 ItemCount libraryIndex;
591 CFContImportedSymbolOptions options;
592 CFragSymbolClass symbolClass;
593 UInt8 reservedA;
594 UInt16 reservedB;
595 UInt32 reservedC;
596 void * reservedD;
597 };
598 typedef struct CFContImportedSymbolInfo CFContImportedSymbolInfo;
599
600 /*
601 -------------------------------------------------
602 Declarations for dealing with container handlers.
603 */
604 typedef UInt32 CFContOpenOptions;
605
606 enum {
607 /* Values for CFContOpenOptions.*/
608 kCFContPrepareInPlaceMask = 0x01,
609 kCFContMinimalOpenMask = 0x02
610 };
611
612 typedef UInt32 CFContCloseOptions;
613
614 enum {
615 /* Values for CFContCloseOptions.*/
616 kCFContPartialCloseMask = 0x01
617 };
618
619 typedef struct OpaqueCFContHandlerRef* CFContHandlerRef;
620 typedef struct CFContHandlerProcs CFContHandlerProcs;
621 typedef CFContHandlerProcs *CFContHandlerProcsPtr;
622 typedef LogicalAddress (*CFContAllocateMem)(ByteCount size);
623 typedef void (*CFContReleaseMem)(LogicalAddress address);
624 /*
625 ¤
626 ===========================================================================================
627 Container Handler Routines
628 ==========================
629 */
630 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);
631 typedef OSStatus (*CFCont_CloseContainer)(CFContHandlerRef containerRef, CFContCloseOptions options);
632 typedef OSStatus (*CFCont_GetContainerInfo)(CFContHandlerRef containerRef, PBVersion infoVersion, CFContContainerInfo *containerInfo);
633 /* -------------------------------------------------------------------------------------------*/
634 typedef OSStatus (*CFCont_GetSectionCount)(CFContHandlerRef containerRef, ItemCount *sectionCount);
635 typedef OSStatus (*CFCont_GetSectionInfo)(CFContHandlerRef containerRef, ItemCount sectionIndex, PBVersion infoVersion, CFContSectionInfo *sectionInfo);
636 typedef OSStatus (*CFCont_FindSectionInfo)(CFContHandlerRef containerRef, const CFContHashedName *sectionName, PBVersion infoVersion, ItemCount *sectionIndex, CFContSectionInfo *sectionInfo);
637 typedef OSStatus (*CFCont_SetSectionAddress)(CFContHandlerRef containerRef, ItemCount sectionIndex, LogicalAddress mappedAddress, LogicalAddress runningAddress);
638 /* -------------------------------------------------------------------------------------------*/
639 typedef OSStatus (*CFCont_GetAnonymousSymbolLocations)(CFContHandlerRef containerRef, CFContLogicalLocation *mainLocation, CFContLogicalLocation *initLocation, CFContLogicalLocation *termLocation);
640 /* -------------------------------------------------------------------------------------------*/
641 typedef OSStatus (*CFCont_GetExportedSymbolCount)(CFContHandlerRef containerRef, ItemCount *exportCount);
642 typedef OSStatus (*CFCont_GetExportedSymbolInfo)(CFContHandlerRef containerRef, CFContSignedIndex exportedIndex, PBVersion infoVersion, CFContExportedSymbolInfo *exportInfo);
643 typedef OSStatus (*CFCont_FindExportedSymbolInfo)(CFContHandlerRef containerRef, const CFContHashedName *exportName, PBVersion infoVersion, ItemCount *exportIndex, CFContExportedSymbolInfo *exportInfo);
644 /* -------------------------------------------------------------------------------------------*/
645 typedef OSStatus (*CFCont_GetImportCounts)(CFContHandlerRef containerRef, ItemCount *libraryCount, ItemCount *symbolCount);
646 typedef OSStatus (*CFCont_GetImportedLibraryInfo)(CFContHandlerRef containerRef, ItemCount libraryIndex, PBVersion infoVersion, CFContImportedLibraryInfo *libraryInfo);
647 typedef OSStatus (*CFCont_GetImportedSymbolInfo)(CFContHandlerRef containerRef, ItemCount symbolIndex, PBVersion infoVersion, CFContImportedSymbolInfo *symbolInfo);
648 typedef OSStatus (*CFCont_SetImportedSymbolAddress)(CFContHandlerRef containerRef, ItemCount symbolIndex, LogicalAddress symbolAddress);
649 /* -------------------------------------------------------------------------------------------*/
650 typedef OSStatus (*CFCont_UnpackSection)(CFContHandlerRef containerRef, ItemCount sectionIndex, ByteCount sectionOffset, LogicalAddress bufferAddress, ByteCount bufferLength);
651 typedef OSStatus (*CFCont_RelocateSection)(CFContHandlerRef containerRef, ItemCount sectionIndex);
652 typedef OSStatus (*CFCont_RelocateImportsOnly)(CFContHandlerRef containerRef, ItemCount sectionIndex, ItemCount libraryIndex);
653 typedef OSStatus (*CFCont_MakeSectionExecutable)(CFContHandlerRef containerRef, ItemCount sectionIndex);
654 typedef OSStatus (*CFCont_AllocateSection)(CFContHandlerRef containerRef, ItemCount sectionIndex, LogicalAddress *mappedAddress, LogicalAddress *runningAddress);
655 typedef OSStatus (*CFCont_ReleaseSection)(CFContHandlerRef containerRef, ItemCount sectionIndex);
656 /* -------------------------------------------------------------------------------------------*/
657
658 #if 0
659 struct CFContHandlerInfo {
660 OrderedItemName orderedName;
661 OrderRequirements orderedReq;
662 CFCont_OpenContainer OpenHandler;
663 };
664 typedef struct CFContHandlerInfo CFContHandlerInfo;
665 #endif
666
667 struct CFContHandlerProcs {
668 ItemCount procCount;
669 CFragShortVersionPair abiVersion;
670
671 CFCont_OpenContainer OpenContainer; /* 1*/
672 CFCont_CloseContainer CloseContainer; /* 2*/
673 CFCont_GetContainerInfo GetContainerInfo; /* 3*/
674
675 CFCont_GetSectionCount GetSectionCount; /* 4*/
676 CFCont_GetSectionInfo GetSectionInfo; /* 5*/
677 CFCont_FindSectionInfo FindSectionInfo; /* 6*/
678 CFCont_SetSectionAddress SetSectionAddress; /* 7*/
679
680 CFCont_GetAnonymousSymbolLocations GetAnonymousSymbolLocations; /* 8*/
681
682 CFCont_GetExportedSymbolCount GetExportedSymbolCount; /* 9*/
683 CFCont_GetExportedSymbolInfo GetExportedSymbolInfo; /* 10*/
684 CFCont_FindExportedSymbolInfo FindExportedSymbolInfo; /* 11*/
685
686 CFCont_GetImportCounts GetImportCounts; /* 12*/
687 CFCont_GetImportedLibraryInfo GetImportedLibraryInfo; /* 13*/
688 CFCont_GetImportedSymbolInfo GetImportedSymbolInfo; /* 14*/
689 CFCont_SetImportedSymbolAddress SetImportedSymbolAddress; /* 15*/
690
691 CFCont_UnpackSection UnpackSection; /* 16*/
692 CFCont_RelocateSection RelocateSection; /* 17*/
693 CFCont_RelocateImportsOnly RelocateImportsOnly; /* 18*/
694 CFCont_MakeSectionExecutable MakeSectionExecutable; /* 19 (Opt.)*/
695 CFCont_AllocateSection AllocateSection; /* 20 (Opt.)*/
696 CFCont_ReleaseSection ReleaseSection; /* 21 (Opt.)*/
697 };
698
699
700 enum {
701 kCFContMinimumProcCount = 18,
702 kCFContCurrentProcCount = 21,
703 kCFContHandlerABIVersion = 0x00010001
704 };
705
706 /*
707 -----------------------------------------------------------------------------------------
708 The ABI version is a pair of UInt16s used as simple counters. The high order part is the
709 current version number, the low order part is the oldest compatible definition version.
710 number. This pair is to be used by the specific container handlers to describe what
711 version of the container handler ABI they support.
712 0x00010001
713 ----------
714 The initial release of this ABI. (The old CFLoader ABI does not count.)
715 ¤
716 ===========================================================================================
717 General Routines
718 ================
719 */
720 extern CFContStringHash CFContHashName(BytePtr nameText, ByteCount nameLength);
721
722 #if 0
723
724 /* -------------------------------------------------------------------------------------------*/
725 extern OSStatus CFContOpenContainer(LogicalAddress mappedAddress, LogicalAddress runningAddress, ByteCount containerLength, KernelProcessID runningProcessID, const CFContHashedName *cfragName, CFContOpenOptions options, CFContAllocateMem Allocate, CFContReleaseMem Release, CFContHandlerRef *containerRef, CFContHandlerProcsPtr *handlerProcs);
726
727 /* -------------------------------------------------------------------------------------------*/
728 extern OSStatus CFContRegisterContainerHandler(const OrderedItemName *orderedName, const OrderRequirements *orderedReq, CFCont_OpenContainer OpenHandler, OrderedItemName *rejectingHandler);
729
730 extern OSStatus CFContUnregisterContainerHandler(const OrderedItemName *orderedName);
731
732 extern OSStatus CFContGetContainerHandlers(ItemCount requestedCount, ItemCount *totalCount, CFContHandlerInfo *handlers);
733
734 /* -------------------------------------------------------------------------------------------*/
735 #endif
736
737
738
739
740
741
742 /*
743 File: PEFLoader.h
744
745 Contains: PEF Loader Interface.
746
747 Version: Maxwell
748
749 Copyright: © 1992-1996 by Apple Computer, Inc., all rights reserved.
750
751 File Ownership:
752
753 DRI: Alan Lillich
754
755 Other Contact: <<unknown>>
756
757 Technology: Core Runtime
758
759 Writers:
760
761 (AWL) Alan Lillich
762 (ELE) Erik Eidt
763
764 Change History (most recent first):
765
766 <7> 8/23/96 AWL (1379028) Propagate changes from CodeFragmentContainerPriv.
767 <6> 2/28/96 AWL Adapt for new container handler model.
768 <5> 6/20/94 AWL Move private PEF loader info struct here to be visible to the
769 booting "wacky" PEF loader.
770 <4> 6/8/94 AWL Make all CFL routines visible for direct use in special cases
771 such as booting.
772 <3> 5/16/94 AWL Fix typo.
773 <2> 2/25/94 AWL Update for Q&D solution to loading across address spaces.
774 <1> 2/15/94 AWL Initial checkin for kernel based CFM.
775 */
776
777 // ===========================================================================================
778
779 enum {
780 kBuiltinSectionArraySize = 4
781 };
782
783 struct PEFPrivateInfo { // !!! Clean up field names, collapse Booleans, etc.
784 CFContAllocateMem Allocate;
785 CFContReleaseMem Release;
786 BytePtr mappedContainer;
787 BytePtr runningContainer;
788 ItemCount sectionCount; // Just the instantiated sections.
789 SectionHeader * sections;
790 BytePtr stringTable;
791 ItemCount ldrSectionNo;
792 LoaderHeader * ldrHeader;
793 BytePtr ldrStringTable;
794 LoaderRelExpHeader * ldrSections;
795 LoaderImportFileID * ldrImportFiles;
796 LoaderImport * ldrImportSymbols;
797 HashSlotEntry * ldrHashSlot;
798 HashChainEntry * ldrHashChain;
799 LoaderExport * ldrExportSymbols;
800 BytePtr ldrRelocations;
801 BytePtr * mappedOrigins; // Mapped base address for each section.
802 ByteCount * runningOffsets; // Running offset from presumed address.
803 BytePtr * imports;
804 BytePtr originArray [kBuiltinSectionArraySize]; // ! Only used if big enough.
805 ByteCount offsetArray [kBuiltinSectionArraySize]; // ! Only used if big enough.
806 Boolean loadInPlace;
807 Boolean resolved;
808 };
809
810 typedef struct PEFPrivateInfo PEFPrivateInfo;
811
812
813 // ===========================================================================================
814
815
816 extern OSStatus PEF_OpenContainer ( LogicalAddress mappedAddress,
817 LogicalAddress runningAddress,
818 ByteCount containerLength,
819 KernelProcessID runningProcessID,
820 const CFContHashedName * cfragName,
821 CFContOpenOptions options,
822 CFContAllocateMem Allocate,
823 CFContReleaseMem Release,
824 CFContHandlerRef * containerRef_o,
825 CFContHandlerProcs * * handlerProcs_o );
826
827 extern OSStatus PEF_CloseContainer ( CFContHandlerRef containerRef,
828 CFContCloseOptions options );
829
830 extern OSStatus PEF_GetContainerInfo ( CFContHandlerRef containerRef,
831 PBVersion infoVersion,
832 CFContContainerInfo * containerInfo );
833
834 // -------------------------------------------------------------------------------------------
835
836 extern OSStatus PEF_GetSectionCount ( CFContHandlerRef containerRef,
837 ItemCount * sectionCount );
838
839 extern OSStatus PEF_GetSectionInfo ( CFContHandlerRef containerRef,
840 ItemCount sectionIndex,
841 PBVersion infoVersion,
842 CFContSectionInfo * sectionInfo );
843
844 extern OSStatus PEF_FindSectionInfo ( CFContHandlerRef containerRef,
845 const CFContHashedName * sectionName,
846 PBVersion infoVersion,
847 ItemCount * sectionIndex, // May be null.
848 CFContSectionInfo * sectionInfo ); // May be null.
849
850 extern OSStatus PEF_SetSectionAddress ( CFContHandlerRef containerRef,
851 ItemCount sectionIndex,
852 LogicalAddress mappedAddress,
853 LogicalAddress runningAddress );
854
855 // -------------------------------------------------------------------------------------------
856
857 extern OSStatus PEF_GetAnonymousSymbolLocations ( CFContHandlerRef containerRef,
858 CFContLogicalLocation * mainLocation, // May be null.
859 CFContLogicalLocation * initLocation, // May be null.
860 CFContLogicalLocation * termLocation ); // May be null.
861
862 // -------------------------------------------------------------------------------------------
863
864 extern OSStatus PEF_GetExportedSymbolCount ( CFContHandlerRef containerRef,
865 ItemCount * exportCount );
866
867 extern OSStatus PEF_GetExportedSymbolInfo ( CFContHandlerRef containerRef,
868 CFContSignedIndex exportIndex,
869 PBVersion infoVersion,
870 CFContExportedSymbolInfo * exportInfo );
871
872 extern OSStatus PEF_FindExportedSymbolInfo ( CFContHandlerRef containerRef,
873 const CFContHashedName * exportName,
874 PBVersion infoVersion,
875 ItemCount * exportIndex, // May be null.
876 CFContExportedSymbolInfo * exportInfo ); // May be null.
877
878 // -------------------------------------------------------------------------------------------
879
880 extern OSStatus PEF_GetImportCounts ( CFContHandlerRef containerRef,
881 ItemCount * libraryCount, // May be null.
882 ItemCount * symbolCount ); // May be null.
883
884 extern OSStatus PEF_GetImportedLibraryInfo ( CFContHandlerRef containerRef,
885 ItemCount libraryIndex,
886 PBVersion infoVersion,
887 CFContImportedLibraryInfo * libraryInfo );
888
889 extern OSStatus PEF_GetImportedSymbolInfo ( CFContHandlerRef containerRef,
890 ItemCount symbolIndex,
891 PBVersion infoVersion,
892 CFContImportedSymbolInfo * symbolInfo );
893
894 extern OSStatus PEF_SetImportedSymbolAddress ( CFContHandlerRef containerRef,
895 ItemCount symbolIndex,
896 LogicalAddress symbolAddress );
897
898 // -------------------------------------------------------------------------------------------
899
900 extern OSStatus PEF_UnpackSection ( CFContHandlerRef containerRef,
901 ItemCount sectionIndex,
902 ByteCount sectionOffset,
903 LogicalAddress bufferAddress,
904 ByteCount bufferLength );
905
906 extern OSStatus PEF_RelocateSection ( CFContHandlerRef containerRef,
907 ItemCount sectionIndex );
908
909 extern OSStatus PEF_RelocateImportsOnly ( CFContHandlerRef containerRef,
910 ItemCount sectionIndex,
911 ItemCount libraryIndex );
912
913 struct CFragInitBlock {
914 void * contextID;
915 void * closureID;
916 void * connectionID;
917 SInt32 where; // locator rec
918 LogicalAddress address;
919 ByteCount length;
920 Boolean inPlace;
921 UInt8 resvA;
922 UInt16 resvB;
923 char * libName;
924 UInt32 resvC;
925 };
926 typedef struct CFragInitBlock CFragInitBlock;
927
928 #pragma options align=reset
929
930 #endif // __IOPEFINTERNALS__
931