MusicKit
0.0.0
|
00001 #ifndef __MK_DSPStructMisc_H___ 00002 #define __MK_DSPStructMisc_H___ 00003 /* $Id$ 00004 * Functions having to do with DSP assembly data structures. 00005 * Copyright 1988-1992, NeXT Inc. All rights reserved. 00006 * Author: Julius O. Smith III 00007 */ 00008 00009 /************************* INITIALIZATION FUNCTIONS **************************/ 00010 00011 00012 extern void DSPDataRecordInit(DSPDataRecord *dr); 00013 00014 00015 extern void DSPSectionInit(DSPSection *sec); 00016 /* 00017 * Initialize all fields to NULL. 00018 */ 00019 00020 00021 extern void DSPLoadSpecInit(DSPLoadSpec *dsp); 00022 /* 00023 * Initialize all fields to NULL. 00024 */ 00025 00026 00027 /**************************** PRINTING FUNCTIONS *****************************/ 00028 00029 extern void DSPSymbolPrint(DSPSymbol sym); 00030 extern void DSPDataRecordPrint(DSPDataRecord *dr); 00031 extern void DSPSectionPrint(DSPSection *section); 00032 extern void DSPLoadSpecPrint(DSPLoadSpec *dsp); 00033 00034 /****************************** ARCHIVING FUNCTIONS **************************/ 00035 00036 extern int DSPDataRecordWrite(DSPDataRecord *dr, FILE *fp); 00037 extern int DSPSymbolWrite(DSPSymbol sym, FILE *fp); 00038 extern int DSPFixupWrite(DSPFixup fxp, FILE *fp); 00039 extern int DSPSectionWrite(DSPSection *sec, FILE *fp); 00040 extern int DSPLoadSpecWrite(DSPLoadSpec *dsp, FILE *fp); 00041 00042 extern int DSPLoadSpecWriteFile( 00043 DSPLoadSpec *dspptr, /* struct containing DSP load image */ 00044 char *dspfn); /* file name */ 00045 /* 00046 * Writes struct of type DSPLoadSpec to a binary file. 00047 * Writes file to be read by DSPLoadSpecReadFile(). 00048 * Loading is much faster in this case than by using _DSPLnkRead(). 00049 */ 00050 00051 /********************************** readDSPx *********************************/ 00052 00053 extern int DSPSymbolRead(DSPSymbol *symp, FILE *fp); 00054 extern int DSPFixupRead(DSPFixup *fxpp, FILE *fp); 00055 extern int DSPSectionRead(DSPSection **secpp, FILE *fp); 00056 extern int DSPLoadSpecRead(DSPLoadSpec **dpp, FILE *fp); 00057 00058 extern int DSPDataRecordRead( 00059 DSPDataRecord **drpp, 00060 FILE *fp, 00061 DSPSection *sp); /* pointer to section owning this data record */ 00062 00063 00064 extern int DSPLoadSpecReadFile( 00065 DSPLoadSpec **dspptr, /* struct containing DSP load image */ 00066 char *dspfn); /* DSPLoadSpecWriteFile output file */ 00067 /* 00068 * Loads struct of type DSPLoadSpec from a binary ".dsp", ".lod", or ".lnk" 00069 * file. Reads file written by DSPLoadSpecWriteFile(). 00070 */ 00071 00072 extern int DSPDataRecordFree(DSPDataRecord *dr); 00073 /* 00074 * Recursively frees entire data record chain. 00075 */ 00076 00077 extern int DSPSymbolFree(DSPSymbol *sym); 00078 extern int DSPFixupFree(DSPFixup *fxp); 00079 extern int DSPSectionFree(DSPSection *sec); 00080 extern int DSPLoadSpecFree(DSPLoadSpec *dsp); 00081 00082 /******************************* MISCELLANEOUS *******************************/ 00083 00084 extern DSPSection *DSPGetUserSection(DSPLoadSpec *dspStruct); 00085 /* 00086 * Return DSPSection containing user's symbols, code, and data. 00087 * There is a separate section for the user (labeled "USER" in 00088 * DSP assembly language) only if relative assembly was used. 00089 * 00090 * If the DSPLoadSpec was assembled in absolute mode (.lod file), 00091 * or if it came from a relative assembly (.lnk file) with no sections, 00092 * then everything is in the GLOBAL section, and that is returned 00093 * instead. 00094 * 00095 * Equivalent to 00096 * return ((*dspStruct->type == 'A')? 00097 * dspStruct->globalSection : 00098 * dspStruct->userSection); 00099 */ 00100 00101 extern DSPAddress DSPGetFirstAddress(DSPLoadSpec *dspStruct, 00102 DSPLocationCounter locationCounter); 00103 00104 extern DSPAddress DSPGetLastAddress(DSPLoadSpec *dspStruct, 00105 DSPLocationCounter locationCounter); 00106 00107 extern int DSPDataRecordInsert(DSPDataRecord *dr, 00108 DSPDataRecord **head, 00109 DSPDataRecord **tail); 00110 /* 00111 * Insert new data record such that load addresses are sorted 00112 */ 00113 00114 00115 extern int DSPDataRecordMerge(DSPDataRecord *dr); 00116 /* 00117 * Merge contiguous, sorted dataRecords within a DSP memory space. 00118 * Arg is a pointer to first data record in linked list. 00119 */ 00120 00121 extern int DSPCopyLoadSpec(DSPLoadSpec **dspPTo,DSPLoadSpec *dspFrom); 00122 00123 #endif