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