// *** This is DSlave.h, the header file for DSlave.c *** // The DSlave.h file contains a number of constants used by the // loadDSP subroutine found in the 'DSlave.c' file. These constants // define the structure of the ".lod" files (COFF format) created // by the C3X linker program 'lnkC3X.exe'. // The explanation of how these constants are derived may be found // in Appendix A of the "TMS320 Floating-Point DSP Assembly Language // Tools" users guide published by TI. (SPRU035A) // // This file also includes the function prototypes for DSlave.c #include "PlxApi.h" #include "..\\Common\PlxInit.h" #include "Reg9030.h" /*********** * Defines ***********/ // File handling #define MAX_SECTIONS 90 #define MAX_SEC_NAME 8 #define MAX_LEN 30 #define MAX_SECTION_IMAGE_SIZE 0x10000 #define RAM_START 0 #define MAJOR_VERSION 1 #define MINOR_VERSION 3 #define MAX_SYM 16 typedef struct { char symbol[MAX_SYM]; unsigned long value; } Global_Sym_Tab; typedef struct { unsigned short section; unsigned short flags; unsigned long offset; char symbol[MAX_SYM]; } Global_Rel_Tab; #define F_RELFLG 0x0001 #define F_EXEC 0x0002 #define F_LNNO 0x0004 #define F_LSYMS 0x0010 #define F_AR32WR 0x0040 typedef struct{ unsigned short magic; unsigned short num_sec; long time; long sym_tab_start; long sym_tab_len; unsigned short opt_head_size; unsigned short flags; } File_Header; #define STYP_REG 0x0000 #define STYP_DSECT 0x0001 #define STYP_NOLOAD 0x0002 #define STYP_GROUP 0x0004 #define STYP_PAD 0x0008 #define STYP_COPY 0x0010 #define STYP_TEXT 0x0020 #define STYP_DATA 0x0040 #define STYP_BSS 0x0080 #define STYP_ALIGN 0x0100 typedef struct{ char name[8]; long physical_address; long virtual_address; long size; long raw_data_pointer; long relocation_pointer; long line_num_pointer; unsigned short num_relocation_entries; unsigned short num_line_num_entries; unsigned short flags; char reserved; char memory_page_number; } Section_Header; #define R_RELLONG 0x0011 #define R_SECREL32 0x0030 #define R_RELWORD 0x0010 #define R_RELPAGE 0x0033 #define R_REL24 0x0005 #define R_PCRWORD 0x0013 #define R_PCRDWORD 0x0014 #define R_RESOLVED 0xFFFF #define R_SECREL16 0x0031 #define R_SECREL24 0x0032 typedef struct{ unsigned long address; unsigned short sym_index; unsigned short reserved; unsigned short type; } Rel_Entry; #define T_NULL 0 #define C_NULL 0 #define C_EXT 2 #define C_EXTDEF 5 #define C_STATLAB 20 #define C_EXTLAB 21 typedef struct{ unsigned long offset_mode; unsigned long string_offset; long value; short section; unsigned short type; unsigned char aclass; unsigned char aux_entries; } Sym_Tab_Entry; // Constants #define PLX_VENDOR_ID 0x10B5 #define RETURN_ERROR -1 // function encountered error #define RETURN_SUCCESS 0 // function completed successfully #define RETURN_TIMEOUT -2 // function completed successfully #define TRUE 1 // pseudo-boolean true #define FALSE 0 // pseudo-boolean false #define BRIEF_PAUSE 0.8 // brief pause #define TIMEOUT_DSP_CONFIRM 3.0 // 3 second timeout period #define RESET_LOW_TIME 1.0 // /RESET stays low for 1 second #define MENU_ERROR 80 // invalid menu selection (non-number) #define WORD_WIDTH 4 // 4 bytes per word #define DSP_OS_FILE "c33_os.bin" // default operating system binary file // PLX Local Configuration Register Locations #define LOCAL_GPIOC 0x54 // GPIO select, direction, and data #define GPIO4_DATA 0x00004000 // GPIO0 data is bit 4 #define CS2BASE 0x00000044 // CS2 Base Address #define LAS2BRD 0x00000030 // Local Addr. Space 2 Region Descriptor #define LAS2RR 0x00000008 // Local Addr. Space 2 Range Register (PCI to Local) #define LAS2BA 0x0000001C // Local Addr. Space 1 Base Address Remap #define CS1BASE 0x00000040 // CS1 Base Address #define LAS1BRD 0x0000002C // Local Addr. Space 1 Region Descriptor #define LAS1RR 0x00000004 // Local Addr. Space 1 Range Register (PCI to Local) #define LAS1BA 0x00000018 // Local Addr. Space 1 Base Address Remap #define CS0BASE 0x0000003C // CS0 Base Address #define LAS0BRD 0x00000028 // Local Addr. Space 0 Region Descriptor #define LAS0RR 0x00000000 // Local Addr. Space 0 Range Register (PCI to Local) #define LAS0BA 0x00000014 // Local Addr. Space 0 Base Address Remap // PLX PCI Configuration Register Locations #define PCIBAR2 0x00000018 // PCI Base Address Reg for mem access to LAS0 #define PCIBAR3 0x0000001C // PCI Base Address Reg for mem access to LAS1 #define PCIBAR4 0x00000020 // PCI Base Address Reg for mem access to LAS2 // DPRAM Mailboxes #define MAILBOX_DSPtoPC 0x00000FFE // #define MAILBOX_PCtoDSP 0x00000FFF // // DSP commands/ memory locations #define DSP_WRITE 0x00000000 // write to DSP memory #define DSP_READ 0x01000000 // read from DSP memory #define DSP_EXECUTE 0x02000000 // start execution at an address #define DSP_USER 0x03000000 // perform user program #define OPCODE_BYTE_SIZE 4 // opcode size is 1 word (4 bytes) #define DSP_REG_BASE 0x00808000 // ?? NEEDS CHANGED ?? #define DSP_CONFIRM 0x0000FAB4 // reset confirmation message from DSP // DSP/DPRAM Addresses #define DSP_END_MEM 0x00FFFFFF // end of DSP memory range #define DPRAM_USER_SIZE 0xFFD // 0x01000-3=0x00ffd -> 4093 #define DPRAM_NUMWORDS 0x00000FFD // load number of words #define DPRAM_OS_ADDR 0x00000000 // load OS address #define DPRAM_START_MEM 0x00000000 // start data // Hex to Floating Point Conversions using "FLOATPT.C" #define SINGLE_PRECISION 1 // 32-bit TMS single-precision number #define DOUBLE_PRECISION 0 // 40-bit TMS double-precision number // Control for error messages to screen #define LEVEL1 1 // Few messages #define LEVEL2 2 // More messages #define LEVEL3 3 // Lots of messages /************************* * Prototype Definitions *************************/ int readLocalReg(U32 RegisterNumber); // read a single PLX local register and display to screen int writeLocalReg(U32 RegisterNumber, U32 Data32); int readPCIReg(U32 Address); // read a single PCI config reg and display int writePCIReg(U32 Location,U32 Data32); // write to a single PCI config reg and display int writeDSPMem(U32 Location, U32 NumWords, U32 *BufferWrite); // write to mem location int readDSPMem(U32 Location, U32 NumWords); int writeDPRAMMem(U32 Location, U32 NumWords, U32 *Buffer); int readDPRAMMem(U32 Location, U32 NumWords); int runDSPProg(); int fetchOpcode(U32 Location, U32 NumWords, U32 Command, U32 *Opcode); int readMailbox(U32 Mailbox, U32 *Data); int resetDSP(); int resetPLXBoard(); int loadDSP(const char *fName, char *message); int loadOS(const char *fName, char *message); int clearReadBuffer(); // clears entire global read buffer int clearWriteBuffer(); // clears entire global write buffer float TMS_IEEE( unsigned long n ); // converts TI Float HEX to C Float void switchEndianess(U32 *buffer, int words); /************************* * Global Variables *************************/ S8 DeviceSelected; HANDLE hDevice; RETURN_CODE rc; DEVICE_LOCATION Device; int ReturnCode; // general purpose return value U32 BufferWrite[DPRAM_USER_SIZE]; // large buffer for write data U32 BufferRead[DPRAM_USER_SIZE]; // large buffer for read data U32 *ReadBufferPtr; // pointer into BufferRead U32 *WriteBufferPtr; // pointer into BufferWrite IOP_SPACE IopSpace; char message[100]; // return message from code loader U32 MessageLevel; // control for text errors and warning output to screen // LEVEL1 (default): Most basic messages, for Common Use // LEVEL2 : More detailed messages // LEVEL3 : Even more detailed messages