public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/17] First set of unreviewed patches
@ 2009-12-15  6:19 Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 01/17] DSPBRIDGE: Remove preproessor condition that could never work Omar Ramirez Luna
                   ` (17 more replies)
  0 siblings, 18 replies; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos, Omar Ramirez Luna

These patches need to be reviewed to be included into dspbridge-baseline.

Ernest Ramos Falcon (1):
  DSPBRIDGE: check pointer before calling Proc_Detach

Ernesto Ramos Falcon (1):
  DSPBRIDGE: Memory leak in Node Register Notify

Fernando Guzman Lugo (3):
  DSPBRIDGE: Implemented Trampoline support for dynamic loader
  DSPBRIDGE: Enable/Disable MCBSP_CLOCKS for MCBSP2
  DSPBRIDGE: support loading 4 dependent DLL

Omar Ramirez Luna (11):
  DSPBRIDGE: set PWRERROR notifications as an option
  DSPBRIDGE: Enable peripheral clocks on wake up
  DSPBRIDGE: Remove long busy-wait loops on PWRST transitions
  DSPBRIDGE: Rename usCount to timeout
  DSPBRIDGE: Trivial cleanup on DBDCD
  DSPBRIDGE: Do not panic on bad page count
  DSPBRIDGE: check the status of DMM_GetHandle
  DSPBRIDGE: KFILE_Seek & KFILE_Tell, u32 replaced with loff_t
  DSPBRIDGE: Delete unused files
  DSPBRIDGE: Avoid REGistry if pDevContext is available
  DSPBRIDGE: Compilation fixes 2.6.31

Rebecca Schultz Zavin (1):
  DSPBRIDGE: Remove preproessor condition that could never work

 arch/arm/mach-omap2/dspbridge.c                |    2 +
 arch/arm/plat-omap/include/dspbridge/cfgdefs.h |    2 +-
 arch/arm/plat-omap/include/dspbridge/dbl.h     |  354 ------
 arch/arm/plat-omap/include/dspbridge/dbof.h    |  117 --
 drivers/dsp/bridge/Kconfig                     |   11 +
 drivers/dsp/bridge/Makefile                    |    3 +-
 drivers/dsp/bridge/dynload/cload.c             |  328 ++++---
 drivers/dsp/bridge/dynload/dlclasses_hdr.h     |   41 -
 drivers/dsp/bridge/dynload/dload_internal.h    |  125 +++-
 drivers/dsp/bridge/dynload/reloc.c             |   81 ++-
 drivers/dsp/bridge/dynload/tramp.c             | 1110 +++++++++++++++++++
 drivers/dsp/bridge/dynload/tramp_table_c6000.c |  164 +++
 drivers/dsp/bridge/pmgr/cod.c                  |    4 +-
 drivers/dsp/bridge/pmgr/dbl.c                  | 1385 ------------------------
 drivers/dsp/bridge/pmgr/wcd.c                  |    5 +
 drivers/dsp/bridge/rmgr/dbdcd.c                |  345 +++---
 drivers/dsp/bridge/rmgr/drv.c                  |    2 +-
 drivers/dsp/bridge/rmgr/drv_interface.c        |   11 +-
 drivers/dsp/bridge/rmgr/proc.c                 |   20 +-
 drivers/dsp/bridge/wmd/_tiomap.h               |    8 +-
 drivers/dsp/bridge/wmd/_tiomap_util.h          |    6 +
 drivers/dsp/bridge/wmd/mmu_fault.c             |   24 +-
 drivers/dsp/bridge/wmd/tiomap3430.c            |  200 ++--
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c        |  134 ++-
 drivers/dsp/bridge/wmd/tiomap_sm.c             |   54 +-
 drivers/dsp/bridge/wmd/ue_deh.c                |   17 +-
 26 files changed, 2106 insertions(+), 2447 deletions(-)
 delete mode 100644 arch/arm/plat-omap/include/dspbridge/dbl.h
 delete mode 100644 arch/arm/plat-omap/include/dspbridge/dbof.h
 delete mode 100644 drivers/dsp/bridge/dynload/dlclasses_hdr.h
 create mode 100644 drivers/dsp/bridge/dynload/tramp.c
 create mode 100644 drivers/dsp/bridge/dynload/tramp_table_c6000.c
 delete mode 100644 drivers/dsp/bridge/pmgr/dbl.c


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH 01/17] DSPBRIDGE: Remove preproessor condition that could never work
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 02/17] DSPBRIDGE: Implemented Trampoline support for dynamic loader Omar Ramirez Luna
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos, Rebecca Schultz Zavin

From: Rebecca Schultz Zavin <rebecca@android.com>

This macro can refer to a varible not defined in this scope.
gcc 4.4 and later will view this as an error and this code
will not compile.

Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
---
 drivers/dsp/bridge/dynload/cload.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/drivers/dsp/bridge/dynload/cload.c b/drivers/dsp/bridge/dynload/cload.c
index ef5d7d9..4fead55 100644
--- a/drivers/dsp/bridge/dynload/cload.c
+++ b/drivers/dsp/bridge/dynload/cload.c
@@ -1475,10 +1475,6 @@ static char *copy_tgt_strings(void *dstp, void *srcp, unsigned charcount)
 #if TARGET_AU_BITS <= BITS_PER_AU
 		/* byte-swapping issues may exist for strings on target */
 		*dst++ = *src++;
-#elif TARGET_ENDIANNESS_DIFFERS(TARGET_BIG_ENDIAN)
-		register TgtAU_t tmp;
-		tmp = *src++;
-		*dst++ = SWAP16BY8(tmp);  /* right for TARGET_AU_BITS == 16 */
 #else
 		*dst++ = *src++;
 #endif
@@ -1486,8 +1482,6 @@ static char *copy_tgt_strings(void *dstp, void *srcp, unsigned charcount)
 	/*apply force to make sure that the string table has null terminator */
 #if (BITS_PER_AU == BITS_PER_BYTE) && (TARGET_AU_BITS == BITS_PER_BYTE)
 	dst[-1] = 0;
-#elif TARGET_BIG_ENDIAN
-	dst[-1] &= ~BYTE_MASK;	/*  big-endian */
 #else
 	dst[-1] &= (1 << (BITS_PER_AU - BITS_PER_BYTE)) - 1; /* little endian */
 #endif
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 02/17] DSPBRIDGE: Implemented Trampoline support for dynamic loader
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 01/17] DSPBRIDGE: Remove preproessor condition that could never work Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15 18:24   ` Felipe Contreras
  2009-12-15  6:19 ` [PATCH 03/17] DSPBRIDGE: Enable/Disable MCBSP_CLOCKS for MCBSP2 Omar Ramirez Luna
                   ` (15 subsequent siblings)
  17 siblings, 1 reply; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos

From: Fernando Guzman Lugo <x0095840@ti.com>

Implemented on dynamic loader automatic generation of
trampolines when near calls are made to outside of signed
21-bit offset available in the C64X+ DSP.

Signed-off-by: Fernando Guzman Lugo <x0095840@ti.com>
---
 drivers/dsp/bridge/Makefile                    |    3 +-
 drivers/dsp/bridge/dynload/cload.c             |  322 +++++---
 drivers/dsp/bridge/dynload/dload_internal.h    |  125 +++-
 drivers/dsp/bridge/dynload/reloc.c             |   81 ++-
 drivers/dsp/bridge/dynload/tramp.c             | 1110 ++++++++++++++++++++++++
 drivers/dsp/bridge/dynload/tramp_table_c6000.c |  164 ++++
 6 files changed, 1659 insertions(+), 146 deletions(-)
 create mode 100644 drivers/dsp/bridge/dynload/tramp.c
 create mode 100644 drivers/dsp/bridge/dynload/tramp_table_c6000.c

diff --git a/drivers/dsp/bridge/Makefile b/drivers/dsp/bridge/Makefile
index e10a2da..cb6d1ce 100644
--- a/drivers/dsp/bridge/Makefile
+++ b/drivers/dsp/bridge/Makefile
@@ -14,7 +14,8 @@ libpmgr = pmgr/chnl.o pmgr/io.o pmgr/msg.o pmgr/cod.o pmgr/dev.o pmgr/wcd.o \
 librmgr = rmgr/dbdcd.o rmgr/disp.o rmgr/drv.o rmgr/mgr.o rmgr/node.o \
 		rmgr/proc.o rmgr/pwr.o rmgr/rmm.o rmgr/strm.o rmgr/dspdrv.o \
 		rmgr/nldr.o rmgr/drv_interface.o
-libdload = dynload/cload.o dynload/getsection.o dynload/reloc.o
+libdload = dynload/cload.o dynload/getsection.o dynload/reloc.o \
+		 dynload/tramp.o
 libhw = hw/hw_prcm.o hw/hw_dspssC64P.o hw/hw_mmu.o hw/hw_mbox.o
 
 bridgedriver-objs = $(libgen) $(libservices) $(libwmd) $(libpmgr) $(librmgr) \
diff --git a/drivers/dsp/bridge/dynload/cload.c b/drivers/dsp/bridge/dynload/cload.c
index 4fead55..7b9cd97 100644
--- a/drivers/dsp/bridge/dynload/cload.c
+++ b/drivers/dsp/bridge/dynload/cload.c
@@ -191,6 +191,8 @@ int Dynamic_Load_Module(struct Dynamic_Loader_Stream *module,
 		symbol_table_free(&dl_state);
 		section_table_free(&dl_state);
 		string_table_free(&dl_state);
+		dload_tramp_cleanup(&dl_state);
+
 
 		if (dl_state.dload_errcount) {
 			Dynamic_Unload_Module(dl_state.myhandle, syms, alloc,
@@ -489,10 +491,14 @@ static void allocate_sections(struct dload_state *dlthis)
 		DL_ERROR("Arg 3 (alloc) required but NULL", 0);
 		return;
 	}
-	/* allocate space for the module handle, which we will
-	 *	keep for unload purposes */
-	siz = dlthis->dfile_hdr.df_target_scns *
-	      sizeof(struct LDR_SECTION_INFO) + MY_HANDLE_SIZE;
+	/*
+	 * allocate space for the module handle, which we will keep for unload
+	 * purposes include an additional section store for an auto-generated
+	 * trampoline section in case we need it.
+	 */
+	siz = (dlthis->dfile_hdr.df_target_scns + 1) *
+		sizeof(struct LDR_SECTION_INFO) + MY_HANDLE_SIZE;
+
 	hndl = (struct my_handle *)dlthis->mysym->Allocate(dlthis->mysym, siz);
 	if (!hndl) {		/* not enough storage */
 		DL_ERROR(E_ALLOC, siz);
@@ -587,7 +593,7 @@ static void section_table_free(struct dload_state *dlthis)
  * big unsorted array.  We just read that array into memory in bulk.
  ************************************************************************/
 static const char S_STRINGTBL[] = { "string table" };
-void dload_strings(struct dload_state *dlthis, boolean sec_names_only)
+void dload_strings(struct dload_state *dlthis, bool sec_names_only)
 {
 	u32 ssiz;
 	char *strbuf;
@@ -707,11 +713,16 @@ static void dload_symbols(struct dload_state *dlthis)
 	if (s_count == 0)
 		return;
 
-	/* We keep a local symbol table for all of the symbols in the input.
+	/*
+	 * We keep a local symbol table for all of the symbols in the input.
 	 * This table contains only section & value info, as we do not have
 	 * to do any name processing for locals.  We reuse this storage
 	 * as a temporary for .dllview record construction.
-	 * Allocate storage for the whole table.*/
+	 * Allocate storage for the whole table.  Add 1 to the section count
+	 * in case a trampoline section is auto-generated as well as the
+	 * size of the trampoline section name so DLLView doens't get lost.
+	 */
+
 	siz = s_count * sizeof(struct Local_Symbol);
 	dsiz = DBG_HDR_SIZE +
 		(sizeof(struct dll_sect) * dlthis->allocated_secn_count) +
@@ -790,6 +801,12 @@ static void dload_symbols(struct dload_state *dlthis)
 					goto loop_cont;
 				}
 				val = delta = symp->value;
+#ifdef ENABLE_TRAMP_DEBUG
+				dload_syms_error(dlthis->mysym,
+						"===> ext sym [%s] at %x",
+						sname, val);
+#endif
+
 				goto loop_cont;
 			}
 			/* symbol defined by this module */
@@ -1045,9 +1062,11 @@ loopexit:
 #define MY_RELOC_BUF_SIZ 8
 /* careful! exists at the same time as the image buffer*/
 static int relocate_packet(struct dload_state *dlthis,
-			   struct image_packet_t *ipacket, u32 *checks)
+				struct image_packet_t *ipacket,
+				u32 *checks, bool *tramps_generated)
 {
 	u32 rnum;
+	*tramps_generated = false;
 
 	rnum = ipacket->i_num_relocs;
 	do {			/* all relocs */
@@ -1068,11 +1087,21 @@ static int relocate_packet(struct dload_state *dlthis,
 		*checks += dload_checksum(rp, siz);
 		do {
 			/* perform the relocation operation */
-			dload_relocate(dlthis, (TgtAU_t *) ipacket->i_bits, rp);
+			dload_relocate(dlthis, (TgtAU_t *) ipacket->i_bits, rp,
+					tramps_generated, false);
 			rp += 1;
 			rnum -= 1;
 		} while ((rinbuf -= 1) > 0);
 	} while (rnum > 0);	/* all relocs */
+	/* If trampoline(s) were generated, we need to do an update of the
+	 * trampoline copy of the packet since a 2nd phase relo will be done
+	 * later.  */
+	if (*tramps_generated == true) {
+		dload_tramp_pkt_udpate(dlthis,
+				(dlthis->image_secn - dlthis->ldr_sections),
+				dlthis->image_offset, ipacket);
+	}
+
 	return 1;
 }				/* dload_read_reloc */
 
@@ -1097,7 +1126,7 @@ static void dload_data(struct dload_state *dlthis)
 	struct doff_scnhdr_t *sptr = dlthis->sect_hdrs;
 	struct LDR_SECTION_INFO *lptr = dlthis->ldr_sections;
 #ifdef OPT_ZERO_COPY_LOADER
-	boolean bZeroCopy = false;
+	bool bZeroCopy = false;
 #endif
 	u8 *pDest;
 
@@ -1107,155 +1136,158 @@ static void dload_data(struct dload_state *dlthis)
 	} ibuf;
 
 	/* Indicates whether CINIT processing has occurred */
-	boolean cinit_processed = false;
+	bool cinit_processed = false;
 
 	/* Loop through the sections and load them one at a time.
 	 */
 	for (curr_sect = 0; curr_sect < dlthis->dfile_hdr.df_no_scns;
 	     curr_sect += 1) {
-		if (DS_NEEDS_DOWNLOAD(sptr)) {
-			s32 nip;
-			LDR_ADDR image_offset = 0;
-			/* set relocation info for this section */
-			if (curr_sect < dlthis->allocated_secn_count)
-				dlthis->delta_runaddr = sptr->ds_paddr;
-			else {
-				lptr = DOFFSEC_IS_LDRSEC(sptr);
-				dlthis->delta_runaddr = 0;
-			}
-			dlthis->image_secn = lptr;
+		if (!DS_NEEDS_DOWNLOAD(sptr))
+			goto loop_cont1;
+
+		s32 nip;
+		LDR_ADDR image_offset = 0;
+		/* set relocation info for this section */
+		if (curr_sect < dlthis->allocated_secn_count)
+			dlthis->delta_runaddr = sptr->ds_paddr;
+		else {
+			lptr = DOFFSEC_IS_LDRSEC(sptr);
+			dlthis->delta_runaddr = 0;
+		}
+		dlthis->image_secn = lptr;
 #if BITS_PER_AU > BITS_PER_BYTE
-			lptr->name = unpack_name(dlthis, sptr->ds_offset);
+		lptr->name = unpack_name(dlthis, sptr->ds_offset);
 #endif
-			nip = sptr->ds_nipacks;
-			while ((nip -= 1) >= 0) {	/* process packets */
-
-				s32 ipsize;
-				u32 checks;
-				/* get the fixed header bits */
-				if (dlthis->strm->read_buffer(dlthis->strm,
-				    &ibuf.ipacket, IPH_SIZE) != IPH_SIZE) {
-					DL_ERROR(E_READSTRM, IMAGEPAK);
-					return;
-				}
-				/* reorder the header if need be */
-				if (dlthis->reorder_map) {
-					dload_reorder(&ibuf.ipacket, IPH_SIZE,
-						      dlthis->reorder_map);
-				}
-				/* now read the rest of the packet */
-				ipsize =
-				    BYTE_TO_HOST(DOFF_ALIGN
-						(ibuf.ipacket.i_packet_size));
-				if (ipsize > BYTE_TO_HOST(IMAGE_PACKET_SIZE)) {
-					DL_ERROR("Bad image packet size %d",
-						ipsize);
-					return;
-				}
-				pDest = ibuf.bufr;
+		nip = sptr->ds_nipacks;
+		while ((nip -= 1) >= 0) {	/* process packets */
+			s32 ipsize;
+			u32 checks;
+			bool  tramp_generated = false;
+
+			/* get the fixed header bits */
+			if (dlthis->strm->read_buffer(dlthis->strm,
+			    &ibuf.ipacket, IPH_SIZE) != IPH_SIZE) {
+				DL_ERROR(E_READSTRM, IMAGEPAK);
+				return;
+			}
+			/* reorder the header if need be */
+			if (dlthis->reorder_map) {
+				dload_reorder(&ibuf.ipacket, IPH_SIZE,
+					      dlthis->reorder_map);
+			}
+			/* now read the rest of the packet */
+			ipsize = BYTE_TO_HOST(DOFF_ALIGN
+					(ibuf.ipacket.i_packet_size));
+			if (ipsize > BYTE_TO_HOST(IMAGE_PACKET_SIZE)) {
+				DL_ERROR("Bad image packet size %d", ipsize);
+				return;
+			}
+			pDest = ibuf.bufr;
 #ifdef OPT_ZERO_COPY_LOADER
-				bZeroCopy = false;
-				if (DLOAD_SECT_TYPE(sptr) != DLOAD_CINIT) {
-					dlthis->myio->writemem(dlthis->myio,
-						&pDest, lptr->load_addr +
-						image_offset, lptr, 0);
+			bZeroCopy = false;
+			if (DLOAD_SECT_TYPE(sptr) != DLOAD_CINIT) {
+				dlthis->myio->writemem(dlthis->myio, &pDest,
+					lptr->load_addr + image_offset,
+					lptr, 0);
 				bZeroCopy = (pDest != ibuf.bufr);
-				}
+			}
 #endif
-		/* End of determination */
+			/* End of determination */
 
-				if (dlthis->strm->read_buffer(dlthis->strm,
-				    ibuf.bufr, ipsize) != ipsize) {
-					DL_ERROR(E_READSTRM, IMAGEPAK);
-					return;
-				}
-				ibuf.ipacket.i_bits = pDest;
+			if (dlthis->strm->read_buffer(dlthis->strm,
+			    ibuf.bufr, ipsize) != ipsize) {
+				DL_ERROR(E_READSTRM, IMAGEPAK);
+				return;
+			}
+			ibuf.ipacket.i_bits = pDest;
 
-				/* reorder the bytes if need be */
+			/* reorder the bytes if need be */
 #if !defined(_BIG_ENDIAN) || (TARGET_AU_BITS > 16)
-				if (dlthis->reorder_map) {
-					dload_reorder(pDest, ipsize,
-						     dlthis->reorder_map);
-				}
-				checks = dload_checksum(pDest, ipsize);
+			if (dlthis->reorder_map) {
+				dload_reorder(pDest, ipsize,
+					     dlthis->reorder_map);
+			}
+			checks = dload_checksum(pDest, ipsize);
 #else
-				if (dlthis->dfile_hdr.df_byte_reshuffle !=
-				    TARGET_ORDER(REORDER_MAP
-				    (BYTE_RESHUFFLE_VALUE))) {
-					/* put image bytes in big-endian order,
-					 * not PC order */
-					dload_reorder(pDest, ipsize,
+			if (dlthis->dfile_hdr.df_byte_reshuffle !=
+			    TARGET_ORDER(REORDER_MAP(BYTE_RESHUFFLE_VALUE))) {
+				/* put image bytes in big-endian order,
+				 * not PC order */
+				dload_reorder(pDest, ipsize,
 					TARGET_ORDER
 					(dlthis->dfile_hdr.df_byte_reshuffle));
-				}
+			}
 #if TARGET_AU_BITS > 8
-				checks = dload_reverse_checksum_16(pDest,
-								   ipsize);
+			checks = dload_reverse_checksum_16(pDest, ipsize);
 #else
-				checks = dload_reverse_checksum(pDest,
-								ipsize);
+			checks = dload_reverse_checksum(pDest, ipsize);
 #endif
 #endif
-
-				checks += dload_checksum(&ibuf.ipacket,
-							IPH_SIZE);
-				/* relocate the image bits as needed */
-				if (ibuf.ipacket.i_num_relocs) {
-					dlthis->image_offset = image_offset;
-					if (!relocate_packet(dlthis,
-					    &ibuf.ipacket, &checks))
-						return;	/* serious error */
-				}
-				if (~checks)
-					DL_ERROR(E_CHECKSUM, IMAGEPAK);
-				/* stuff the result into target memory */
+			checks += dload_checksum(&ibuf.ipacket,	IPH_SIZE);
+			/* relocate the image bits as needed */
+			if (ibuf.ipacket.i_num_relocs) {
+				dlthis->image_offset = image_offset;
+				if (!relocate_packet(dlthis,
+				    &ibuf.ipacket, &checks,
+				    &tramp_generated))
+					return;	/* serious error */
+			}
+			if (~checks)
+				DL_ERROR(E_CHECKSUM, IMAGEPAK);
+			/* Only write the result to the target if no
+			 * trampoline was generated.  Otherwise it
+			 * will be done during trampoline finalize.  */
+
+			if (tramp_generated == false) {
+				/* stuff the result into target
+				 * memory */
 				if (DLOAD_SECT_TYPE(sptr) == DLOAD_CINIT) {
 					cload_cinit(dlthis, &ibuf.ipacket);
 					cinit_processed = true;
 				} else {
 #ifdef OPT_ZERO_COPY_LOADER
-				    if (!bZeroCopy) {
+					if (!bZeroCopy) {
 #endif
-
-					if (!dlthis->myio->writemem
-					   (dlthis->myio, ibuf.bufr,
-					   lptr->load_addr + image_offset, lptr,
-					   BYTE_TO_HOST
-					   (ibuf.ipacket.i_packet_size))) {
-						DL_ERROR(
-						"Write to " FMT_UI32 " failed",
-						lptr->load_addr + image_offset);
-					}
+						if (!dlthis->myio->writemem
+						(dlthis->myio, ibuf.bufr,
+						lptr->load_addr + image_offset,
+						lptr, BYTE_TO_HOST
+						(ibuf.ipacket.i_packet_size))) {
+							DL_ERROR(
+							"Write to " FMT_UI32
+							" failed",
+							lptr->load_addr +
+							image_offset);
+						}
 #ifdef OPT_ZERO_COPY_LOADER
-				}
+					}
 #endif
-
 				}
-				image_offset +=
+			}
+			image_offset +=
 				      BYTE_TO_TADDR(ibuf.ipacket.i_packet_size);
-			}	/* process packets */
-			/* if this is a BSS section, we may want to fill it */
-			if (DLOAD_SECT_TYPE(sptr) != DLOAD_BSS)
-				goto loop_cont;
+		}	/* process packets */
+		/* if this is a BSS section, we may want to fill it */
+		if (DLOAD_SECT_TYPE(sptr) != DLOAD_BSS)
+			goto loop_cont;
 
-			if (!(dlthis->myoptions & DLOAD_INITBSS))
-				goto loop_cont;
+		if (!(dlthis->myoptions & DLOAD_INITBSS))
+			goto loop_cont;
 
-			if (cinit_processed) {
-				/* Don't clear BSS after load-time
-				 * initialization */
-				DL_ERROR
-				  ("Zero-initialization at " FMT_UI32 " after "
+		if (cinit_processed) {
+			/* Don't clear BSS after load-time
+			 * initialization */
+			DL_ERROR("Zero-initialization at " FMT_UI32 " after "
 				  "load-time initialization!", lptr->load_addr);
-				goto loop_cont;
-			}
-			/* fill the .bss area */
-			dlthis->myio->fillmem(dlthis->myio,
-					      TADDR_TO_HOST(lptr->load_addr),
-					      lptr, TADDR_TO_HOST(lptr->size),
-					      dload_fill_bss);
 			goto loop_cont;
-		} /* if DS_DOWNLOAD_MASK */
+		}
+		/* fill the .bss area */
+		dlthis->myio->fillmem(dlthis->myio,
+					TADDR_TO_HOST(lptr->load_addr),
+					lptr, TADDR_TO_HOST(lptr->size),
+					dload_fill_bss);
+		goto loop_cont;
+loop_cont1:
 		/* If not loading, but BSS, zero initialize */
 		if (DLOAD_SECT_TYPE(sptr) != DLOAD_BSS)
 			goto loop_cont;
@@ -1281,6 +1313,12 @@ loop_cont:
 		sptr += 1;
 		lptr += 1;
 	}			/* load sections */
+
+	/*  Finalize any trampolines that were created during the load  */
+	if (dload_tramp_finalize(dlthis) == 0) {
+		DL_ERROR("Finalization of auto-trampolines (size = " FMT_UI32
+			") failed", dlthis->tramp.tramp_sect_next_addr);
+    }
 }				/* dload_data */
 
 /*************************************************************************
@@ -1526,6 +1564,16 @@ static void init_module_handle(struct dload_state *dlthis)
 	hndl = dlthis->myhandle;
 	if (!hndl)
 		return;		/* must be errors detected, so forget it */
+
+	/*  Store the section count  */
+	hndl->secn_count = dlthis->allocated_secn_count;
+
+	/*  If a trampoline section was created, add it in  */
+	if (dlthis->tramp.tramp_sect_next_addr != 0)
+		hndl->secn_count += 1;
+
+	hndl->secn_count = hndl->secn_count << 1;
+
 	hndl->secn_count = dlthis->allocated_secn_count << 1;
 #ifndef TARGET_ENDIANNESS
 	if (dlthis->big_e_target)
@@ -1603,10 +1651,30 @@ static void init_module_handle(struct dload_state *dlthis)
 		dbsec += 1;
 		asecs += 1;
 	}
+
+	/*  If a trampoline section was created go ahead and add its info  */
+	if (dlthis->tramp.tramp_sect_next_addr != 0) {
+		dbmod->num_sects++;
+		dbsec->sect_load_adr = asecs->load_addr;
+		dbsec->sect_run_adr = asecs->run_addr;
+		dbsec++;
+		asecs++;
+	}
+
 	/* now cram in the names */
 	cp = copy_tgt_strings(dbsec, dlthis->str_head,
 			      dlthis->debug_string_size);
 
+
+	/* If a trampoline section was created, add its name so DLLView
+	 * can show the user the section info.  */
+	if (dlthis->tramp.tramp_sect_next_addr != 0) {
+		cp = copy_tgt_strings(cp,
+			dlthis->tramp.final_string_table,
+			strlen(dlthis->tramp.final_string_table) + 1);
+	}
+
+
 	/* round off the size of the debug record, and remember same */
 	hndl->dm.dbsiz = HOST_TO_TDATA_ROUND(cp - (char *)dbmod);
 	*cp = 0;		/* strictly to make our test harness happy */
@@ -1713,7 +1781,9 @@ int Dynamic_Unload_Module(DLOAD_mhandle mhandle,
 	if (!syms)
 		return 1;
 	syms->Purge_Symbol_Table(syms, (unsigned) hndl);
-	 /* Deallocate target memory for sections */
+	 /* Deallocate target memory for sections
+	  * NOTE: The trampoline section, if created, gets deleted here, too */
+
 	asecs = hndl->secns;
 	if (alloc)
 		for (curr_sect = (hndl->secn_count >> 1); curr_sect > 0;
diff --git a/drivers/dsp/bridge/dynload/dload_internal.h b/drivers/dsp/bridge/dynload/dload_internal.h
index 78f5058..65d1f47 100644
--- a/drivers/dsp/bridge/dynload/dload_internal.h
+++ b/drivers/dsp/bridge/dynload/dload_internal.h
@@ -120,7 +120,103 @@ struct Local_Symbol {
 	s32 delta;	/* Original value in input file */
 	s16 secnn;		/* section number */
 	s16 sclass;		/* symbol class */
-} ;
+};
+
+
+/*
+ * Trampoline data structures
+ */
+#define TRAMP_NO_GEN_AVAIL              65535
+#define TRAMP_SYM_PREFIX                "__$dbTR__"
+#define TRAMP_SECT_NAME                 ".dbTR"
+#define TRAMP_SYM_PREFIX_LEN            9  /*  MUST MATCH THE LENGTH ABOVE!! */
+#define TRAMP_SYM_HEX_ASCII_LEN         9  /*  Includes NULL termination  */
+
+#define GET_CONTAINER(ptr, type, field) ((type *)((unsigned long)ptr -\
+				(unsigned long)(&((type *)0)->field)))
+#ifndef FIELD_OFFSET
+#define FIELD_OFFSET(type, field)       ((unsigned long)(&((type *)0)->field))
+#endif
+
+
+/*
+    The trampoline code for the target is located in a table called
+    "tramp_gen_info" with is indexed by looking up the index in the table
+    "tramp_map".  The tramp_map index is acquired using the target
+    HASH_FUNC on the relocation type that caused the trampoline.  Each
+    trampoline code table entry MUST follow this format:
+
+    |----------------------------------------------|
+    |  tramp_gen_code_hdr                          |
+    |----------------------------------------------|
+    |  Trampoline image code                       |
+    |  (the raw instruction code for the target)   |
+    |----------------------------------------------|
+    |  Relocation entries for the image code       |
+    |----------------------------------------------|
+
+    This is very similar to how image data is laid out in the DOFF file
+    itself.
+*/
+struct tramp_gen_code_hdr {
+	u32		tramp_code_size;    /*  in BYTES  */
+	u32		num_relos;
+	u32		relo_offset;   /*  in BYTES  */
+};
+
+struct tramp_img_pkt {
+	struct tramp_img_pkt	*next;    /*  MUST BE FIRST  */
+	u32		base;
+	struct tramp_gen_code_hdr	hdr;
+	u8		payload[VARIABLE_SIZE];
+};
+
+struct tramp_img_dup_relo {
+	struct tramp_img_dup_relo	*next;
+	struct reloc_record_t	relo;
+};
+
+struct tramp_img_dup_pkt {
+	struct tramp_img_dup_pkt  *next;    /*  MUST BE FIRST  */
+	s16		secnn;
+	u32		offset;
+	struct image_packet_t                img_pkt;
+	struct tramp_img_dup_relo            *relo_chain;
+
+	/*  PAYLOAD OF IMG PKT FOLLOWS  */
+};
+
+struct tramp_sym {
+	struct tramp_sym	*next;    /*  MUST BE FIRST  */
+	u32		index;
+	u32		str_index;
+	struct Local_Symbol sym_info;
+};
+
+struct tramp_string {
+	struct tramp_string	*next;    /*  MUST BE FIRST  */
+	u32	index;
+	char    str[VARIABLE_SIZE];    /*  NULL terminated  */
+};
+
+struct tramp_info {
+	u32		tramp_sect_next_addr;
+	struct LDR_SECTION_INFO	sect_info;
+
+	struct tramp_sym		*symbol_head;
+	struct tramp_sym		*symbol_tail;
+	u32		tramp_sym_next_index;
+	struct	Local_Symbol		*final_sym_table;
+
+	struct tramp_string                *string_head;
+	struct tramp_string                *string_tail;
+	u32		tramp_string_next_index;
+	u32		tramp_string_size;
+	char		*final_string_table;
+
+	struct tramp_img_pkt		*tramp_pkts;
+	struct tramp_img_dup_pkt	*dup_pkts;
+};
 
 /*
  * States of the .cinit state machine
@@ -187,6 +283,8 @@ struct dload_state {
 	struct doff_filehdr_t dfile_hdr;	/* DOFF file header structure */
 	struct doff_verify_rec_t verify;	/* Verify record */
 
+	struct tramp_info tramp;	/* Trampoline data, if needed  */
+
 	int relstkidx;		/* index into relocation value stack */
 	/* relocation value stack used in relexp.c */
 	RVALUE relstk[STATIC_EXPR_STK_SIZE];
@@ -206,7 +304,7 @@ extern void dload_error(struct dload_state *dlthis, const char *errtxt, ...);
 extern void dload_syms_error(struct Dynamic_Loader_Sym *syms,
 			     const char *errtxt, ...);
 extern void dload_headers(struct dload_state *dlthis);
-extern void dload_strings(struct dload_state *dlthis, boolean sec_names_only);
+extern void dload_strings(struct dload_state *dlthis, bool sec_names_only);
 extern void dload_sections(struct dload_state *dlthis);
 extern void dload_reorder(void *data, int dsiz, u32 map);
 extern u32 dload_checksum(void *data, unsigned siz);
@@ -226,7 +324,8 @@ extern uint32_t dload_reverse_checksum_16(void *data, unsigned siz);
  * exported by reloc.c
  */
 extern void dload_relocate(struct dload_state *dlthis, TgtAU_t *data,
-			   struct reloc_record_t *rp);
+			struct reloc_record_t *rp, bool *tramps_generated,
+			bool second_pass);
 
 extern RVALUE dload_unpack(struct dload_state *dlthis, TgtAU_t *data,
 			   int fieldsz, int offset, unsigned sgn);
@@ -234,4 +333,24 @@ extern RVALUE dload_unpack(struct dload_state *dlthis, TgtAU_t *data,
 extern int dload_repack(struct dload_state *dlthis, RVALUE val, TgtAU_t *data,
 			int fieldsz, int offset, unsigned sgn);
 
+
+/*
+ * exported by tramp.c
+ */
+extern bool dload_tramp_avail(struct dload_state *dlthis,
+			struct reloc_record_t *rp);
+
+int dload_tramp_generate(struct dload_state *dlthis, s16 secnn,
+			u32 image_offset, struct image_packet_t *ipacket,
+			struct reloc_record_t *rp);
+
+extern int dload_tramp_pkt_udpate(struct dload_state *dlthis,
+			s16 secnn, u32 image_offset,
+			struct image_packet_t *ipacket);
+
+extern int dload_tramp_finalize(struct dload_state *dlthis);
+
+extern void dload_tramp_cleanup(struct dload_state *dlthis);
+
+
 #endif				/* __DLOAD_INTERNAL__ */
diff --git a/drivers/dsp/bridge/dynload/reloc.c b/drivers/dsp/bridge/dynload/reloc.c
index 54e460e..d4457c5 100644
--- a/drivers/dsp/bridge/dynload/reloc.c
+++ b/drivers/dsp/bridge/dynload/reloc.c
@@ -163,10 +163,10 @@ static const u8 C60_Scale[SCALE_MASK+1] = {
  *	Performs the specified relocation operation
  **************************************************************************/
 void dload_relocate(struct dload_state *dlthis, TgtAU_t *data,
-		    struct reloc_record_t *rp)
+			struct reloc_record_t *rp, bool *tramps_genereted,
+			bool second_pass)
 {
-	RVALUE val = 0;
-	RVALUE reloc_amt = 0;
+	RVALUE val, reloc_amt, orig_val = 0;
 	unsigned int fieldsz = 0;
 	unsigned int offset = 0;
 	unsigned int reloc_info = 0;
@@ -178,6 +178,17 @@ void dload_relocate(struct dload_state *dlthis, TgtAU_t *data,
 #ifdef RFV_SCALE
 	unsigned int scale = 0;
 #endif
+	struct image_packet_t *img_pkt = NULL;
+
+	/* The image packet data struct is only used during first pass
+	  * relocation in the event that a trampoline is needed.  2nd pass
+	  * relocation doesn't guarantee that data is coming from an
+	  * image_packet_t structure. See cload.c, dload_data for how i_bits is
+	  * set. If that changes this needs to be updated!!!  */
+	if (second_pass == false)
+		img_pkt = (struct image_packet_t *)((u8 *)data -
+				sizeof(struct image_packet_t));
+
 
 	rx = HASH_FUNC(rp->r_type);
 	while (rop_map1[rx] != rp->r_type) {
@@ -211,16 +222,22 @@ void dload_relocate(struct dload_state *dlthis, TgtAU_t *data,
 	/* Compute the relocation amount for the referenced symbol, if any */
 	reloc_amt = rp->r_uval;
 	if (RFV_SYM(reloc_info)) {	/* relocation uses a symbol reference */
-		if ((u32)rp->r_symndx < dlthis->dfile_hdr.df_no_syms) {
-			/* real symbol reference */
-			svp = &dlthis->local_symtab[rp->r_symndx];
-			reloc_amt = (RFV_SYM(reloc_info) == ROP_SYMD) ?
-				    svp->delta : svp->value;
+		/* If this is first pass, use the module local symbol table,
+		  * else use the trampoline symbol table.  */
+	       if (second_pass == false) {
+			if ((u32)rp->r_symndx < dlthis->dfile_hdr.df_no_syms) {
+				/* real symbol reference */
+				svp = &dlthis->local_symtab[rp->r_symndx];
+				reloc_amt = (RFV_SYM(reloc_info) == ROP_SYMD) ?
+					    svp->delta : svp->value;
+			}
+			/* reloc references current section */
+			else if (rp->r_symndx == -1) {
+				reloc_amt = (RFV_SYM(reloc_info) == ROP_SYMD) ?
+				dlthis->delta_runaddr :
+				dlthis->image_secn->run_addr;
+			}
 		}
-		/* reloc references current section */
-		else if (rp->r_symndx == -1)
-			reloc_amt = (RFV_SYM(reloc_info) == ROP_SYMD) ?
-			  dlthis->delta_runaddr : dlthis->image_secn->run_addr;
 	}	/* relocation uses a symbol reference */
 	/* Handle stack adjustment */
 	val = 0;
@@ -277,6 +294,10 @@ void dload_relocate(struct dload_state *dlthis, TgtAU_t *data,
 	if (reloc_info & ROP_R) {    /* relocation reads current image value */
 		val = dload_unpack(dlthis, data, fieldsz, offset,
 		      RFV_SIGN(reloc_info));
+	/* Save off the original value in case the relo overflows and
+	  * we can trampoline it.  */
+	orig_val = val;
+
 #ifdef RFV_SCALE
 		val <<= scale;
 #endif
@@ -414,10 +435,38 @@ void dload_relocate(struct dload_state *dlthis, TgtAU_t *data,
 #endif
 		if (dload_repack(dlthis, val, data, fieldsz, offset,
 		   RFV_SIGN(reloc_info))) {
-			dload_error(dlthis, "Relocation value " FMT_UI32
-			    " overflows %d bits in %s offset " FMT_UI32, val,
-			    fieldsz, dlthis->image_secn->name,
-			    dlthis->image_offset + rp->r_vaddr);
+			/* Check to see if this relo can be trampolined,
+			  * but only in first phase relocation.  2nd phase
+			  * relocation cannot trampoline.  */
+			if ((second_pass == false) &&
+				(dload_tramp_avail(dlthis, rp) == true)) {
+
+				/* Before generating the trampoline, restore
+				  * the value to its original so the 2nd pass
+				  *  relo will work.  */
+				dload_repack(dlthis, orig_val, data, fieldsz,
+					offset, RFV_SIGN(reloc_info));
+				if (!dload_tramp_generate(dlthis,
+					(dlthis->image_secn - dlthis->
+					ldr_sections), dlthis->image_offset,
+					img_pkt, rp)) {
+					dload_error(dlthis, "Failed to "
+					     "generate trampoline for bit "
+					     "overflow");
+					dload_error(dlthis, "Relocation value "
+					   FMT_UI32 " overflows %d bits in %s "
+					   "offset " FMT_UI32, val, fieldsz,
+					   dlthis->image_secn->name,
+					   dlthis->image_offset + rp->r_vaddr);
+				} else
+					*tramps_genereted = true;
+			} else {
+				dload_error(dlthis, "Relocation value "
+					FMT_UI32 " overflows %d bits in %s"
+					" offset " FMT_UI32, val, fieldsz,
+					dlthis->image_secn->name,
+					dlthis->image_offset + rp->r_vaddr);
+			}
 		}
 	} else if (top)
 		*stackp = val;
diff --git a/drivers/dsp/bridge/dynload/tramp.c b/drivers/dsp/bridge/dynload/tramp.c
new file mode 100644
index 0000000..8c725c7
--- /dev/null
+++ b/drivers/dsp/bridge/dynload/tramp.c
@@ -0,0 +1,1110 @@
+/*
+ *  Copyright 2009 by Texas Instruments Incorporated.
+ *  All rights reserved. Property of Texas Instruments Incorporated.
+ *  Restricted rights to use, duplicate or disclose this code are
+ *  granted through contract.
+ *
+ *  @(#) DSP/BIOS Bridge
+ */
+#include "header.h"
+
+#if TMS32060
+#include "tramp_table_c6000.c"
+#endif
+
+#define MAX_RELOS_PER_PASS	4
+
+/*
+ * Function:	priv_tramp_sect_tgt_alloc
+ * Description: Allocate target memory for the trampoline section.  The
+ *	  target mem size is easily obtained as the next available address.
+ */
+static int priv_tramp_sect_tgt_alloc(struct dload_state *dlthis)
+{
+	int ret_val = 0;
+	struct LDR_SECTION_INFO	*sect_info;
+
+	/*  Populate the trampoline loader section and allocate it on the
+	 * target.  The section name is ALWAYS the first string in the final
+	 * string table for trampolines.  The trampoline section is always
+	 * 1 beyond the total number of allocated sections.  */
+	sect_info = &dlthis->ldr_sections[dlthis->allocated_secn_count];
+
+	sect_info->name = dlthis->tramp.final_string_table;
+	sect_info->size = dlthis->tramp.tramp_sect_next_addr;
+	sect_info->context = 0;
+	sect_info->type =
+		(4 << 8) | DLOAD_TEXT | DS_ALLOCATE_MASK | DS_DOWNLOAD_MASK;
+	sect_info->page = 0;
+	sect_info->run_addr = 0;
+	sect_info->load_addr = 0;
+	ret_val = dlthis->myalloc->Allocate(dlthis->myalloc,
+			sect_info, DS_ALIGNMENT(sect_info->type));
+
+	if (ret_val == 0)
+		dload_error(dlthis, "Failed to allocate target memory for"
+							" trampoline");
+
+	return ret_val;
+}
+
+/*
+ * Function:	priv_h2a
+ * Description: Helper function to convert a hex value to its ASCII
+ *	  representation.  Used for trampoline symbol name generation.
+ */
+static u8 priv_h2a(u8 value)
+{
+	if (value > 0xF)
+		return 0xFF;
+
+	if (value <= 9)
+		value += 0x30;
+	else
+		value += 0x37;
+
+	return value;
+}
+
+/*
+ * Function:	priv_tramp_sym_gen_name
+ * Description: Generate a trampoline symbol name (ASCII) using the value
+ *	  of the symbol.  This places the new name into the user buffer.
+ *	  The name is fixed in length and of the form: __$dbTR__xxxxxxxx
+ *	  (where "xxxxxxxx" is the hex value.
+ */
+static void priv_tramp_sym_gen_name(u32 value, char *dst)
+{
+	u32 i;
+	volatile char *prefix = TRAMP_SYM_PREFIX;
+	volatile char *dst_local = dst;
+	u8 tmp;
+
+	/*  Clear out the destination, including the ending NULL  */
+	for (i = 0; i < (TRAMP_SYM_PREFIX_LEN + TRAMP_SYM_HEX_ASCII_LEN); i++)
+		*(dst_local + i) = 0;
+
+	/*  Copy the prefix to start  */
+	for (i = 0; i < strlen(TRAMP_SYM_PREFIX); i++) {
+		*dst_local = *(prefix + i);
+		dst_local++;
+	}
+
+	/*  Now convert the value passed in to a string equiv of the hex  */
+	for (i = 0; i < sizeof(value); i++) {
+#ifndef _BIG_ENDIAN
+		tmp = *(((u8 *)&value) + (sizeof(value) - 1) - i);
+		*dst_local = priv_h2a((tmp & 0xF0) >> 4);
+		dst_local++;
+		*dst_local = priv_h2a(tmp & 0x0F);
+		dst_local++;
+#else
+		tmp = *(((u8 *)&value) + i);
+		*dst_local = priv_h2a((tmp & 0xF0) >> 4);
+		dst_local++;
+		*dst_local = priv_h2a(tmp & 0x0F);
+		dst_local++;
+#endif
+	}
+
+	/*  NULL terminate  */
+	*dst_local = 0;
+}
+
+/*
+ * Function:	priv_tramp_string_create
+ * Description: Create a new string specific to the trampoline loading and add
+ *	  it to the trampoline string list.  This list contains the
+ *	  trampoline section name and trampoline point symbols.
+ */
+static struct tramp_string *priv_tramp_string_create(struct dload_state *dlthis,
+	  u32 str_len, char *str)
+{
+	struct tramp_string *new_string = NULL;
+	u32 i;
+
+	/*  Create a new string object with the specified size.  */
+	new_string = (struct tramp_string *)dlthis->mysym->Allocate(
+		dlthis->mysym, (sizeof(struct tramp_string) + str_len + 1));
+	if (new_string != NULL) {
+		/*  Clear the string first.  This ensures the ending NULL is
+		 * present and the optimizer won't touch it.  */
+		for (i = 0; i < (sizeof(struct tramp_string) + str_len + 1);
+				i++)
+			*((u8 *)new_string + i) = 0;
+
+		/*  Add this string to our virtual table by assigning it the
+		 * next index and pushing it to the tail of the list.  */
+		new_string->index = dlthis->tramp.tramp_string_next_index;
+		dlthis->tramp.tramp_string_next_index++;
+		dlthis->tramp.tramp_string_size += str_len + 1;
+
+		new_string->next = NULL;
+		if (dlthis->tramp.string_head == NULL)
+			dlthis->tramp.string_head = new_string;
+		else
+			dlthis->tramp.string_tail->next = new_string;
+
+		dlthis->tramp.string_tail = new_string;
+
+		/*  Copy the string over to the new object  */
+		for (i = 0; i < str_len; i++)
+			new_string->str[i] = str[i];
+	}
+
+	return new_string;
+}
+
+/*
+ * Function:	priv_tramp_string_find
+ * Description: Walk the trampoline string list and find a match for the
+ *	  provided string.  If not match is found, NULL is returned.
+ */
+static struct tramp_string *priv_tramp_string_find(struct dload_state *dlthis,
+								char *str)
+{
+	struct tramp_string *cur_str = NULL;
+	struct tramp_string *ret_val = NULL;
+	u32 i;
+	u32 str_len = strlen(str);
+
+	for (cur_str = dlthis->tramp.string_head;
+		 (ret_val == NULL) && (cur_str != NULL);
+		 cur_str = cur_str->next) {
+		/*  If the string lengths aren't equal, don't bother
+		 * comparing  */
+		if (str_len != strlen(cur_str->str))
+			continue;
+
+		/*  Walk the strings until one of them ends  */
+		for (i = 0; i < str_len; i++) {
+			/*  If they don't match in the current position then
+			 * break out now, no sense in continuing to look at
+			 * this string.  */
+			if (str[i] != cur_str->str[i])
+				break;
+		}
+
+		if (i == str_len)
+			ret_val = cur_str;
+	}
+
+	return ret_val;
+}
+
+/*
+ * Function:	priv_string_tbl_finalize
+ * Description: Flatten the trampoline string list into a table of NULL
+ *	  terminated strings.  This is the same format of string table
+ *	  as used by the COFF/DOFF file.
+ */
+static int priv_string_tbl_finalize(struct dload_state *dlthis)
+{
+	int ret_val = 0;
+	struct tramp_string *cur_string;
+	char *cur_loc;
+	char *tmp;
+
+	/*  Allocate enough space for all strings that have been created.  The
+	 * table is simply all strings concatenated together will NULL
+	 * endings.  */
+	dlthis->tramp.final_string_table =
+		(char *)dlthis->mysym->Allocate(dlthis->mysym,
+					dlthis->tramp.tramp_string_size);
+	if (dlthis->tramp.final_string_table != NULL) {
+		/*  We got our buffer, walk the list and release the nodes as*
+		 * we go  */
+		cur_loc = dlthis->tramp.final_string_table;
+		cur_string = dlthis->tramp.string_head;
+		while (cur_string != NULL) {
+			/*  Move the head/tail pointers  */
+			dlthis->tramp.string_head = cur_string->next;
+			if (dlthis->tramp.string_tail == cur_string)
+				dlthis->tramp.string_tail = NULL;
+
+			/*  Copy the string contents  */
+			for (tmp = cur_string->str;
+				 *tmp != '\0';
+				 tmp++, cur_loc++)
+				*cur_loc = *tmp;
+
+			/*  Pick up the NULL termination since it was missed by
+			 * breaking using it to end the above loop.  */
+			*cur_loc = '\0';
+			cur_loc++;
+
+			/*  Free the string node, we don't need it any more. */
+			dlthis->mysym->Deallocate(dlthis->mysym, cur_string);
+
+			/*  Move our pointer to the next one  */
+			cur_string = dlthis->tramp.string_head;
+		}
+
+		/*  Update our return value to success  */
+		ret_val = 1;
+	} else
+		dload_error(dlthis, "Failed to allocate trampoline "
+						"string table");
+
+	return ret_val;
+}
+
+/*
+ * Function:	priv_tramp_sect_alloc
+ * Description: Virtually allocate space from the trampoline section.  This
+ *	  function returns the next offset within the trampoline section
+ *	  that is available and moved the next available offset by the
+ *	  requested size.  NO TARGET ALLOCATION IS DONE AT THIS TIME.
+ */
+static u32 priv_tramp_sect_alloc(struct dload_state *dlthis, u32 tramp_size)
+{
+	u32 ret_val;
+
+	/*  If the next available address is 0, this is our first allocation.
+	 * Create a section name string to go into the string table .  */
+	if (dlthis->tramp.tramp_sect_next_addr == 0) {
+		dload_syms_error(dlthis->mysym, "*** WARNING ***  created "
+			"dynamic TRAMPOLINE section for module %s",
+			dlthis->str_head);
+	}
+
+	/*  Reserve space for the new trampoline  */
+	ret_val = dlthis->tramp.tramp_sect_next_addr;
+	dlthis->tramp.tramp_sect_next_addr += tramp_size;
+	return ret_val;
+}
+
+/*
+ * Function:	priv_tramp_sym_create
+ * Description: Allocate and create a new trampoline specific symbol and add
+ *	  it to the trampoline symbol list.  These symbols will include
+ *	  trampoline points as well as the external symbols they
+ *	  reference.
+ */
+static struct tramp_sym *priv_tramp_sym_create(struct dload_state *dlthis,
+			u32 str_index, struct Local_Symbol *tmp_sym)
+{
+	struct tramp_sym	*new_sym = NULL;
+	u32 i;
+
+	/*  Allocate new space for the symbol in the symbol table.  */
+	new_sym = (struct tramp_sym *)dlthis->mysym->Allocate(dlthis->mysym,
+						   sizeof(struct tramp_sym));
+	if (new_sym != NULL) {
+		for (i = 0; i != sizeof(struct tramp_sym); i++)
+			*((char *)new_sym + i) = 0;
+
+		/*  Assign this symbol the next symbol index for easier
+		 * reference later during relocation.  */
+		new_sym->index = dlthis->tramp.tramp_sym_next_index;
+		dlthis->tramp.tramp_sym_next_index++;
+
+		/*  Populate the symbol information.  At this point any
+		 * trampoline symbols will be the offset location, not the
+		 * final.  Copy over the symbol info to start, then be sure to
+		 * get the string index from the trampoline string table.  */
+		new_sym->sym_info = *tmp_sym;
+		new_sym->str_index = str_index;
+
+		/*  Push the new symbol to the tail of the symbol table list  */
+		new_sym->next = NULL;
+		if (dlthis->tramp.symbol_head == NULL)
+			dlthis->tramp.symbol_head = new_sym;
+		else
+			dlthis->tramp.symbol_tail->next = new_sym;
+
+		dlthis->tramp.symbol_tail = new_sym;
+	}
+
+	return new_sym;
+}
+
+/*
+ * Function:	priv_tramp_sym_get
+ * Description: Search for the symbol with the matching string index (from
+ *	  the trampoline string table) and return the trampoline
+ *	  symbol object, if found.  Otherwise return NULL.
+ */
+static struct tramp_sym *priv_tramp_sym_get(struct dload_state *dlthis,
+						 u32 string_index)
+{
+	struct tramp_sym *sym_found = NULL;
+
+	/*  Walk the symbol table list and search vs. the string index  */
+	for (sym_found = dlthis->tramp.symbol_head;
+		 sym_found != NULL;
+		 sym_found = sym_found->next) {
+		if (sym_found->str_index == string_index)
+			break;
+	}
+
+	return sym_found;
+}
+
+/*
+ * Function:	priv_tramp_sym_find
+ * Description: Search for a trampoline symbol based on the string name of
+ *	  the symbol.  Return the symbol object, if found, otherwise
+ *	  return NULL.
+ */
+static struct tramp_sym *priv_tramp_sym_find(struct dload_state *dlthis,
+							char *string)
+{
+	struct tramp_sym *sym_found = NULL;
+	struct tramp_string *str_found = NULL;
+
+	/*  First, search for the string, then search for the sym based on the
+		string index.  */
+	str_found = priv_tramp_string_find(dlthis, string);
+	if (str_found != NULL)
+		sym_found = priv_tramp_sym_get(dlthis, str_found->index);
+
+	return sym_found;
+}
+
+/*
+ * Function:	priv_tramp_sym_finalize
+ * Description: Allocate a flat symbol table for the trampoline section,
+ *	  put each trampoline symbol into the table, adjust the
+ *	  symbol value based on the section address on the target and
+ *	  free the trampoline symbol list nodes.
+ */
+static int priv_tramp_sym_finalize(struct dload_state *dlthis)
+{
+	int ret_val = 0;
+	struct tramp_sym *cur_sym;
+	struct LDR_SECTION_INFO *tramp_sect =
+		&dlthis->ldr_sections[dlthis->allocated_secn_count];
+	struct Local_Symbol *new_sym;
+
+	/*  Allocate a table to hold a flattened version of all symbols
+	 * created.  */
+	dlthis->tramp.final_sym_table =
+		(struct Local_Symbol *)dlthis->mysym->Allocate(
+			dlthis->mysym, (sizeof(struct Local_Symbol) *
+			dlthis->tramp.tramp_sym_next_index));
+	if (dlthis->tramp.final_sym_table != NULL) {
+		/*  Walk the list of all symbols, copy it over to the flattened
+		 * table. After it has been copied, the node can be freed as
+		 * it is no longer needed.  */
+		new_sym = dlthis->tramp.final_sym_table;
+		cur_sym = dlthis->tramp.symbol_head;
+		while (cur_sym != NULL) {
+			/*  Pop it off the list  */
+			dlthis->tramp.symbol_head = cur_sym->next;
+			if (cur_sym == dlthis->tramp.symbol_tail)
+				dlthis->tramp.symbol_tail = NULL;
+
+			/*  Copy the symbol contents into the flat table  */
+			*new_sym = cur_sym->sym_info;
+
+			/*  Now finaize the symbol.  If it is in the tramp
+			 * section, we need to adjust for the section start.
+			 * If it is external then we don't need to adjust at
+			 * all.
+			 * NOTE: THIS CODE ASSUMES THAT THE TRAMPOLINE IS
+			 * REFERENCED LIKE A CALL TO AN EXTERNAL SO VALUE AND
+			 * DELTA ARE THE SAME.  SEE THE FUNCTION dload_symbols
+			 * WHERE DN_UNDEF IS HANDLED FOR MORE REFERENCE.  */
+			if (new_sym->secnn < 0) {
+				new_sym->value += tramp_sect->load_addr;
+				new_sym->delta = new_sym->value;
+			}
+
+			/*  Let go of the symbol node  */
+			dlthis->mysym->Deallocate(dlthis->mysym, cur_sym);
+
+			/*  Move to the next node  */
+			cur_sym = dlthis->tramp.symbol_head;
+			new_sym++;
+		}
+
+		ret_val = 1;
+	} else
+		dload_error(dlthis, "Failed to alloc trampoline sym table");
+
+	return ret_val;
+}
+
+/*
+ * Function:	priv_tgt_img_gen
+ * Description: Allocate storage for and copy the target specific image data
+ *	and fix up its relocations for the new external symbol.  If
+ *	a trampoline image packet was successfully created it is added
+ *	to the trampoline list.
+ */
+static int priv_tgt_img_gen(struct dload_state *dlthis, u32 base,
+		u32 gen_index, struct tramp_sym *new_ext_sym)
+{
+	struct tramp_img_pkt *new_img_pkt = NULL;
+	u32 i;
+	u32 pkt_size = tramp_img_pkt_size_get();
+	u8 *gen_tbl_entry;
+	u8 *pkt_data;
+	struct reloc_record_t *cur_relo;
+	int ret_val = 0;
+
+	/*  Allocate a new image packet and set it up.  */
+	new_img_pkt =
+		(struct tramp_img_pkt *)dlthis->mysym->Allocate(dlthis->mysym,
+								 pkt_size);
+	if (new_img_pkt != NULL) {
+		/*  Save the base, this is where it goes in the section  */
+		new_img_pkt->base = base;
+
+		/*  Copy over the image data and relos from the target table */
+		pkt_data = (u8 *)&new_img_pkt->hdr;
+		gen_tbl_entry = (u8 *)&tramp_gen_info[gen_index];
+		for (i = 0; i < pkt_size; i++) {
+			*pkt_data = *gen_tbl_entry;
+			pkt_data++;
+			gen_tbl_entry++;
+		}
+
+		/*  Update the relocations to point to the external symbol  */
+		cur_relo =
+			(struct reloc_record_t *)((u8 *)&new_img_pkt->hdr +
+					   new_img_pkt->hdr.relo_offset);
+		for (i = 0; i < new_img_pkt->hdr.num_relos; i++)
+			cur_relo[i].r_symndx = new_ext_sym->index;
+
+		/*  Add it to the trampoline list.  */
+		new_img_pkt->next = dlthis->tramp.tramp_pkts;
+		dlthis->tramp.tramp_pkts = new_img_pkt;
+
+		ret_val = 1;
+	}
+
+	return ret_val;
+}
+
+/*
+ * Function:	priv_pkt_relo
+ * Description: Take the provided image data and the collection of relocations
+ *	  for it and perform the relocations.  Note that all relocations
+ *	  at this stage are considered SECOND PASS since the original
+ *	  image has already been processed in the first pass.  This means
+ *	  TRAMPOLINES ARE TREATED AS 2ND PASS even though this is really
+ *	  the first (and only) relocation that will be performed on them.
+ */
+static int priv_pkt_relo(struct dload_state *dlthis, TgtAU_t *data,
+			 struct reloc_record_t *rp[], u32 relo_count)
+{
+	int ret_val = 1;
+	u32 i;
+	bool tmp;
+
+	/*  Walk through all of the relos and process them.  This function is
+	 * the equivalent of relocate_packet() from cload.c, but specialized
+	 * for trampolines and 2nd phase relocations.  */
+	for (i = 0; i < relo_count; i++)
+		dload_relocate(dlthis, data, rp[i], &tmp, true);
+
+	return ret_val;
+}
+
+/*
+ * Function:	priv_tramp_pkt_finalize
+ * Description: Walk the list of all trampoline packets and finalize them.
+ *	  Each trampoline image packet will be relocated now that the
+ *	  trampoline section has been allocated on the target.  Once
+ *	  all of the relocations are done the trampoline image data
+ *	  is written into target memory and the trampoline packet
+ *	  is freed: it is no longer needed after this point.
+ */
+static int priv_tramp_pkt_finalize(struct dload_state *dlthis)
+{
+	int ret_val = 1;
+	struct tramp_img_pkt *cur_pkt = NULL;
+	struct reloc_record_t *relos[MAX_RELOS_PER_PASS];
+	u32 relos_done;
+	u32 i;
+	struct reloc_record_t *cur_relo;
+	struct LDR_SECTION_INFO *sect_info =
+		&dlthis->ldr_sections[dlthis->allocated_secn_count];
+
+	/*  Walk the list of trampoline packets and relocate each packet.  This
+	 * function is the trampoline equivalent of dload_data() from
+	 * cload.c.  */
+	cur_pkt = dlthis->tramp.tramp_pkts;
+	while ((ret_val != 0) && (cur_pkt != NULL)) {
+		/*  Remove the pkt from the list  */
+		dlthis->tramp.tramp_pkts = cur_pkt->next;
+
+		/*  Setup section and image offset information for the relo  */
+		dlthis->image_secn = sect_info;
+		dlthis->image_offset = cur_pkt->base;
+		dlthis->delta_runaddr = sect_info->run_addr;
+
+		/*  Walk through all relos for the packet  */
+		relos_done = 0;
+		cur_relo = (struct reloc_record_t *)((u8 *)&cur_pkt->hdr +
+						  cur_pkt->hdr.relo_offset);
+		while (relos_done < cur_pkt->hdr.num_relos) {
+#ifdef ENABLE_TRAMP_DEBUG
+			dload_syms_error(dlthis->mysym,
+				 "===> Trampoline %x branches to %x",
+				 sect_info->run_addr + dlthis->image_offset,
+				 dlthis->tramp.
+				 final_sym_table[cur_relo->r_symndx].value);
+#endif
+
+			for (i = 0;
+				 ((i < MAX_RELOS_PER_PASS) &&
+				  ((i + relos_done) < cur_pkt->hdr.num_relos));
+				 i++)
+				relos[i] = cur_relo + i;
+
+			/*  Do the actual relo  */
+			ret_val = priv_pkt_relo(dlthis,
+						(TgtAU_t *)&cur_pkt->payload,
+						relos, i);
+			if (ret_val == 0) {
+				dload_error(dlthis,
+				"Relocation of trampoline pkt at %x failed",
+				cur_pkt->base + sect_info->run_addr);
+				break;
+			}
+
+			relos_done += i;
+			cur_relo += i;
+		}
+
+		/*  Make sure we didn't hit a problem  */
+		if (ret_val != 0) {
+			/*  Relos are done for the packet, write it to the
+			 * target  */
+			ret_val = dlthis->myio->writemem(dlthis->myio,
+					   &cur_pkt->payload,
+					   sect_info->load_addr + cur_pkt->base
+					   , sect_info, BYTE_TO_HOST(
+					   cur_pkt->hdr.tramp_code_size));
+			if (ret_val == 0) {
+				dload_error(dlthis,
+					"Write to " FMT_UI32 " failed",
+					sect_info->load_addr + cur_pkt->base);
+			}
+
+			/*  Done with the pkt, let it go  */
+			dlthis->mysym->Deallocate(dlthis->mysym, cur_pkt);
+
+			/*  Get the next packet to process  */
+			cur_pkt = dlthis->tramp.tramp_pkts;
+		}
+	}
+
+	return ret_val;
+}
+
+/*
+ * Function:	priv_dup_pkt_finalize
+ * Description: Walk the list of duplicate image packets and finalize them.
+ *	  Each duplicate packet will be relocated again for the
+ *	  relocations that previously failed and have been adjusted
+ *	  to point at a trampoline.  Once all relocations for a packet
+ *	  have been done, write the packet into target memory.  The
+ *	  duplicate packet and its relocation chain are all freed
+ *	  after use here as they are no longer needed after this.
+ */
+static int priv_dup_pkt_finalize(struct dload_state *dlthis)
+{
+	int ret_val = 1;
+	struct tramp_img_dup_pkt *cur_pkt;
+	struct tramp_img_dup_relo *cur_relo;
+	struct reloc_record_t *relos[MAX_RELOS_PER_PASS];
+	struct doff_scnhdr_t *sect_hdr = NULL;
+	s32 i;
+
+	/* Similar to the trampoline pkt finalize, this function walks each dup
+	 * pkt that was generated and performs all relocations that were
+	 * deferred to a 2nd pass.  This is the equivalent of dload_data() from
+	 * cload.c, but does not need the additional reorder and checksum
+	 * processing as it has already been done.  */
+	cur_pkt = dlthis->tramp.dup_pkts;
+	while ((ret_val != 0) && (cur_pkt != NULL)) {
+		/*  Remove the node from the list, we'll be freeing it
+		 * shortly  */
+		dlthis->tramp.dup_pkts = cur_pkt->next;
+
+		/*  Setup the section and image offset for relocation  */
+		dlthis->image_secn = &dlthis->ldr_sections[cur_pkt->secnn];
+		dlthis->image_offset = cur_pkt->offset;
+
+		/*  In order to get the delta run address, we need to reference
+		 * the original section header.  It's a bit ugly, but needed
+		 * for relo.  */
+		i = (s32)(dlthis->image_secn - dlthis->ldr_sections);
+		sect_hdr = dlthis->sect_hdrs + i;
+		dlthis->delta_runaddr = sect_hdr->ds_paddr;
+
+		/*  Walk all relos in the chain and process each.  */
+		cur_relo = cur_pkt->relo_chain;
+		while (cur_relo != NULL) {
+			/*  Process them a chunk at a time to be efficient  */
+			for (i = 0; (i < MAX_RELOS_PER_PASS)
+				 && (cur_relo != NULL);
+				 i++, cur_relo = cur_relo->next) {
+				relos[i] = &cur_relo->relo;
+				cur_pkt->relo_chain = cur_relo->next;
+			}
+
+			/*  Do the actual relo  */
+			ret_val = priv_pkt_relo(dlthis,
+				cur_pkt->img_pkt.i_bits,
+				relos, i);
+			if (ret_val == 0) {
+				dload_error(dlthis,
+					"Relocation of dup pkt at %x failed",
+					cur_pkt->offset + dlthis->image_secn->
+					run_addr);
+				break;
+			}
+
+			/*  Release all of these relos, we're done with them */
+			while (i > 0) {
+				dlthis->mysym->Deallocate(dlthis->mysym,
+					  GET_CONTAINER(relos[i - 1],
+					struct tramp_img_dup_relo, relo));
+				i--;
+			}
+
+			/*  DO NOT ADVANCE cur_relo, IT IS ALREADY READY TO
+			 * GO!  */
+		}
+
+		/* Done with all relos.  Make sure we didn't have a problem and
+		 * write it out to the target  */
+		if (ret_val != 0) {
+			ret_val = dlthis->myio->writemem(dlthis->myio,
+				   cur_pkt->img_pkt.i_bits,
+				   dlthis->image_secn->load_addr +
+				   cur_pkt->offset, dlthis->image_secn,
+				   BYTE_TO_HOST(cur_pkt->
+				   img_pkt.i_packet_size));
+			if (ret_val == 0) {
+				dload_error(dlthis,
+					"Write to " FMT_UI32 " failed",
+					dlthis->image_secn->load_addr +
+					cur_pkt->offset);
+			}
+
+			dlthis->mysym->Deallocate(dlthis->mysym, cur_pkt);
+
+			/*  Advance to the next packet  */
+			cur_pkt = dlthis->tramp.dup_pkts;
+		}
+	}
+
+	return ret_val;
+}
+
+/*
+ * Function:	priv_dup_find
+ * Description: Walk the list of existing duplicate packets and find a
+ *	  match based on the section number and image offset.  Return
+ *	  the duplicate packet if found, otherwise NULL.
+ */
+static struct tramp_img_dup_pkt *priv_dup_find(struct dload_state *dlthis,
+					s16 secnn, u32 image_offset)
+{
+	struct tramp_img_dup_pkt *cur_pkt = NULL;
+
+	for (cur_pkt = dlthis->tramp.dup_pkts;
+		 cur_pkt != NULL;
+		 cur_pkt = cur_pkt->next) {
+		if ((cur_pkt->secnn == secnn) &&
+			(cur_pkt->offset == image_offset)) {
+			/*  Found a match, break out  */
+			break;
+		}
+	}
+
+	return cur_pkt;
+}
+
+/*
+ * Function:	priv_img_pkt_dup
+ * Description: Duplicate the original image packet.  If this is the first
+ *	  time this image packet has been seen (based on section number
+ *	  and image offset), create a new duplicate packet and add it
+ *	  to the dup packet list.  If not, just get the existing one and
+ *	  update it with the current packet contents (since relocation
+ *	  on the packet is still ongoing in first pass.)  Create a
+ *	  duplicate of the provided relocation, but update it to point
+ *	  to the new trampoline symbol.  Add the new relocation dup to
+ *	  the dup packet's relo chain for 2nd pass relocation later.
+ */
+static int priv_img_pkt_dup(struct dload_state *dlthis,
+	s16 secnn, u32 image_offset, struct image_packet_t *ipacket,
+	struct reloc_record_t *rp, struct tramp_sym *new_tramp_sym)
+{
+	struct tramp_img_dup_pkt *dup_pkt = NULL;
+	u32 new_dup_size;
+	s32 i;
+	int ret_val = 0;
+	struct tramp_img_dup_relo *dup_relo = NULL;
+
+	/*  Determinne if this image packet is already being tracked in the
+		dup list for other trampolines.  */
+	dup_pkt = priv_dup_find(dlthis, secnn, image_offset);
+
+	if (dup_pkt == NULL) {
+		/*  This image packet does not exist in our tracking, so create
+		 * a new one and add it to the head of the list.  */
+		new_dup_size = sizeof(struct tramp_img_dup_pkt) +
+						ipacket->i_packet_size;
+
+		dup_pkt = (struct tramp_img_dup_pkt *)
+			dlthis->mysym->Allocate(dlthis->mysym, new_dup_size);
+		if (dup_pkt != NULL) {
+			/*  Save off the section and offset information  */
+			dup_pkt->secnn = secnn;
+			dup_pkt->offset = image_offset;
+			dup_pkt->relo_chain = NULL;
+
+			/*  Copy the original packet content  */
+			dup_pkt->img_pkt = *ipacket;
+			dup_pkt->img_pkt.i_bits = (u8 *)(dup_pkt + 1);
+			for (i = 0; i < ipacket->i_packet_size; i++)
+				*(dup_pkt->img_pkt.i_bits + i) =
+					*(ipacket->i_bits + i);
+
+			/*  Add the packet to the dup list  */
+			dup_pkt->next = dlthis->tramp.dup_pkts;
+			dlthis->tramp.dup_pkts = dup_pkt;
+		} else
+			dload_error(dlthis, "Failed to create dup packet!");
+	} else {
+		/*  The image packet contents could have changed since
+		 * trampoline detection happens during relocation of the image
+		 * packets.  So, we need to update the image packet contents
+		 * before adding relo information.  */
+		for (i = 0; i < dup_pkt->img_pkt.i_packet_size; i++)
+			*(dup_pkt->img_pkt.i_bits + i) =
+				*(ipacket->i_bits + i);
+	}
+
+	/*  Since the previous code may have allocated a new dup packet for us,
+		double check that we actually have one.  */
+	if (dup_pkt != NULL) {
+		/*  Allocate a new node for the relo chain.  Each image packet
+		 * can potentially have multiple relocations that cause a
+		 * trampoline to be generated.  So, we keep them in a chain,
+		 * order is not important.  */
+		dup_relo = dlthis->mysym->Allocate(dlthis->mysym,
+					   sizeof(struct tramp_img_dup_relo));
+		if (dup_relo != NULL) {
+			/*  Copy the relo contents, adjust for the new
+			 * trampoline and add it to the list.  */
+			dup_relo->relo = *rp;
+			dup_relo->relo.r_symndx = new_tramp_sym->index;
+
+			dup_relo->next = dup_pkt->relo_chain;
+			dup_pkt->relo_chain = dup_relo;
+
+			/*  That's it, we're done.  Make sure we update our
+			 * return value to be success since everything finished
+			 * ok  */
+			ret_val = 1;
+		} else
+			dload_error(dlthis, "Unable to alloc dup relo");
+	}
+
+	return ret_val;
+}
+
+/*
+ * Function:	dload_tramp_avail
+ * Description: Check to see if the target supports a trampoline for this type
+ *	  of relocation.  Return true if it does, otherwise false.
+ */
+bool dload_tramp_avail(struct dload_state *dlthis, struct reloc_record_t *rp)
+{
+	bool ret_val = false;
+	u16 map_index;
+	u16 gen_index;
+
+	/*  Check type hash vs. target tramp table  */
+	map_index = HASH_FUNC(rp->r_type);
+	gen_index = tramp_map[map_index];
+	if (gen_index != TRAMP_NO_GEN_AVAIL)
+		ret_val = true;
+
+	return ret_val;
+}
+
+/*
+ * Function:	dload_tramp_generate
+ * Description: Create a new trampoline for the provided image packet and
+ *	  relocation causing problems.  This will create the trampoline
+ *	  as well as duplicate/update the image packet and relocation
+ *	  causing the problem, which will be relo'd again during
+ *	  finalization.
+ */
+int dload_tramp_generate(struct dload_state *dlthis, s16 secnn,
+	u32 image_offset, struct image_packet_t *ipacket,
+	struct reloc_record_t *rp)
+{
+	u16 map_index;
+	u16 gen_index;
+	int ret_val = 1;
+	char tramp_sym_str[TRAMP_SYM_PREFIX_LEN + TRAMP_SYM_HEX_ASCII_LEN];
+	struct Local_Symbol *ref_sym;
+	struct tramp_sym	*new_tramp_sym;
+	struct tramp_sym	*new_ext_sym;
+	struct tramp_string *new_tramp_str;
+	u32 new_tramp_base;
+	struct Local_Symbol tmp_sym;
+	struct Local_Symbol ext_tmp_sym;
+
+	/*  Hash the relo type to get our generator information  */
+	map_index = HASH_FUNC(rp->r_type);
+	gen_index = tramp_map[map_index];
+	if (gen_index != TRAMP_NO_GEN_AVAIL) {
+		/*  If this is the first trampoline, create the section name in
+		 * our string table for debug help later.  */
+		if (dlthis->tramp.string_head == NULL) {
+			priv_tramp_string_create(dlthis,
+				 strlen(TRAMP_SECT_NAME), TRAMP_SECT_NAME);
+		}
+
+#ifdef ENABLE_TRAMP_DEBUG
+		dload_syms_error(dlthis->mysym,
+			 "Trampoline at img loc %x, references %x",
+			 dlthis->ldr_sections[secnn].run_addr + image_offset +
+			 rp->r_vaddr,
+			 dlthis->local_symtab[rp->r_symndx].value);
+#endif
+
+		/*  Generate the trampoline string, check if already defined.
+		 * If the relo symbol index is -1, it means we need the section
+		 * info for relo later.  To do this we'll dummy up a symbol
+		 * with the section delta and run addresses.  */
+		if (rp->r_symndx == -1) {
+			ext_tmp_sym.value =
+				dlthis->ldr_sections[secnn].run_addr;
+			ext_tmp_sym.delta = dlthis->sect_hdrs[secnn].ds_paddr;
+			ref_sym = &ext_tmp_sym;
+		} else
+			ref_sym = &(dlthis->local_symtab[rp->r_symndx]);
+
+		priv_tramp_sym_gen_name(ref_sym->value, tramp_sym_str);
+		new_tramp_sym = priv_tramp_sym_find(dlthis, tramp_sym_str);
+		if (new_tramp_sym == NULL) {
+			/*  If tramp string not defined, create it and a new
+			 * string, and symbol for it as well as the original
+			 * symbol which caused the trampoline.  */
+			new_tramp_str = priv_tramp_string_create(dlthis,
+				 strlen(tramp_sym_str), tramp_sym_str);
+			if (new_tramp_str == NULL) {
+				dload_error(dlthis, "Failed to create new "
+					"trampoline string\n");
+				ret_val = 0;
+			} else {
+				/*  Allocate tramp section space for the new
+				 * tramp from the target  */
+				new_tramp_base = priv_tramp_sect_alloc(dlthis,
+							   tramp_size_get());
+
+				/*  We have a string, create the new symbol and
+				 * duplicate the external.  */
+				tmp_sym.value = new_tramp_base;
+				tmp_sym.delta = 0;
+				tmp_sym.secnn = -1;
+				tmp_sym.sclass = 0;
+				new_tramp_sym = priv_tramp_sym_create(dlthis,
+					  new_tramp_str->index, &tmp_sym);
+
+				new_ext_sym = priv_tramp_sym_create(dlthis,
+								-1, ref_sym);
+
+				if ((new_tramp_sym != NULL) &&
+					(new_ext_sym != NULL)) {
+					/*  Call the image generator to get the
+					 * new image data and fix up its
+					 * relocations for the external
+					 * symbol.  */
+					ret_val = priv_tgt_img_gen(dlthis,
+					   new_tramp_base, gen_index,
+					   new_ext_sym);
+
+					/*  Add generated image data to tramp
+					 * image list  */
+					if (ret_val != 1) {
+						dload_error(dlthis, "Failed to"
+						   " create image packet for "
+						   "trampoline\n");
+					}
+				} else {
+					dload_error(dlthis, "Failed to create "
+					   "new tramp syms (%8.8X, %8.8X)\n",
+					   new_tramp_sym, new_ext_sym);
+					ret_val = 0;
+				}
+			}
+		}
+
+		/*  Duplicate the image data and relo record that caused the
+		 * tramp, including update the relo data to point to the tramp
+		 * symbol.  */
+		if (ret_val == 1) {
+			ret_val = priv_img_pkt_dup(dlthis, secnn, image_offset,
+				   ipacket, rp, new_tramp_sym);
+			if (ret_val != 1) {
+				dload_error(dlthis, "Failed to create dup of "
+					"original img pkt\n");
+			}
+		}
+	}
+
+	return ret_val;
+}
+
+/*
+ * Function:	dload_tramp_pkt_update
+ * Description: Update the duplicate copy of this image packet, which the
+ *	  trampoline layer is already tracking.  This is call is critical
+ *	  to make if trampolines were generated anywhere within the
+ *	  packet and first pass relo continued on the remainder.  The
+ *	  trampoline layer needs the updates image data so when 2nd
+ *	  pass relo is done during finalize the image packet can be
+ *	  written to the target since all relo is done.
+ */
+int dload_tramp_pkt_udpate(struct dload_state *dlthis, s16 secnn,
+	   u32 image_offset, struct image_packet_t *ipacket)
+{
+	struct tramp_img_dup_pkt *dup_pkt = NULL;
+	s32 i;
+	int ret_val = 0;
+
+	/*  Find the image packet in question, the caller needs us to update it
+		since a trampoline was previously generated.  */
+	dup_pkt = priv_dup_find(dlthis, secnn, image_offset);
+	if (dup_pkt != NULL) {
+		for (i = 0; i < dup_pkt->img_pkt.i_packet_size; i++)
+			*(dup_pkt->img_pkt.i_bits + i) = *(ipacket->i_bits + i);
+
+		ret_val = 1;
+	} else {
+		dload_error(dlthis,
+			"Unable to find existing DUP pkt for %x, offset %x",
+			secnn, image_offset);
+
+	}
+
+	return ret_val;
+}
+
+/*
+ * Function:	dload_tramp_finalize
+ * Description: If any trampolines were created, finalize everything on the
+ *	  target by allocating the trampoline section on the target,
+ *	  finalizing the trampoline symbols, finalizing the trampoline
+ *	  packets (write the new section to target memory) and finalize
+ *	  the duplicate packets by doing 2nd pass relo over them.
+ */
+int dload_tramp_finalize(struct dload_state *dlthis)
+{
+	int ret_val = 1;
+
+	if (dlthis->tramp.tramp_sect_next_addr != 0) {
+		/*  Finalize strings into a flat table.  This is needed so it
+		 * can be added to the debug string table later.  */
+		ret_val = priv_string_tbl_finalize(dlthis);
+
+		/*  Do target allocation for section BEFORE finalizing
+		 * symbols.  */
+		if (ret_val != 0)
+			ret_val = priv_tramp_sect_tgt_alloc(dlthis);
+
+		/*  Finalize symbols with their correct target information and
+		 * flatten  */
+		if (ret_val != 0)
+			ret_val = priv_tramp_sym_finalize(dlthis);
+
+		/*  Finalize all trampoline packets.  This performs the
+		 * relocation on the packets as well as writing them to target
+		 * memory.  */
+		if (ret_val != 0)
+			ret_val = priv_tramp_pkt_finalize(dlthis);
+
+		/*  Perform a 2nd pass relocation on the dup list.  */
+		if (ret_val != 0)
+			ret_val = priv_dup_pkt_finalize(dlthis);
+	}
+
+	return ret_val;
+}
+
+/*
+ * Function:	dload_tramp_cleanup
+ * Description: Release all temporary resources used in the trampoline layer.
+ *	  Note that the target memory which may have been allocated and
+ *	  written to store the trampolines is NOT RELEASED HERE since it
+ *	  is potentially still in use.  It is automatically released
+ *	  when the module is unloaded.
+ */
+void dload_tramp_cleanup(struct dload_state *dlthis)
+{
+	struct tramp_info *tramp = &dlthis->tramp;
+	struct tramp_sym *cur_sym;
+	struct tramp_string *cur_string;
+	struct tramp_img_pkt *cur_tramp_pkt;
+	struct tramp_img_dup_pkt *cur_dup_pkt;
+	struct tramp_img_dup_relo *cur_dup_relo;
+
+	/*  If there were no tramps generated, just return  */
+	if (tramp->tramp_sect_next_addr == 0)
+		return;
+
+	/*  Destroy all tramp information  */
+	for (cur_sym = tramp->symbol_head;
+		 cur_sym != NULL;
+		 cur_sym = tramp->symbol_head) {
+		tramp->symbol_head = cur_sym->next;
+		if (tramp->symbol_tail == cur_sym)
+			tramp->symbol_tail = NULL;
+
+		dlthis->mysym->Deallocate(dlthis->mysym, cur_sym);
+	}
+
+	if (tramp->final_sym_table != NULL)
+		dlthis->mysym->Deallocate(dlthis->mysym,
+			tramp->final_sym_table);
+
+	for (cur_string = tramp->string_head;
+		 cur_string != NULL;
+		 cur_string = tramp->string_head) {
+		tramp->string_head = cur_string->next;
+		if (tramp->string_tail == cur_string)
+			tramp->string_tail = NULL;
+
+		dlthis->mysym->Deallocate(dlthis->mysym, cur_string);
+	}
+
+	if (tramp->final_string_table != NULL)
+		dlthis->mysym->Deallocate(dlthis->mysym,
+			tramp->final_string_table);
+
+	for (cur_tramp_pkt = tramp->tramp_pkts;
+		 cur_tramp_pkt != NULL;
+		 cur_tramp_pkt = tramp->tramp_pkts) {
+		tramp->tramp_pkts = cur_tramp_pkt->next;
+		dlthis->mysym->Deallocate(dlthis->mysym, cur_tramp_pkt);
+	}
+
+	for (cur_dup_pkt = tramp->dup_pkts;
+		 cur_dup_pkt != NULL;
+		 cur_dup_pkt = tramp->dup_pkts) {
+		tramp->dup_pkts = cur_dup_pkt->next;
+
+		for (cur_dup_relo = cur_dup_pkt->relo_chain;
+			 cur_dup_relo != NULL;
+			 cur_dup_relo = cur_dup_pkt->relo_chain) {
+			cur_dup_pkt->relo_chain = cur_dup_relo->next;
+			dlthis->mysym->Deallocate(dlthis->mysym, cur_dup_relo);
+		}
+
+		dlthis->mysym->Deallocate(dlthis->mysym, cur_dup_pkt);
+	}
+}
diff --git a/drivers/dsp/bridge/dynload/tramp_table_c6000.c b/drivers/dsp/bridge/dynload/tramp_table_c6000.c
new file mode 100644
index 0000000..1a7d974
--- /dev/null
+++ b/drivers/dsp/bridge/dynload/tramp_table_c6000.c
@@ -0,0 +1,164 @@
+/*
+ *  Copyright 2009 by Texas Instruments Incorporated.
+ *  All rights reserved. Property of Texas Instruments Incorporated.
+ *  Restricted rights to use, duplicate or disclose this code are
+ *  granted through contract.
+ *
+ *  @(#) DSP/BIOS Bridge
+ */
+#include "dload_internal.h"
+
+/*  These are defined in coff.h, but may not be available on all platforms
+	so we'll go ahead and define them here.  */
+#ifndef R_C60LO16
+#define R_C60LO16	  0x54	   /* C60: MVK Low Half Register	  */
+#define R_C60HI16	  0x55	   /* C60: MVKH/MVKLH High Half Register  */
+#endif
+
+#define C6X_TRAMP_WORD_COUNT			8
+#define C6X_TRAMP_MAX_RELOS			 8
+
+/*  THIS HASH FUNCTION MUST MATCH THE ONE IN reloc_table_c6000.c  */
+#define HASH_FUNC(zz) (((((zz) + 1) * UINT32_C(1845)) >> 11) & 63)
+
+
+/*  THIS MUST MATCH reloc_record_t FOR A SYMBOL BASED RELO  */
+struct c6000_relo_record {
+	s32 r_vaddr;
+	s32 symndx;
+#ifndef _BIG_ENDIAN
+	u16 disp;
+	u16 type;
+#else
+	u16 type;
+	u16 disp;
+#endif
+};
+
+struct c6000_gen_code {
+	struct tramp_gen_code_hdr	hdr;
+	u32 tramp_instrs[C6X_TRAMP_WORD_COUNT];
+	struct c6000_relo_record relos[C6X_TRAMP_MAX_RELOS];
+};
+
+
+/*  Hash mapping for relos that can cause trampolines.  */
+static const u16 tramp_map[] =
+{
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	0,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535,
+	65535
+};
+
+
+static const struct c6000_gen_code   tramp_gen_info[] =
+{
+	/*  Tramp caused by R_C60PCR21  */
+	{
+		/*  Header - 8 instructions, 2 relos  */
+		{
+			sizeof(u32) * C6X_TRAMP_WORD_COUNT,
+			2,
+			FIELD_OFFSET(struct c6000_gen_code, relos)
+		},
+
+		/*  Trampoline instructions  */
+		{
+			0x053C54F7,	/*	 STW.D2T2  B10, *sp--[2]  */
+			0x0500002A,	/*  || MVK.S2	<blank>, B10   */
+			0x0500006A,	/*	 MVKH.S2   <blank>, B10   */
+			0x00280362,	/*	 B.S2	  B10		*/
+			0x053C52E6,	/*	 LDW.D2T2  *++sp[2], B10  */
+			0x00006000,	/*	 NOP	   4		*/
+			0x00000000,	/*	 NOP			*/
+			0x00000000	/*	 NOP			*/
+		},
+
+		/*  Relocations  */
+		{
+			{ 4, 0, 0, R_C60LO16 },
+			{ 8, 0, 0, R_C60HI16 },
+			{ 0, 0, 0, 0x0000 },
+			{ 0, 0, 0, 0x0000 },
+			{ 0, 0, 0, 0x0000 },
+			{ 0, 0, 0, 0x0000 },
+			{ 0, 0, 0, 0x0000 },
+			{ 0, 0, 0, 0x0000 }
+		}
+	}
+};
+
+
+
+/*  TARGET SPECIFIC FUNCTIONS THAT MUST BE DEFINED  */
+static u32 tramp_size_get(void)
+{
+	return sizeof(u32) * C6X_TRAMP_WORD_COUNT;
+}
+
+
+static u32 tramp_img_pkt_size_get(void)
+{
+	return sizeof(struct c6000_gen_code);
+}
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 03/17] DSPBRIDGE: Enable/Disable MCBSP_CLOCKS for MCBSP2
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 01/17] DSPBRIDGE: Remove preproessor condition that could never work Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 02/17] DSPBRIDGE: Implemented Trampoline support for dynamic loader Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15 18:26   ` Felipe Contreras
  2009-12-15  6:19 ` [PATCH 04/17] DSPBRIDGE: set PWRERROR notifications as an option Omar Ramirez Luna
                   ` (14 subsequent siblings)
  17 siblings, 1 reply; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos, Omar Ramirez Luna

From: Fernando Guzman Lugo <x0095840@ti.com>

Enable/Disable McBSP_CLOCKS when McBSP2 is requested
so DPLL can be gated.

Signed-off-by: Fernando Guzman Lugo <x0095840@ti.com>
Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c |   73 ++++++++++++++++++++++++++++++-
 1 files changed, 72 insertions(+), 1 deletions(-)

diff --git a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
index 619ed1a..f30da74 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
@@ -361,6 +361,8 @@ DSP_STATUS DSPPeripheralClkCtrl(struct WMD_DEV_CONTEXT *pDevContext,
 	u32 dspPerClksBefore;
 	DSP_STATUS status = DSP_SOK;
 	DSP_STATUS status1 = DSP_SOK;
+	struct CFG_HOSTRES resources;
+	u32 value;
 
 	DBG_Trace(DBG_ENTER, "Entering DSPPeripheralClkCtrl \n");
 	dspPerClksBefore = pDevContext->uDspPerClks;
@@ -369,6 +371,13 @@ DSP_STATUS DSPPeripheralClkCtrl(struct WMD_DEV_CONTEXT *pDevContext,
 
 	extClk = (u32)*((u32 *)pArgs);
 
+	status = CFG_GetHostResources(
+			(struct CFG_DEVNODE *)DRV_GetFirstDevExtension(),
+			&resources);
+
+	if (DSP_FAILED(status))
+		return DSP_EFAIL;
+
 	DBG_Trace(DBG_LEVEL3, "DSPPeripheralClkCtrl : extClk+Cmd = 0x%x \n",
 		 extClk);
 
@@ -399,6 +408,17 @@ DSP_STATUS DSPPeripheralClkCtrl(struct WMD_DEV_CONTEXT *pDevContext,
 			 "DSPPeripheralClkCtrl : Disable CLK for \n");
 		status1 = CLK_Disable(BPWR_Clks[clkIdIndex].intClk);
 		status = CLK_Disable(BPWR_Clks[clkIdIndex].funClk);
+		if (BPWR_CLKID[clkIdIndex] == BPWR_MCBSP1) {
+			/* clear MCBSP1_CLKS, on McBSP1 OFF */
+			value = __raw_readl(resources.dwSysCtrlBase + 0x274);
+			value &= ~(1 << 2);
+			__raw_writel(value, resources.dwSysCtrlBase + 0x274);
+		} else if (BPWR_CLKID[clkIdIndex] == BPWR_MCBSP2) {
+			/* clear MCBSP2_CLKS, on McBSP2 OFF */
+			value = __raw_readl(resources.dwSysCtrlBase + 0x274);
+			value &= ~(1 << 6);
+			__raw_writel(value, resources.dwSysCtrlBase + 0x274);
+		}
 		DSPClkWakeupEventCtrl(BPWR_Clks[clkIdIndex].clkId, false);
 		if ((DSP_SUCCEEDED(status)) && (DSP_SUCCEEDED(status1))) {
 			(pDevContext->uDspPerClks) &=
@@ -413,6 +433,17 @@ DSP_STATUS DSPPeripheralClkCtrl(struct WMD_DEV_CONTEXT *pDevContext,
 			 "DSPPeripheralClkCtrl : Enable CLK for \n");
 		status1 = CLK_Enable(BPWR_Clks[clkIdIndex].intClk);
 		status = CLK_Enable(BPWR_Clks[clkIdIndex].funClk);
+		if (BPWR_CLKID[clkIdIndex] == BPWR_MCBSP1) {
+			/* set MCBSP1_CLKS, on McBSP1 ON */
+			value = __raw_readl(resources.dwSysCtrlBase + 0x274);
+			value |= 1 << 2;
+			__raw_writel(value, resources.dwSysCtrlBase + 0x274);
+		} else if (BPWR_CLKID[clkIdIndex] == BPWR_MCBSP2) {
+			/* set MCBSP2_CLKS, on McBSP2 ON */
+			value = __raw_readl(resources.dwSysCtrlBase + 0x274);
+			value |= 1 << 6;
+			__raw_writel(value, resources.dwSysCtrlBase + 0x274);
+		}
 		DSPClkWakeupEventCtrl(BPWR_Clks[clkIdIndex].clkId, true);
 		if ((DSP_SUCCEEDED(status)) && (DSP_SUCCEEDED(status1))) {
 			(pDevContext->uDspPerClks) |= (1 << clkIdIndex);
@@ -522,14 +553,34 @@ DSP_STATUS PostScale_DSP(struct WMD_DEV_CONTEXT *pDevContext, IN void *pArgs)
 DSP_STATUS DSP_PeripheralClocks_Disable(struct WMD_DEV_CONTEXT *pDevContext,
 					IN void *pArgs)
 {
-
 	u32 clkIdx;
 	DSP_STATUS status = DSP_SOK;
+	struct CFG_HOSTRES resources;
+	u32 value;
+
+	status = CFG_GetHostResources(
+			(struct CFG_DEVNODE *)DRV_GetFirstDevExtension(),
+			&resources);
 
 	for (clkIdx = 0; clkIdx < MBX_PM_MAX_RESOURCES; clkIdx++) {
 		if (((pDevContext->uDspPerClks) >> clkIdx) & 0x01) {
 			/* Disables the interface clock of the peripheral */
 			status = CLK_Disable(BPWR_Clks[clkIdx].intClk);
+			if (BPWR_CLKID[clkIdx] == BPWR_MCBSP1) {
+				/* clear MCBSP1_CLKS, on McBSP1 OFF */
+				value = __raw_readl(resources.dwSysCtrlBase
+								+ 0x274);
+				value &= ~(1 << 2);
+				__raw_writel(value, resources.dwSysCtrlBase
+								+ 0x274);
+			} else if (BPWR_CLKID[clkIdx] == BPWR_MCBSP2) {
+				/* clear MCBSP2_CLKS, on McBSP2 OFF */
+				value = __raw_readl(resources.dwSysCtrlBase
+								+ 0x274);
+				value &= ~(1 << 6);
+				__raw_writel(value, resources.dwSysCtrlBase
+								+ 0x274);
+			}
 			if (DSP_FAILED(status)) {
 				DBG_Trace(DBG_LEVEL7,
 					 "Failed to Enable the DSP Peripheral"
@@ -556,11 +607,31 @@ DSP_STATUS DSP_PeripheralClocks_Enable(struct WMD_DEV_CONTEXT *pDevContext,
 {
 	u32 clkIdx;
 	DSP_STATUS int_clk_status = DSP_EFAIL, fun_clk_status = DSP_EFAIL;
+	struct CFG_HOSTRES resources;
+	u32 value;
+
+	CFG_GetHostResources((struct CFG_DEVNODE *)DRV_GetFirstDevExtension(),
+			&resources);
 
 	for (clkIdx = 0; clkIdx < MBX_PM_MAX_RESOURCES; clkIdx++) {
 		if (((pDevContext->uDspPerClks) >> clkIdx) & 0x01) {
 			/* Enable the interface clock of the peripheral */
 			int_clk_status = CLK_Enable(BPWR_Clks[clkIdx].intClk);
+			if (BPWR_CLKID[clkIdx] == BPWR_MCBSP1) {
+				/* set MCBSP1_CLKS, on McBSP1 ON */
+				value = __raw_readl(resources.dwSysCtrlBase
+								+ 0x274);
+				value |= 1 << 2;
+				__raw_writel(value, resources.dwSysCtrlBase
+								+ 0x274);
+			} else if (BPWR_CLKID[clkIdx] == BPWR_MCBSP2) {
+				/* set MCBSP2_CLKS, on McBSP2 ON */
+				value = __raw_readl(resources.dwSysCtrlBase
+								+ 0x274);
+				value |= 1 << 6;
+				__raw_writel(value, resources.dwSysCtrlBase
+								+ 0x274);
+			}
 			/* Enable the functional clock of the periphearl */
 			fun_clk_status = CLK_Enable(BPWR_Clks[clkIdx].funClk);
 		}
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 04/17] DSPBRIDGE: set PWRERROR notifications as an option
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
                   ` (2 preceding siblings ...)
  2009-12-15  6:19 ` [PATCH 03/17] DSPBRIDGE: Enable/Disable MCBSP_CLOCKS for MCBSP2 Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 05/17] DSPBRIDGE: Enable peripheral clocks on wake up Omar Ramirez Luna
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos, Omar Ramirez Luna

This patch enables/disables the option to register to be
notified about bridge driver PWR errors, generally caused
because the timer expires waiting for the dsp to change from
active to retention or hibernation.

This event, if enabled, will be signaled as a fatal error,
bridge driver will be unusable until a recovery method
cleans the error state.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/Kconfig              |   11 +++++++++++
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c |    4 ++++
 drivers/dsp/bridge/wmd/ue_deh.c         |    2 ++
 3 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/drivers/dsp/bridge/Kconfig b/drivers/dsp/bridge/Kconfig
index 2fed82c..e494f02 100644
--- a/drivers/dsp/bridge/Kconfig
+++ b/drivers/dsp/bridge/Kconfig
@@ -34,3 +34,14 @@ config BRIDGE_DEBUG
 	depends on MPU_BRIDGE
 	help
 	  Say Y to enable Bridge debugging capabilities
+
+comment "Bridge Notifications"
+	depends on MPU_BRIDGE
+
+config BRIDGE_NTFY_PWRERR
+	bool "Notify DSP Power Error"
+	depends on MPU_BRIDGE
+	help
+	  Enable notifications to registered clients on the event of power errror
+	  trying to suspend bridge driver. Say Y, to signal this event as a fatal
+	  error, this will require a bridge restart to recover.
diff --git a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
index f30da74..2d7be1c 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
@@ -192,7 +192,9 @@ DSP_STATUS SleepDSP(struct WMD_DEV_CONTEXT *pDevContext, IN u32 dwCmd,
 	DSP_STATUS status = DSP_SOK;
 #ifdef CONFIG_PM
 	struct CFG_HOSTRES resources;
+#ifdef CONFIG_BRIDGE_NTFY_PWRERR
 	struct DEH_MGR *hDehMgr;
+#endif /* CONFIG_BRIDGE_NTFY_PWRERR */
 	u16 usCount = TIHELEN_ACKTIMEOUT;
 	enum HW_PwrState_t pwrState, targetPwrState;
 
@@ -267,8 +269,10 @@ DSP_STATUS SleepDSP(struct WMD_DEV_CONTEXT *pDevContext, IN u32 dwCmd,
 	if (!usCount) {
 		DBG_Trace(DBG_LEVEL7, "SleepDSP: Timed out Waiting for DSP"
 			 " STANDBY %x \n", pwrState);
+#ifdef CONFIG_BRIDGE_NTFY_PWRERR
 		DEV_GetDehMgr(pDevContext->hDevObject, &hDehMgr);
 		WMD_DEH_Notify(hDehMgr, DSP_PWRERROR, 0);
+#endif /* CONFIG_BRIDGE_NTFY_PWRERR */
 		return WMD_E_TIMEOUT;
 	} else {
 		DBG_Trace(DBG_LEVEL7, "SleepDSP: DSP STANDBY Pwr state %x \n",
diff --git a/drivers/dsp/bridge/wmd/ue_deh.c b/drivers/dsp/bridge/wmd/ue_deh.c
index 483a9c3..d6d6043 100644
--- a/drivers/dsp/bridge/wmd/ue_deh.c
+++ b/drivers/dsp/bridge/wmd/ue_deh.c
@@ -280,6 +280,7 @@ DBG_Trace(DBG_LEVEL6, "WMD_DEH_Notify: DSP_MMUFAULT, "
 			HW_MMU_EventAck(resources.dwDmmuBase,
 					 HW_MMU_TRANSLATION_FAULT);
 			break;
+#ifdef CONFIG_BRIDGE_NTFY_PWRERR
 		case DSP_PWRERROR:
 			/* reset errInfo structure before use */
 			pDehMgr->errInfo.dwErrMask = DSP_PWRERROR;
@@ -290,6 +291,7 @@ DBG_Trace(DBG_LEVEL6, "WMD_DEH_Notify: DSP_MMUFAULT, "
 			printk(KERN_ERR "WMD_DEH_Notify: DSP_PWRERROR, errInfo "
 					"= 0x%x\n", dwErrInfo);
 			break;
+#endif /* CONFIG_BRIDGE_NTFY_PWRERR */
 		default:
 			DBG_Trace(DBG_LEVEL6,
 				 "WMD_DEH_Notify: Unknown Error, errInfo = "
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 05/17] DSPBRIDGE: Enable peripheral clocks on wake up
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
                   ` (3 preceding siblings ...)
  2009-12-15  6:19 ` [PATCH 04/17] DSPBRIDGE: set PWRERROR notifications as an option Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 06/17] DSPBRIDGE: Remove long busy-wait loops on PWRST transitions Omar Ramirez Luna
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos, Omar Ramirez Luna

If enable_off_mode is not set bridge target state going into
suspend will be retention, on this path the peripheral clocks
will be disabled but not enabled again when waking the dsp up.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/wmd/tiomap_sm.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/dsp/bridge/wmd/tiomap_sm.c b/drivers/dsp/bridge/wmd/tiomap_sm.c
index 7d389e3..fe4d8b0 100644
--- a/drivers/dsp/bridge/wmd/tiomap_sm.c
+++ b/drivers/dsp/bridge/wmd/tiomap_sm.c
@@ -148,7 +148,9 @@ DSP_STATUS CHNLSM_InterruptDSP2(struct WMD_DEV_CONTEXT *pDevContext,
 		temp = *(REG_UWORD32 *)(resources.dwDmmuBase + 0x10);
 
 		pDevContext->dwBrdState = BRD_RUNNING;
-	}
+	} else if (pDevContext->dwBrdState == BRD_RETENTION)
+		/* Restart the peripheral clocks */
+		DSP_PeripheralClocks_Enable(pDevContext, NULL);
 
 	timeout = jiffies + msecs_to_jiffies(1);
 	while (fifo_full((void __iomem *) resources.dwMboxBase, 0)) {
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 06/17] DSPBRIDGE: Remove long busy-wait loops on PWRST transitions
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
                   ` (4 preceding siblings ...)
  2009-12-15  6:19 ` [PATCH 05/17] DSPBRIDGE: Enable peripheral clocks on wake up Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 07/17] DSPBRIDGE: Rename usCount to timeout Omar Ramirez Luna
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos, Omar Ramirez Luna

Remove busy waiting on suspend and self hibernation paths by
removing udelays.

Decrease the total timer waiting on power transitions to be less
than 3 seconds, defined to wait for power transition approx. 200 msecs

Change required for:
http://android.git.kernel.org/?p=kernel/omap.git;a=commit;h=c8853459b739e5f43da0badc1605a0a0c0c8195d

Reported-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Fernando Guzman Lugo <x0095840@ti.com>
Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/wmd/_tiomap_util.h   |    6 ++++++
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c |   24 +++++++++++++-----------
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/drivers/dsp/bridge/wmd/_tiomap_util.h b/drivers/dsp/bridge/wmd/_tiomap_util.h
index 47e1e5d..bd1b571 100644
--- a/drivers/dsp/bridge/wmd/_tiomap_util.h
+++ b/drivers/dsp/bridge/wmd/_tiomap_util.h
@@ -31,6 +31,12 @@
 /* Time out Values in uSeconds*/
 #define TIHELEN_ACKTIMEOUT  10000
 
+/*
+ * Time out for power state transition (in msecs), due to system
+ * latencies and HZ resolution this timer can vary.
+ */
+#define PWRSTST_TIMEOUT		200
+
 /*  Time delay for HOM->SAM transition. */
 #define  WAIT_SAM   1000000	/* in usec (1000 millisec) */
 
diff --git a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
index 2d7be1c..da59e4b 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
@@ -110,7 +110,7 @@ DSP_STATUS handle_hibernation_fromDSP(struct WMD_DEV_CONTEXT *pDevContext)
 {
 	DSP_STATUS status = DSP_SOK;
 #ifdef CONFIG_PM
-	u16 usCount = TIHELEN_ACKTIMEOUT;
+	u16 usCount = PWRSTST_TIMEOUT / 10;
 	struct CFG_HOSTRES resources;
 	enum HW_PwrState_t pwrState;
 #ifdef CONFIG_BRIDGE_DVFS
@@ -127,10 +127,12 @@ DSP_STATUS handle_hibernation_fromDSP(struct WMD_DEV_CONTEXT *pDevContext)
 
 	HW_PWR_IVA2StateGet(resources.dwPrmBase, HW_PWR_DOMAIN_DSP,
 			    &pwrState);
-	/* Wait for DSP to move into Off state,  how much time should
-	 * we wait? */
+	/* Wait for DSP to move into OFF state */
 	while ((pwrState != HW_PWR_STATE_OFF) && --usCount) {
-		udelay(500);
+		if (msleep_interruptible(10)) {
+			pr_err("Waiting for DSP OFF mode interrupted\n");
+			return DSP_EFAIL;
+		}
 		HW_PWR_IVA2StateGet(resources.dwPrmBase, HW_PWR_DOMAIN_DSP,
 				    &pwrState);
 	}
@@ -195,7 +197,7 @@ DSP_STATUS SleepDSP(struct WMD_DEV_CONTEXT *pDevContext, IN u32 dwCmd,
 #ifdef CONFIG_BRIDGE_NTFY_PWRERR
 	struct DEH_MGR *hDehMgr;
 #endif /* CONFIG_BRIDGE_NTFY_PWRERR */
-	u16 usCount = TIHELEN_ACKTIMEOUT;
+	u16 usCount = PWRSTST_TIMEOUT / 10;
 	enum HW_PwrState_t pwrState, targetPwrState;
 
 	DBG_Trace(DBG_LEVEL7, "SleepDSP- Enter function \n");
@@ -256,12 +258,12 @@ DSP_STATUS SleepDSP(struct WMD_DEV_CONTEXT *pDevContext, IN u32 dwCmd,
 	HW_PWR_IVA2StateGet(resources.dwPrmBase, HW_PWR_DOMAIN_DSP,
 			&pwrState);
 
-	/*
-	 * Wait for DSP to move into Standby state,  how much time
-	 * should we wait?
-	 */
-	while ((pwrState != targetPwrState) && --usCount) {
-		udelay(500);
+	/* Wait for DSP to move into target power state */
+	while ((pwrState != targetPwrState) && usCount--) {
+		if (msleep_interruptible(10)) {
+			pr_err("Waiting for DSP to Suspend interrupted\n");
+			return DSP_EFAIL;
+		}
 		HW_PWR_IVA2StateGet(resources.dwPrmBase, HW_PWR_DOMAIN_DSP,
 				    &pwrState);
 	}
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 07/17] DSPBRIDGE: Rename usCount to timeout
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
                   ` (5 preceding siblings ...)
  2009-12-15  6:19 ` [PATCH 06/17] DSPBRIDGE: Remove long busy-wait loops on PWRST transitions Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 08/17] DSPBRIDGE: Trivial cleanup on DBDCD Omar Ramirez Luna
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos, Omar Ramirez Luna

Rename usCount to timeout

Reported-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/wmd/tiomap3430.c     |    6 +++---
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c |   12 ++++++------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/dsp/bridge/wmd/tiomap3430.c b/drivers/dsp/bridge/wmd/tiomap3430.c
index 018a5f4..65a21b2 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430.c
@@ -2089,14 +2089,14 @@ void configureDspMmu(struct WMD_DEV_CONTEXT *pDevContext, u32 dataBasePhys,
  */
 bool WaitForStart(struct WMD_DEV_CONTEXT *pDevContext, u32 dwSyncAddr)
 {
-	u16 usCount = TIHELEN_ACKTIMEOUT;
+	u16 timeout = TIHELEN_ACKTIMEOUT;
 
 	/*  Wait for response from board */
-	while (*((volatile u16 *)dwSyncAddr) && --usCount)
+	while (*((volatile u16 *)dwSyncAddr) && --timeout)
 		udelay(10);
 
 	/*  If timed out: return FALSE */
-	if (!usCount) {
+	if (!timeout) {
 		DBG_Trace(DBG_LEVEL7, "Timed out Waiting for DSP to Start\n");
 		return FALSE;
 	}
diff --git a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
index da59e4b..ea299a0 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
@@ -110,7 +110,7 @@ DSP_STATUS handle_hibernation_fromDSP(struct WMD_DEV_CONTEXT *pDevContext)
 {
 	DSP_STATUS status = DSP_SOK;
 #ifdef CONFIG_PM
-	u16 usCount = PWRSTST_TIMEOUT / 10;
+	u16 timeout = PWRSTST_TIMEOUT / 10;
 	struct CFG_HOSTRES resources;
 	enum HW_PwrState_t pwrState;
 #ifdef CONFIG_BRIDGE_DVFS
@@ -128,7 +128,7 @@ DSP_STATUS handle_hibernation_fromDSP(struct WMD_DEV_CONTEXT *pDevContext)
 	HW_PWR_IVA2StateGet(resources.dwPrmBase, HW_PWR_DOMAIN_DSP,
 			    &pwrState);
 	/* Wait for DSP to move into OFF state */
-	while ((pwrState != HW_PWR_STATE_OFF) && --usCount) {
+	while ((pwrState != HW_PWR_STATE_OFF) && --timeout) {
 		if (msleep_interruptible(10)) {
 			pr_err("Waiting for DSP OFF mode interrupted\n");
 			return DSP_EFAIL;
@@ -136,7 +136,7 @@ DSP_STATUS handle_hibernation_fromDSP(struct WMD_DEV_CONTEXT *pDevContext)
 		HW_PWR_IVA2StateGet(resources.dwPrmBase, HW_PWR_DOMAIN_DSP,
 				    &pwrState);
 	}
-	if (usCount == 0) {
+	if (timeout == 0) {
 		DBG_Trace(DBG_LEVEL7, "Timed out Waiting for DSP Off mode \n");
 		status = WMD_E_TIMEOUT;
 		return status;
@@ -197,7 +197,7 @@ DSP_STATUS SleepDSP(struct WMD_DEV_CONTEXT *pDevContext, IN u32 dwCmd,
 #ifdef CONFIG_BRIDGE_NTFY_PWRERR
 	struct DEH_MGR *hDehMgr;
 #endif /* CONFIG_BRIDGE_NTFY_PWRERR */
-	u16 usCount = PWRSTST_TIMEOUT / 10;
+	u16 timeout = PWRSTST_TIMEOUT / 10;
 	enum HW_PwrState_t pwrState, targetPwrState;
 
 	DBG_Trace(DBG_LEVEL7, "SleepDSP- Enter function \n");
@@ -259,7 +259,7 @@ DSP_STATUS SleepDSP(struct WMD_DEV_CONTEXT *pDevContext, IN u32 dwCmd,
 			&pwrState);
 
 	/* Wait for DSP to move into target power state */
-	while ((pwrState != targetPwrState) && usCount--) {
+	while ((pwrState != targetPwrState) && timeout--) {
 		if (msleep_interruptible(10)) {
 			pr_err("Waiting for DSP to Suspend interrupted\n");
 			return DSP_EFAIL;
@@ -268,7 +268,7 @@ DSP_STATUS SleepDSP(struct WMD_DEV_CONTEXT *pDevContext, IN u32 dwCmd,
 				    &pwrState);
 	}
 
-	if (!usCount) {
+	if (!timeout) {
 		DBG_Trace(DBG_LEVEL7, "SleepDSP: Timed out Waiting for DSP"
 			 " STANDBY %x \n", pwrState);
 #ifdef CONFIG_BRIDGE_NTFY_PWRERR
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 08/17] DSPBRIDGE: Trivial cleanup on DBDCD
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
                   ` (6 preceding siblings ...)
  2009-12-15  6:19 ` [PATCH 07/17] DSPBRIDGE: Rename usCount to timeout Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 09/17] DSPBRIDGE: Do not panic on bad page count Omar Ramirez Luna
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos, Omar Ramirez Luna

Trivial spacing cleanup on DSP/BIOS Bridge Configuration
Database module.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/rmgr/dbdcd.c |  343 ++++++++++++++++++++-------------------
 1 files changed, 179 insertions(+), 164 deletions(-)

diff --git a/drivers/dsp/bridge/rmgr/dbdcd.c b/drivers/dsp/bridge/rmgr/dbdcd.c
index fb4a9a6..b1391e2 100644
--- a/drivers/dsp/bridge/rmgr/dbdcd.c
+++ b/drivers/dsp/bridge/rmgr/dbdcd.c
@@ -31,32 +31,32 @@
  *! ================
  *! 03-Dec-2003 map Changed DCD_OBJTYPE to DSP_DCDOBJTYPE
  *! 17-Dec-2002 map Modified DCD_GetDepLibs, DCD_GetNumDepLibs, GetDepLibInfo
- *!                 to include phase information
+ *!		 to include phase information
  *! 02-Dec-2002 map Modified DCD_GetLibraryName for phases in different
- *!                 libraries
+ *!		 libraries
  *! 26-Feb-2003 kc  Updated DCD_AutoUnregister and DCD_GetObjects to simplify
- *!                 DCD implementation.
+ *!		 DCD implementation.
  *! 17-Jul-2002 jeh Call COD_Open() instead of COD_OpenBase(), call COD_Close()
  *! 11-Jul-2002 jeh Added DCD_GetDepLibs(), DCD_GetNumDepLibs().
  *! 18-Feb-2003 vp  Code review updates
  *! 18-Oct-2002 vp  Ported to Linux platform
  *! 15-Mar-2002 jeh Read dynamic loading memory requirements into node object
- *!                 data. Added DCD_GetLibraryName().
+ *!		 data. Added DCD_GetLibraryName().
  *! 13-Feb-2002 jeh Get system stack size in GetAttrsFromBuf().
  *! 01-Aug-2001 ag: Added check for PROC "extended" attributes used for
- *!                    DSP-MMU setup. These are private attributes.
+ *!		    DSP-MMU setup. These are private attributes.
  *! 18-Apr-2001 jeh Use COD_OpenBase instead of COD_LoadBase.
  *! 03-Apr-2001 sg: Changed error names to DSP_EDCD* format.
  *! 11-Jan-2001 jeh Changes to DCD_GetObjectDef to match node.cdb, proc.cdb.
  *! 12-Dec-2000 kc: Added DCD_AutoUnregister. MSGNODE, DAISNODE added in
- *!                 GetAttrsFromBuf
+ *!		 GetAttrsFromBuf
  *! 22-Nov-2000 kc: Replaced sprintf() calls with strncat.
  *! 09-Nov-2000 kc: Optimized DCD module.
  *! 30-Oct-2000 kc: Added DCD_AutoRegister function; changed local var. names.
  *! 29-Sep-2000 kc: Added code review changes (src/reviews/dcd_reviews.txt).
  *! 06-Sep-2000 jeh Get message segid, message notification type. Added Atoi()
- *!                 to replace atoi(), until cdb generation can output in
- *!                 decimal format.
+ *!		 to replace atoi(), until cdb generation can output in
+ *!		 decimal format.
  *! 26-Jul-2000 kc: Created.
  *!
  */
@@ -88,12 +88,12 @@
 /*  ----------------------------------- Global defines. */
 #define SIGNATURE       0x5f444344	/* "DCD_" (in reverse). */
 
-#define IsValidHandle(h)    (((h) != NULL) && (h->dwSignature == SIGNATURE))
+#define IsValidHandle(h)	(((h) != NULL) && (h->dwSignature == SIGNATURE))
 
 #define MAX_INT2CHAR_LENGTH     16   /* Maximum int2char len of 32 bit int. */
 
 /* Name of section containing dependent libraries */
-#define DEPLIBSECT              ".dspbridge_deplibs"
+#define DEPLIBSECT		".dspbridge_deplibs"
 
 /* DCD specific structures. */
 struct DCD_MANAGER {
@@ -107,17 +107,13 @@ static u32 cEnumRefs;
 
 extern struct GT_Mask curTrace;
 
-/* helper function prototypes. */
+/* Helper function prototypes. */
 static s32 Atoi(char *pszBuf);
-
 static DSP_STATUS GetAttrsFromBuf(char *pszBuf, u32 ulBufSize,
 				  enum DSP_DCDOBJTYPE objType,
 				  struct DCD_GENERICOBJ *pGenObj);
-
 static void CompressBuf(char *pszBuf, u32 ulBufSize, s32 cCharSize);
-
 static char DspChar2GppChar(char *pWord, s32 cDspCharSize);
-
 static DSP_STATUS GetDepLibInfo(IN struct DCD_MANAGER *hDcdMgr,
 				IN struct DSP_UUID *pUuid,
 				IN OUT u16 *pNumLibs,
@@ -131,9 +127,8 @@ static DSP_STATUS GetDepLibInfo(IN struct DCD_MANAGER *hDcdMgr,
  *  Purpose:
  *      Parses the supplied image and resigsters with DCD.
  */
-
 DSP_STATUS DCD_AutoRegister(IN struct DCD_MANAGER *hDcdMgr,
-			    IN char *pszCoffPath)
+				IN char *pszCoffPath)
 {
 	DSP_STATUS status = DSP_SOK;
 
@@ -161,7 +156,7 @@ DSP_STATUS DCD_AutoRegister(IN struct DCD_MANAGER *hDcdMgr,
  *      Parses the supplied DSP image and unresiters from DCD.
  */
 DSP_STATUS DCD_AutoUnregister(IN struct DCD_MANAGER *hDcdMgr,
-			     IN char *pszCoffPath)
+				IN char *pszCoffPath)
 {
 	DSP_STATUS status = DSP_SOK;
 
@@ -172,8 +167,7 @@ DSP_STATUS DCD_AutoUnregister(IN struct DCD_MANAGER *hDcdMgr,
 
 	if (IsValidHandle(hDcdMgr)) {
 		status = DCD_GetObjects(hDcdMgr, pszCoffPath,
-				       (DCD_REGISTERFXN)DCD_RegisterObject,
-				       NULL);
+				(DCD_REGISTERFXN)DCD_RegisterObject, NULL);
 	} else {
 		status = DSP_EHANDLE;
 		GT_0trace(curTrace, GT_6CLASS,
@@ -190,9 +184,9 @@ DSP_STATUS DCD_AutoUnregister(IN struct DCD_MANAGER *hDcdMgr,
  *      Creates DCD manager.
  */
 DSP_STATUS DCD_CreateManager(IN char *pszZlDllName,
-			    OUT struct DCD_MANAGER **phDcdMgr)
+				OUT struct DCD_MANAGER **phDcdMgr)
 {
-	struct COD_MANAGER *hCodMgr;	/* COD manager handle */
+	struct COD_MANAGER *hCodMgr;		/* COD manager handle */
 	struct DCD_MANAGER *pDcdMgr = NULL;	/* DCD Manager pointer */
 	DSP_STATUS status = DSP_SOK;
 
@@ -203,43 +197,44 @@ DSP_STATUS DCD_CreateManager(IN char *pszZlDllName,
 		 phDcdMgr);
 
 	status = COD_Create(&hCodMgr, pszZlDllName, NULL);
-	if (DSP_SUCCEEDED(status)) {
 
-		/* Create a DCD object. */
-		MEM_AllocObject(pDcdMgr, struct DCD_MANAGER, SIGNATURE);
-		if (pDcdMgr != NULL) {
+	if (DSP_FAILED(status)) {
+		status = DSP_EFAIL;
+		GT_0trace(curTrace, GT_6CLASS,
+			 "DCD_CreateManager: COD_Create failed\n");
+		goto func_end;
+	}
 
-			/* Fill out the object. */
-			pDcdMgr->hCodMgr = hCodMgr;
+	/* Create a DCD object. */
+	MEM_AllocObject(pDcdMgr, struct DCD_MANAGER, SIGNATURE);
+	if (pDcdMgr != NULL) {
+		/* Fill out the object. */
+		pDcdMgr->hCodMgr = hCodMgr;
 
-			/* Return handle to this DCD interface. */
-			*phDcdMgr = pDcdMgr;
+		/* Return handle to this DCD interface. */
+		*phDcdMgr = pDcdMgr;
 
-			GT_2trace(curTrace, GT_5CLASS,
-				 "DCD_CreateManager: pDcdMgr 0x%x, "
-				 " hCodMgr 0x%x", pDcdMgr, hCodMgr);
-		} else {
-			status = DSP_EMEMORY;
+		GT_2trace(curTrace, GT_5CLASS,
+			 "DCD_CreateManager: pDcdMgr 0x%x, "
+			 " hCodMgr 0x%x", pDcdMgr, hCodMgr);
+	} else {
+		status = DSP_EMEMORY;
 
-			/*
-			 * If allocation of DcdManager object failed, delete the
-			 * COD manager.
-			 */
-			COD_Delete(hCodMgr);
+		/*
+		 * If allocation of DcdManager object failed, delete the
+		 * COD manager.
+		 */
+		COD_Delete(hCodMgr);
 
-			GT_0trace(curTrace, GT_6CLASS,
-				 "DCD_CreateManager: MEM_AllocObject failed\n");
-		}
-	} else {
-		status = DSP_EFAIL;
 		GT_0trace(curTrace, GT_6CLASS,
-			 "DCD_CreateManager: COD_Create failed\n");
+			 "DCD_CreateManager: MEM_AllocObject failed\n");
 	}
 
 	DBC_Ensure((DSP_SUCCEEDED(status)) || ((hCodMgr == NULL) &&
-		  (status == DSP_EFAIL)) || ((pDcdMgr == NULL) &&
-		  (status == DSP_EMEMORY)));
+			(status == DSP_EFAIL)) || ((pDcdMgr == NULL) &&
+			(status == DSP_EMEMORY)));
 
+func_end:
 	return status;
 }
 
@@ -259,7 +254,6 @@ DSP_STATUS DCD_DestroyManager(IN struct DCD_MANAGER *hDcdMgr)
 		 hDcdMgr);
 
 	if (IsValidHandle(hDcdMgr)) {
-
 		/* Delete the COD manager. */
 		COD_Delete(pDcdMgr->hCodMgr);
 
@@ -317,15 +311,15 @@ DSP_STATUS DCD_EnumerateObject(IN s32 cIndex, IN enum DSP_DCDOBJTYPE objType,
 		 * Pre-determine final key length. It's length of DCD_REGKEY +
 		 *  "_\0" + length of szObjType string + terminating NULL.
 		 */
-               dwKeyLen = strlen(DCD_REGKEY) + 1 + sizeof(szObjType) + 1;
+		dwKeyLen = strlen(DCD_REGKEY) + 1 + sizeof(szObjType) + 1;
 		DBC_Assert(dwKeyLen < REG_MAXREGPATHLENGTH);
 
 		/* Create proper REG key; concatenate DCD_REGKEY with
 		 * objType. */
-               strncpy(szRegKey, DCD_REGKEY, strlen(DCD_REGKEY) + 1);
-               if ((strlen(szRegKey) + strlen("_\0")) <
+		strncpy(szRegKey, DCD_REGKEY, strlen(DCD_REGKEY) + 1);
+		if ((strlen(szRegKey) + strlen("_\0")) <
 		   REG_MAXREGPATHLENGTH) {
-                       strncat(szRegKey, "_\0", 2);
+			strncat(szRegKey, "_\0", 2);
 		} else {
 			status = DSP_EFAIL;
 		}
@@ -339,10 +333,10 @@ DSP_STATUS DCD_EnumerateObject(IN s32 cIndex, IN enum DSP_DCDOBJTYPE objType,
 			status = DSP_EFAIL;
 		} else {
 			status = DSP_SOK;
-                       if ((strlen(szRegKey) + strlen(szObjType)) <
+			if ((strlen(szRegKey) + strlen(szObjType)) <
 			   REG_MAXREGPATHLENGTH) {
-                               strncat(szRegKey, szObjType,
-                                          strlen(szObjType) + 1);
+				strncat(szRegKey, szObjType,
+					strlen(szObjType) + 1);
 			} else {
 				status = DSP_EFAIL;
 			}
@@ -447,7 +441,7 @@ DSP_STATUS DCD_GetNumDepLibs(IN struct DCD_MANAGER *hDcdMgr,
 		 hDcdMgr);
 
 	status = GetDepLibInfo(hDcdMgr, pUuid, pNumLibs, pNumPersLibs,
-			      NULL, NULL, phase);
+				NULL, NULL, phase);
 
 	return status;
 }
@@ -459,9 +453,9 @@ DSP_STATUS DCD_GetNumDepLibs(IN struct DCD_MANAGER *hDcdMgr,
  *      object type.
  */
 DSP_STATUS DCD_GetObjectDef(IN struct DCD_MANAGER *hDcdMgr,
-			   IN struct DSP_UUID *pObjUuid,
-			   IN enum DSP_DCDOBJTYPE objType,
-			   OUT struct DCD_GENERICOBJ *pObjDef)
+			IN struct DSP_UUID *pObjUuid,
+			IN enum DSP_DCDOBJTYPE objType,
+			OUT struct DCD_GENERICOBJ *pObjDef)
 {
 	struct DCD_MANAGER *pDcdMgr = hDcdMgr;	/* pointer to DCD manager */
 	struct COD_LIBRARYOBJ *lib = NULL;
@@ -495,15 +489,17 @@ DSP_STATUS DCD_GetObjectDef(IN struct DCD_MANAGER *hDcdMgr,
 			 "DCD manager handle.\n");
 		goto func_end;
 	}
-	 /* Pre-determine final key length. It's length of DCD_REGKEY +
+
+	/* Pre-determine final key length. It's length of DCD_REGKEY +
 	 *  "_\0" + length of szObjType string + terminating NULL */
-       dwKeyLen = strlen(DCD_REGKEY) + 1 + sizeof(szObjType) + 1;
+	dwKeyLen = strlen(DCD_REGKEY) + 1 + sizeof(szObjType) + 1;
 	DBC_Assert(dwKeyLen < REG_MAXREGPATHLENGTH);
+
 	/* Create proper REG key; concatenate DCD_REGKEY with objType. */
-       strncpy(szRegKey, DCD_REGKEY, strlen(DCD_REGKEY) + 1);
+	strncpy(szRegKey, DCD_REGKEY, strlen(DCD_REGKEY) + 1);
 
-       if ((strlen(szRegKey) + strlen("_\0")) < REG_MAXREGPATHLENGTH)
-               strncat(szRegKey, "_\0", 2);
+	if ((strlen(szRegKey) + strlen("_\0")) < REG_MAXREGPATHLENGTH)
+		strncat(szRegKey, "_\0", 2);
 	else
 		status = DSP_EFAIL;
 
@@ -513,32 +509,34 @@ DSP_STATUS DCD_GetObjectDef(IN struct DCD_MANAGER *hDcdMgr,
 	} else {
 		status = DSP_SOK;
 
-               if ((strlen(szRegKey) + strlen(szObjType)) <
+		if ((strlen(szRegKey) + strlen(szObjType)) <
 		   REG_MAXREGPATHLENGTH) {
-                       strncat(szRegKey, szObjType, strlen(szObjType) + 1);
+			strncat(szRegKey, szObjType, strlen(szObjType) + 1);
 		} else {
 			status = DSP_EFAIL;
 		}
+
 		/* Create UUID value to set in registry. */
 		UUID_UuidToString(pObjUuid, szUuid, MAXUUIDLEN);
 
-               if ((strlen(szRegKey) + MAXUUIDLEN) < REG_MAXREGPATHLENGTH)
-                       strncat(szRegKey, szUuid, MAXUUIDLEN);
-               else
+		if ((strlen(szRegKey) + MAXUUIDLEN) < REG_MAXREGPATHLENGTH)
+			strncat(szRegKey, szUuid, MAXUUIDLEN);
+		else
 			status = DSP_EFAIL;
 
 		/* Retrieve paths from the registry based on struct DSP_UUID */
 		dwBufSize = REG_MAXREGPATHLENGTH;
 	}
-	if (DSP_SUCCEEDED(status)) {
+	if (DSP_SUCCEEDED(status))
 		status = REG_GetValue(szRegKey, (u8 *)szRegData, &dwBufSize);
-	}
+
 	if (DSP_FAILED(status)) {
 		status = DSP_EUUID;
 		GT_0trace(curTrace, GT_6CLASS, "DCD_GetObjectDef: "
 			 "REG_GetValue() failed\n");
 		goto func_end;
 	}
+
 	/* Open COFF file. */
 	status = COD_Open(pDcdMgr->hCodMgr, szRegData, COD_NOLOAD, &lib);
 	if (DSP_FAILED(status)) {
@@ -547,13 +545,16 @@ DSP_STATUS DCD_GetObjectDef(IN struct DCD_MANAGER *hDcdMgr,
 			 "COD_OpenBase() failed\n");
 		goto func_end;
 	}
+
 	/* Ensure szUuid + 1 is not greater than sizeof szSectName. */
-       DBC_Assert((strlen(szUuid) + 1) < sizeof(szSectName));
+	DBC_Assert((strlen(szUuid) + 1) < sizeof(szSectName));
+
 	/* Create section name based on node UUID. A period is
 	 * pre-pended to the UUID string to form the section name.
 	 * I.e. ".24BC8D90_BB45_11d4_B756_006008BDB66F" */
-       strncpy(szSectName, ".", 2);
-       strncat(szSectName, szUuid, strlen(szUuid));
+	strncpy(szSectName, ".", 2);
+	strncat(szSectName, szUuid, strlen(szUuid));
+
 	/* Get section information. */
 	status = COD_GetSection(lib, szSectName, &ulAddr, &ulLen);
 	if (DSP_FAILED(status)) {
@@ -562,10 +563,11 @@ DSP_STATUS DCD_GetObjectDef(IN struct DCD_MANAGER *hDcdMgr,
 			 " COD_GetSection() failed\n");
 		goto func_end;
 	}
+
 	/* Allocate zeroed buffer. */
 	pszCoffBuf = MEM_Calloc(ulLen + 4, MEM_PAGED);
 #ifdef _DB_TIOMAP
-       if (strstr(szRegData, "iva") == NULL) {
+	if (strstr(szRegData, "iva") == NULL) {
 		/* Locate section by objectID and read its content. */
 		status = COD_ReadSection(lib, szSectName, pszCoffBuf, ulLen);
 	} else {
@@ -578,13 +580,14 @@ DSP_STATUS DCD_GetObjectDef(IN struct DCD_MANAGER *hDcdMgr,
 #endif
 	if (DSP_SUCCEEDED(status)) {
 		/* Compres DSP buffer to conform to PC format. */
-               if (strstr(szRegData, "iva") == NULL) {
+		if (strstr(szRegData, "iva") == NULL) {
 			CompressBuf(pszCoffBuf, ulLen, DSPWORDSIZE);
 		} else {
 			CompressBuf(pszCoffBuf, ulLen, 1);
 			GT_0trace(curTrace, GT_4CLASS, "Compressing IVA "
 				 "COFF buffer by 1 for IVA !!\n");
 		}
+
 		/* Parse the content of the COFF buffer. */
 		status = GetAttrsFromBuf(pszCoffBuf, ulLen, objType, pObjDef);
 		if (DSP_FAILED(status)) {
@@ -597,6 +600,7 @@ DSP_STATUS DCD_GetObjectDef(IN struct DCD_MANAGER *hDcdMgr,
 		GT_0trace(curTrace, GT_6CLASS, "DCD_GetObjectDef: "
 			 "COD_ReadSection() failed\n");
 	}
+
 	/* Free the previously allocated dynamic buffer. */
 	MEM_Free(pszCoffBuf);
 func_end:
@@ -605,6 +609,7 @@ func_end:
 
 	if (szUuid)
 		MEM_Free(szUuid);
+
 	return status;
 }
 
@@ -635,6 +640,7 @@ DSP_STATUS DCD_GetObjects(IN struct DCD_MANAGER *hDcdMgr, IN char *pszCoffPath,
 			 "DCD_GetObjects: invalid DCD manager handle.\n");
 		goto func_end;
 	}
+
 	/* Open DSP coff file, don't load symbols. */
 	status = COD_Open(pDcdMgr->hCodMgr, pszCoffPath, COD_NOLOAD, &lib);
 	if (DSP_FAILED(status)) {
@@ -643,6 +649,7 @@ DSP_STATUS DCD_GetObjects(IN struct DCD_MANAGER *hDcdMgr, IN char *pszCoffPath,
 			 "DCD_AutoRegister: COD_Open() failed\n");
 		goto func_cont;
 	}
+
 	/* Get DCD_RESIGER_SECTION section information. */
 	status = COD_GetSection(lib, DCD_REGISTER_SECTION, &ulAddr, &ulLen);
 	if (DSP_FAILED(status) ||  !(ulLen > 0)) {
@@ -652,6 +659,7 @@ DSP_STATUS DCD_GetObjects(IN struct DCD_MANAGER *hDcdMgr, IN char *pszCoffPath,
 			 "- no auto register section\n");
 		goto func_cont;
 	}
+
 	/* Allocate zeroed buffer. */
 	pszCoffBuf = MEM_Calloc(ulLen + 4, MEM_PAGED);
 #ifdef _DB_TIOMAP
@@ -678,15 +686,19 @@ DSP_STATUS DCD_GetObjects(IN struct DCD_MANAGER *hDcdMgr, IN char *pszCoffPath,
 			GT_0trace(curTrace, GT_4CLASS, "Compress COFF buffer "
 				 "with 1 word for IVA !!\n");
 		}
+
 		/* Read from buffer and register object in buffer. */
 		pszCur = pszCoffBuf;
 		while ((pToken = strsep(&pszCur, seps)) && *pToken != '\0') {
 			/*  Retrieve UUID string. */
 			UUID_UuidFromString(pToken, &dspUuid);
+
 			/*  Retrieve object type */
 			pToken = strsep(&pszCur, seps);
+
 			/*  Retrieve object type */
 			cObjectType = Atoi(pToken);
+
 			/*
 			 *  Apply registerFxn to the found DCD object.
 			 *  Possible actions include:
@@ -715,6 +727,7 @@ DSP_STATUS DCD_GetObjects(IN struct DCD_MANAGER *hDcdMgr, IN char *pszCoffPath,
 		GT_0trace(curTrace, GT_6CLASS, "DCD_GetObjects: "
 			 "COD_ReadSection() failed\n");
 	}
+
 	/* Free the previously allocated dynamic buffer. */
 	MEM_Free(pszCoffBuf);
 func_cont:
@@ -732,9 +745,9 @@ func_end:
  *
  */
 DSP_STATUS DCD_GetLibraryName(IN struct DCD_MANAGER *hDcdMgr,
-			     IN struct DSP_UUID *pUuid,
-			     IN OUT char *pstrLibName, IN OUT u32 *pdwSize,
-			     enum NLDR_PHASE phase, OUT bool *fPhaseSplit)
+			IN struct DSP_UUID *pUuid,
+			IN OUT char *pstrLibName, IN OUT u32 *pdwSize,
+			enum NLDR_PHASE phase, OUT bool *fPhaseSplit)
 {
 	char szRegKey[REG_MAXREGPATHLENGTH];
 	char szUuid[MAXUUIDLEN];
@@ -751,16 +764,18 @@ DSP_STATUS DCD_GetLibraryName(IN struct DCD_MANAGER *hDcdMgr,
 		 "DCD_GetLibraryName: hDcdMgr 0x%x, pUuid 0x%x, "
 		 " pstrLibName 0x%x, pdwSize 0x%x\n", hDcdMgr, pUuid,
 		 pstrLibName, pdwSize);
+
 	/*
 	 *  Pre-determine final key length. It's length of DCD_REGKEY +
 	 *  "_\0" + length of szObjType string + terminating NULL.
 	 */
-       dwKeyLen = strlen(DCD_REGKEY) + 1 + sizeof(szObjType) + 1;
+	dwKeyLen = strlen(DCD_REGKEY) + 1 + sizeof(szObjType) + 1;
 	DBC_Assert(dwKeyLen < REG_MAXREGPATHLENGTH);
+
 	/* Create proper REG key; concatenate DCD_REGKEY with objType. */
-       strncpy(szRegKey, DCD_REGKEY, strlen(DCD_REGKEY) + 1);
-       if ((strlen(szRegKey) + strlen("_\0")) < REG_MAXREGPATHLENGTH)
-               strncat(szRegKey, "_\0", 2);
+	strncpy(szRegKey, DCD_REGKEY, strlen(DCD_REGKEY) + 1);
+	if ((strlen(szRegKey) + strlen("_\0")) < REG_MAXREGPATHLENGTH)
+		strncat(szRegKey, "_\0", 2);
 	else
 		status = DSP_EFAIL;
 
@@ -789,17 +804,17 @@ DSP_STATUS DCD_GetLibraryName(IN struct DCD_MANAGER *hDcdMgr,
 		status = DSP_EFAIL;
 	} else {
 		status = DSP_SOK;
-               if ((strlen(szRegKey) + strlen(szObjType))
-		   < REG_MAXREGPATHLENGTH) {
-                       strncat(szRegKey, szObjType, strlen(szObjType) + 1);
+		if ((strlen(szRegKey) + strlen(szObjType)) <
+		   REG_MAXREGPATHLENGTH) {
+			strncat(szRegKey, szObjType, strlen(szObjType) + 1);
 		} else {
 			status = DSP_EFAIL;
 		}
 		/* Create UUID value to find match in registry. */
 		UUID_UuidToString(pUuid, szUuid, MAXUUIDLEN);
-               if ((strlen(szRegKey) + MAXUUIDLEN) <
+		if ((strlen(szRegKey) + MAXUUIDLEN) <
 		   REG_MAXREGPATHLENGTH) {
-                       strncat(szRegKey, szUuid, MAXUUIDLEN);
+			strncat(szRegKey, szUuid, MAXUUIDLEN);
 		} else {
 			status = DSP_EFAIL;
 		}
@@ -808,29 +823,30 @@ DSP_STATUS DCD_GetLibraryName(IN struct DCD_MANAGER *hDcdMgr,
 		/* Retrieve path from the registry based on DSP_UUID */
 		status = REG_GetValue(szRegKey,	(u8 *)pstrLibName, pdwSize);
 	}
+
 	/* If can't find, phases might be registered as generic LIBRARYTYPE */
 	if (DSP_FAILED(status) && phase != NLDR_NOPHASE) {
 		if (fPhaseSplit)
 			*fPhaseSplit = false;
 
-               strncpy(szRegKey, DCD_REGKEY, strlen(DCD_REGKEY) + 1);
-               if ((strlen(szRegKey) + strlen("_\0")) <
+		strncpy(szRegKey, DCD_REGKEY, strlen(DCD_REGKEY) + 1);
+		if ((strlen(szRegKey) + strlen("_\0")) <
 		   REG_MAXREGPATHLENGTH) {
-                       strncat(szRegKey, "_\0", 2);
+			strncat(szRegKey, "_\0", 2);
 		} else {
 			status = DSP_EFAIL;
 		}
 		sprintf(szObjType, "%d", DSP_DCDLIBRARYTYPE);
-               if ((strlen(szRegKey) + strlen(szObjType))
+		if ((strlen(szRegKey) + strlen(szObjType))
 		   < REG_MAXREGPATHLENGTH) {
-                       strncat(szRegKey, szObjType, strlen(szObjType) + 1);
+			strncat(szRegKey, szObjType, strlen(szObjType) + 1);
 		} else {
 			status = DSP_EFAIL;
 		}
 		UUID_UuidToString(pUuid, szUuid, MAXUUIDLEN);
-               if ((strlen(szRegKey) + MAXUUIDLEN) < REG_MAXREGPATHLENGTH)
-                       strncat(szRegKey, szUuid, MAXUUIDLEN);
-               else
+		if ((strlen(szRegKey) + MAXUUIDLEN) < REG_MAXREGPATHLENGTH)
+			strncat(szRegKey, szUuid, MAXUUIDLEN);
+		else
 			status = DSP_EFAIL;
 
 		status = REG_GetValue(szRegKey, (u8 *)pstrLibName, pdwSize);
@@ -857,11 +873,11 @@ bool DCD_Init(void)
 		 cRefs);
 
 	if (cRefs == 0) {
-
 		/* Initialize required modules. */
 		fInitMEM = MEM_Init();
 		fInitCOD = COD_Init();
 		fInitREG = REG_Init();
+
 		if (!fInitMEM || !fInitCOD || !fInitREG) {
 			fInit = false;
 			GT_0trace(curTrace, GT_6CLASS, "DCD_Init failed\n");
@@ -897,91 +913,94 @@ bool DCD_Init(void)
  *      If pszPathName == NULL, unregister the specified DCD object.
  */
 DSP_STATUS DCD_RegisterObject(IN struct DSP_UUID *pUuid,
-			     IN enum DSP_DCDOBJTYPE objType,
-			     IN char *pszPathName)
+			IN enum DSP_DCDOBJTYPE objType,
+			IN char *pszPathName)
 {
 	DSP_STATUS status = DSP_SOK;
 	char szRegKey[REG_MAXREGPATHLENGTH];
 	char szUuid[MAXUUIDLEN + 1];
 	u32 dwPathSize = 0;
-	u32 dwKeyLen;		/* Len of REG key. */
+	u32 dwKeyLen;				/* Len of REG key. */
 	char szObjType[MAX_INT2CHAR_LENGTH];	/* str. rep. of objType. */
 
 	DBC_Require(cRefs > 0);
 	DBC_Require(pUuid != NULL);
 	DBC_Require((objType == DSP_DCDNODETYPE) ||
-		   (objType == DSP_DCDPROCESSORTYPE) ||
-		   (objType == DSP_DCDLIBRARYTYPE) ||
-		   (objType == DSP_DCDCREATELIBTYPE) ||
-		   (objType == DSP_DCDEXECUTELIBTYPE) ||
-		   (objType == DSP_DCDDELETELIBTYPE));
+			(objType == DSP_DCDPROCESSORTYPE) ||
+			(objType == DSP_DCDLIBRARYTYPE) ||
+			(objType == DSP_DCDCREATELIBTYPE) ||
+			(objType == DSP_DCDEXECUTELIBTYPE) ||
+			(objType == DSP_DCDDELETELIBTYPE));
 
 	GT_3trace(curTrace, GT_ENTER, "DCD_RegisterObject: object UUID 0x%x, "
 		 "objType %d, szPathName %s\n", pUuid, objType, pszPathName);
+
 	/*
 	 * Pre-determine final key length. It's length of DCD_REGKEY +
 	 *  "_\0" + length of szObjType string + terminating NULL.
 	 */
-       dwKeyLen = strlen(DCD_REGKEY) + 1 + sizeof(szObjType) + 1;
+	dwKeyLen = strlen(DCD_REGKEY) + 1 + sizeof(szObjType) + 1;
 	DBC_Assert(dwKeyLen < REG_MAXREGPATHLENGTH);
+
 	/* Create proper REG key; concatenate DCD_REGKEY with objType. */
-       strncpy(szRegKey, DCD_REGKEY, strlen(DCD_REGKEY) + 1);
-       if ((strlen(szRegKey) + strlen("_\0")) < REG_MAXREGPATHLENGTH)
-               strncat(szRegKey, "_\0", 2);
-	else
+	strncpy(szRegKey, DCD_REGKEY, strlen(DCD_REGKEY) + 1);
+	if ((strlen(szRegKey) + strlen("_\0")) < REG_MAXREGPATHLENGTH)
+		strncat(szRegKey, "_\0", 2);
+	else {
 		status = DSP_EFAIL;
+		goto func_end;
+	}
 
 	status = snprintf(szObjType, MAX_INT2CHAR_LENGTH, "%d", objType);
 	if (status == -1) {
 		status = DSP_EFAIL;
 	} else {
 		status = DSP_SOK;
-               if ((strlen(szRegKey) + strlen(szObjType)) <
+		if ((strlen(szRegKey) + strlen(szObjType)) <
 		   REG_MAXREGPATHLENGTH) {
-                       strncat(szRegKey, szObjType, strlen(szObjType) + 1);
-		} else {
+			strncat(szRegKey, szObjType, strlen(szObjType) + 1);
+		} else
 			status = DSP_EFAIL;
-		}
+
 		/* Create UUID value to set in registry. */
 		UUID_UuidToString(pUuid, szUuid, MAXUUIDLEN);
-               if ((strlen(szRegKey) + MAXUUIDLEN) < REG_MAXREGPATHLENGTH)
-                       strncat(szRegKey, szUuid, MAXUUIDLEN);
-               else
+		if ((strlen(szRegKey) + MAXUUIDLEN) < REG_MAXREGPATHLENGTH)
+			strncat(szRegKey, szUuid, MAXUUIDLEN);
+		else
 			status = DSP_EFAIL;
-
 	}
 
-	if (DSP_SUCCEEDED(status)) {
-		/*
-		 * If pszPathName != NULL, perform registration, otherwise,
-		 * perform unregistration.
-		 */
-		if (pszPathName) {
-			/* Add new reg value (UUID+objType) with COFF path
-			 * info. */
-                       dwPathSize = strlen(pszPathName) + 1;
-			status = REG_SetValue(szRegKey, (u8 *)pszPathName, dwPathSize);
-			GT_2trace(curTrace, GT_6CLASS, "REG_SetValue  "
-				  "(u8 *)pszPathName=%s, dwPathSize=%d\n",
-				  pszPathName, dwPathSize);
-
-			if (DSP_FAILED(status)) {
-				status = DSP_EFAIL;
-				GT_0trace(curTrace, GT_6CLASS,
+	if (DSP_FAILED(status))
+		goto func_end;
+
+	/*
+	 * If pszPathName != NULL, perform registration, otherwise,
+	 * perform unregistration.
+	 */
+	if (pszPathName) {
+		/* Add new reg value (UUID+objType) with COFF path info */
+		dwPathSize = strlen(pszPathName) + 1;
+		status = REG_SetValue(szRegKey, (u8 *)pszPathName, dwPathSize);
+		GT_2trace(curTrace, GT_6CLASS, "REG_SetValue "
+			"(u8 *)pszPathName=%s, dwPathSize=%d\n",
+			pszPathName, dwPathSize);
+
+		if (DSP_FAILED(status)) {
+			status = DSP_EFAIL;
+			GT_0trace(curTrace, GT_6CLASS,
 				  "DCD_RegisterObject: REG_SetValue failed!\n");
-			}
-		} else {
-			/* Deregister an existing object. */
-			status = REG_DeleteValue(szRegKey);
-			if (DSP_FAILED(status)) {
-				status = DSP_EFAIL;
-				GT_0trace(curTrace, GT_6CLASS,
-					"DCD_UnregisterObject: "
-					"REG_DeleteValue failed!\n");
-			}
+		}
+	} else {
+		/* Deregister an existing object */
+		status = REG_DeleteValue(szRegKey);
+		if (DSP_FAILED(status)) {
+			status = DSP_EFAIL;
+			GT_0trace(curTrace, GT_6CLASS, "DCD_UnregisterObject: "
+				"REG_DeleteValue failed!\n");
 		}
 	}
 
+
 	if (DSP_SUCCEEDED(status)) {
 		/*
 		 *  Because the node database has been updated through a
@@ -990,10 +1009,9 @@ DSP_STATUS DCD_RegisterObject(IN struct DSP_UUID *pUuid,
 		 *  current enumerations to reflect this update in the node
 		 *  database.
 		 */
-
 		cEnumRefs = 0;
 	}
-
+func_end:
 	return status;
 }
 
@@ -1080,7 +1098,6 @@ static s32 Atoi(char *pszBuf)
 				c = c - 'a' + 10;
 			else
 				c -= '0';
-
 		}
 		result += c;
 		++pch;
@@ -1116,7 +1133,6 @@ static DSP_STATUS GetAttrsFromBuf(char *pszBuf, u32 ulBufSize,
 		    || (objType == DSP_DCDPROCESSORTYPE));
 	DBC_Require(pGenObj != NULL);
 
-
 	switch (objType) {
 	case DSP_DCDNODETYPE:
 		/*
@@ -1137,12 +1153,12 @@ static DSP_STATUS GetAttrsFromBuf(char *pszBuf, u32 ulBufSize,
 		token = strsep(&pszCur, seps);
 
 		/* acName */
-               DBC_Require(token);
+		DBC_Require(token);
 		cLen = strlen(token);
 		if (cLen > DSP_MAXNAMELEN - 1)
 			cLen = DSP_MAXNAMELEN - 1;
 
-               strncpy(pGenObj->objData.nodeObj.ndbProps.acName,
+		strncpy(pGenObj->objData.nodeObj.ndbProps.acName,
 			   token, cLen);
 		pGenObj->objData.nodeObj.ndbProps.acName[cLen] = '\0';
 		token = strsep(&pszCur, seps);
@@ -1220,8 +1236,8 @@ static DSP_STATUS GetAttrsFromBuf(char *pszBuf, u32 ulBufSize,
 			Atoi(token);
 		token = strsep(&pszCur, seps);
 
-		/* char * pstrCreatePhaseFxn */
-               DBC_Require(token);
+		/* char *pstrCreatePhaseFxn */
+		DBC_Require(token);
 		cLen = strlen(token);
 		pGenObj->objData.nodeObj.pstrCreatePhaseFxn =
 			MEM_Calloc(cLen + 1, MEM_PAGED);
@@ -1230,8 +1246,8 @@ static DSP_STATUS GetAttrsFromBuf(char *pszBuf, u32 ulBufSize,
 		pGenObj->objData.nodeObj.pstrCreatePhaseFxn[cLen] = '\0';
 		token = strsep(&pszCur, seps);
 
-		/* char * pstrExecutePhaseFxn */
-               DBC_Require(token);
+		/* char *pstrExecutePhaseFxn */
+		DBC_Require(token);
 		cLen = strlen(token);
 		pGenObj->objData.nodeObj.pstrExecutePhaseFxn =
 			 MEM_Calloc(cLen + 1, MEM_PAGED);
@@ -1240,8 +1256,8 @@ static DSP_STATUS GetAttrsFromBuf(char *pszBuf, u32 ulBufSize,
 		pGenObj->objData.nodeObj.pstrExecutePhaseFxn[cLen] = '\0';
 		token = strsep(&pszCur, seps);
 
-		/* char * pstrDeletePhaseFxn */
-               DBC_Require(token);
+		/* char *pstrDeletePhaseFxn */
+		DBC_Require(token);
 		cLen = strlen(token);
 		pGenObj->objData.nodeObj.pstrDeletePhaseFxn =
 			MEM_Calloc(cLen + 1, MEM_PAGED);
@@ -1258,7 +1274,7 @@ static DSP_STATUS GetAttrsFromBuf(char *pszBuf, u32 ulBufSize,
 		pGenObj->objData.nodeObj.uMsgNotifyType = Atoi(token);
 		token = strsep(&pszCur, seps);
 
-		/* char * pstrIAlgName */
+		/* char *pstrIAlgName */
 		if (token) {
 			cLen = strlen(token);
 			pGenObj->objData.nodeObj.pstrIAlgName =
@@ -1388,7 +1404,6 @@ static void CompressBuf(char *pszBuf, u32 ulBufSize, s32 cCharSize)
 		return;
 
 	for (q = pszBuf; q < (pszBuf + ulBufSize);) {
-
 		ch = DspChar2GppChar(q, cCharSize);
 		if (ch == '\\') {
 			q += cCharSize;
@@ -1424,7 +1439,6 @@ static void CompressBuf(char *pszBuf, u32 ulBufSize, s32 cCharSize)
 	/* NULL out remainder of buffer. */
 	while (p < q)
 		*p++ = '\0';
-
 }
 
 /*
@@ -1460,8 +1474,8 @@ static DSP_STATUS GetDepLibInfo(IN struct DCD_MANAGER *hDcdMgr,
 	char *pszCur;
 	char *pszFileName = NULL;
 	struct COD_LIBRARYOBJ *lib = NULL;
-	u32 ulAddr = 0;	/* Used by COD_GetSection */
-	u32 ulLen = 0;	/* Used by COD_GetSection */
+	u32 ulAddr = 0;				/* Used by COD_GetSection */
+	u32 ulLen = 0;				/* Used by COD_GetSection */
 	u32 dwDataSize = COD_MAXPATHLENGTH;
 	char seps[] = ", ";
 	char *pToken = NULL;
@@ -1494,6 +1508,7 @@ static DSP_STATUS GetDepLibInfo(IN struct DCD_MANAGER *hDcdMgr,
 		status = DCD_GetLibraryName(hDcdMgr, pUuid, pszFileName,
 			 &dwDataSize, phase, NULL);
 	}
+
 	/* Open the library */
 	if (DSP_SUCCEEDED(status)) {
 		status = COD_Open(pDcdMgr->hCodMgr, pszFileName,
@@ -1525,6 +1540,7 @@ static DSP_STATUS GetDepLibInfo(IN struct DCD_MANAGER *hDcdMgr,
 
 	/* Compress and format DSP buffer to conform to PC format. */
 	CompressBuf(pszCoffBuf, ulLen, DSPWORDSIZE);
+
 	/* Read from buffer */
 	pszCur = pszCoffBuf;
 	while ((pToken = strsep(&pszCur, seps)) && *pToken != '\0') {
@@ -1564,4 +1580,3 @@ func_cont:
 
 	return status;
 }
-
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 09/17] DSPBRIDGE: Do not panic on bad page count
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
                   ` (7 preceding siblings ...)
  2009-12-15  6:19 ` [PATCH 08/17] DSPBRIDGE: Trivial cleanup on DBDCD Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 10/17] DSPBRIDGE: support loading 4 dependent DLL Omar Ramirez Luna
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos, Omar Ramirez Luna

If a page doesn't have a sane count, do not panic or release it.
Loudly complain with dump_stack but do not halt with BUG.

Signed-off-by: Fernando Guzman Lugo <x0095840@ti.com>
Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/wmd/tiomap3430.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/dsp/bridge/wmd/tiomap3430.c b/drivers/dsp/bridge/wmd/tiomap3430.c
index 65a21b2..f41763c 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430.c
@@ -301,7 +301,7 @@ static void bad_page_dump(u32 pa, struct page *pg)
 		current->comm, pg, (int)(2*sizeof(unsigned long)),
 		(unsigned long)pg->flags, pg->mapping,
 		page_mapcount(pg), page_count(pg));
-	BUG();
+	dump_stack();
 }
 
 /*
@@ -1707,9 +1707,10 @@ static DSP_STATUS WMD_BRD_MemUnMap(struct WMD_DEV_CONTEXT *hDevContext,
 						"COUNT 0 FOR PA 0x%x, size = "
 						"0x%x\n", pAddr, ulNumBytes);
 					bad_page_dump(pAddr, pg);
+				} else {
+					SetPageDirty(pg);
+					page_cache_release(pg);
 				}
-				SetPageDirty(pg);
-				page_cache_release(pg);
 				pAddr += HW_PAGE_SIZE_4KB;
 			}
 			if (HW_MMU_PteClear(pteAddrL2, vaCurr, pteSize)
@@ -1772,9 +1773,10 @@ skip_coarse_page:
 						"COUNT 0 FOR PA 0x%x, size = "
 						"0x%x\n", pAddr, ulNumBytes);
 					bad_page_dump(pAddr, pg);
+				} else {
+					SetPageDirty(pg);
+					page_cache_release(pg);
 				}
-				SetPageDirty(pg);
-				page_cache_release(pg);
 			}
 			pAddr += HW_PAGE_SIZE_4KB;
 		}
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 10/17] DSPBRIDGE: support loading 4 dependent DLL
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
                   ` (8 preceding siblings ...)
  2009-12-15  6:19 ` [PATCH 09/17] DSPBRIDGE: Do not panic on bad page count Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 11/17] DSPBRIDGE: Memory leak in Node Register Notify Omar Ramirez Luna
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos

From: Fernando Guzman Lugo <x0095840@ti.com>

This patch fixes loading a SN that has 4 dependent DLLs, previously
it was failing due to a non-null terminated string.

Signed-off-by: Fernando Guzman Lugo <x0095840@ti.com>
---
 drivers/dsp/bridge/rmgr/dbdcd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/dsp/bridge/rmgr/dbdcd.c b/drivers/dsp/bridge/rmgr/dbdcd.c
index b1391e2..fb06ff2 100644
--- a/drivers/dsp/bridge/rmgr/dbdcd.c
+++ b/drivers/dsp/bridge/rmgr/dbdcd.c
@@ -1529,7 +1529,7 @@ static DSP_STATUS GetDepLibInfo(IN struct DCD_MANAGER *hDcdMgr,
 		goto func_cont;
 
 	/* Allocate zeroed buffer. */
-	pszCoffBuf = MEM_Calloc(ulLen, MEM_PAGED);
+	pszCoffBuf = MEM_Calloc(ulLen + 4, MEM_PAGED);
 	if (pszCoffBuf == NULL)
 		status = DSP_EMEMORY;
 
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 11/17] DSPBRIDGE: Memory leak in Node Register Notify
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
                   ` (9 preceding siblings ...)
  2009-12-15  6:19 ` [PATCH 10/17] DSPBRIDGE: support loading 4 dependent DLL Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 12/17] DSPBRIDGE: check pointer before calling Proc_Detach Omar Ramirez Luna
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos

From: Ernesto Ramos Falcon <ernesto@ti.com>

Fix for memory leak in DSPNode_RegisterNotify when
unregistering an object.

Signed-off-by: Ernesto Ramos Falcon <ernesto@ti.com>
---
 drivers/dsp/bridge/pmgr/wcd.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/dsp/bridge/pmgr/wcd.c b/drivers/dsp/bridge/pmgr/wcd.c
index bb28cd2..c211b64 100644
--- a/drivers/dsp/bridge/pmgr/wcd.c
+++ b/drivers/dsp/bridge/pmgr/wcd.c
@@ -1403,6 +1403,11 @@ u32 NODEWRAP_RegisterNotify(union Trapped_Args *args)
 	notification.psName = NULL;
 	notification.handle = NULL;
 
+	if (!args->ARGS_PROC_REGISTER_NOTIFY.uEventMask)
+		cp_fm_usr(&notification,
+			args->ARGS_PROC_REGISTER_NOTIFY.hNotification,
+			status, 1);
+
 	status = NODE_RegisterNotify(args->ARGS_NODE_REGISTERNOTIFY.hNode,
 				    args->ARGS_NODE_REGISTERNOTIFY.uEventMask,
 				    args->ARGS_NODE_REGISTERNOTIFY.uNotifyType,
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 12/17] DSPBRIDGE: check pointer before calling Proc_Detach
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
                   ` (10 preceding siblings ...)
  2009-12-15  6:19 ` [PATCH 11/17] DSPBRIDGE: Memory leak in Node Register Notify Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 13/17] DSPBRIDGE: check the status of DMM_GetHandle Omar Ramirez Luna
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos

From: Ernest Ramos Falcon <ernesto@ti.com>

This patch adds a check before calling Proc_Detach, otherwise
we will see an error.

Signed-off-by: Ernest Ramos Falcon <ernesto@ti.com>
Signed-off-by: Fernando Guzman Lugo <x0095840@ti.com>
---
 drivers/dsp/bridge/rmgr/drv_interface.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/dsp/bridge/rmgr/drv_interface.c b/drivers/dsp/bridge/rmgr/drv_interface.c
index a2df832..6415955 100644
--- a/drivers/dsp/bridge/rmgr/drv_interface.c
+++ b/drivers/dsp/bridge/rmgr/drv_interface.c
@@ -592,7 +592,8 @@ static int bridge_release(struct inode *ip, struct file *filp)
 		if (DSP_SUCCEEDED(dsp_status)) {
 			flush_signals(current);
 			DRV_RemoveAllResources(pr_ctxt);
-			PROC_Detach(pr_ctxt->hProcessor);
+			if (pr_ctxt->hProcessor)
+				PROC_Detach(pr_ctxt->hProcessor);
 			DRV_RemoveProcContext((struct DRV_OBJECT *)hDrvObject,
 					pr_ctxt, (void *)pr_ctxt->pid);
 		} else {
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 13/17] DSPBRIDGE: check the status of DMM_GetHandle
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
                   ` (11 preceding siblings ...)
  2009-12-15  6:19 ` [PATCH 12/17] DSPBRIDGE: check pointer before calling Proc_Detach Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 14/17] DSPBRIDGE: KFILE_Seek & KFILE_Tell, u32 replaced with loff_t Omar Ramirez Luna
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos, Omar Ramirez Luna

Check the status of DMM_GetHandle

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/rmgr/proc.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/dsp/bridge/rmgr/proc.c b/drivers/dsp/bridge/rmgr/proc.c
index ab0b913..89b1ff3 100644
--- a/drivers/dsp/bridge/rmgr/proc.c
+++ b/drivers/dsp/bridge/rmgr/proc.c
@@ -1833,16 +1833,19 @@ DSP_STATUS PROC_UnMap(DSP_HPROCESSOR hProcessor, void *pMapAddr)
 	}
 
 	status = DMM_GetHandle(hProcessor, &hDmmMgr);
-	/* Critical section */
-	(void)SYNC_EnterCS(hProcLock);
 	if (DSP_FAILED(status)) {
 		GT_1trace(PROC_DebugMask, GT_7CLASS, "PROC_UnMap: "
-			 "Failed to get DMM Mgr handle: 0x%x\n", status);
-	} else {
-		/* Update DMM structures. Get the size to unmap.
-		 This function returns error if the VA is not mapped */
-		status = DMM_UnMapMemory(hDmmMgr, (u32) vaAlign, &sizeAlign);
+			"Failed to get DMM Mgr handle: 0x%x\n", status);
+		goto func_end;
 	}
+
+	/* Critical section */
+	(void)SYNC_EnterCS(hProcLock);
+	/*
+	 * Update DMM structures. Get the size to unmap.
+	 * This function returns error if the VA is not mapped
+	 */
+	status = DMM_UnMapMemory(hDmmMgr, (u32) vaAlign, &sizeAlign);
 	/* Remove mapping from the page tables. */
 	if (DSP_SUCCEEDED(status)) {
 		status = (*pProcObject->pIntfFxns->pfnBrdMemUnMap)
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 14/17] DSPBRIDGE: KFILE_Seek & KFILE_Tell, u32 replaced with loff_t
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
                   ` (12 preceding siblings ...)
  2009-12-15  6:19 ` [PATCH 13/17] DSPBRIDGE: check the status of DMM_GetHandle Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 15/17] DSPBRIDGE: Delete unused files Omar Ramirez Luna
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos, Omar Ramirez Luna

KFILE_Seek & KFILE_Tell, u32 replaced with loff_t

Discovered-by: Ameya Palande <ameya.palande@nokia.com>
Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/pmgr/cod.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dsp/bridge/pmgr/cod.c b/drivers/dsp/bridge/pmgr/cod.c
index a85f2a7..1ebbe8d 100644
--- a/drivers/dsp/bridge/pmgr/cod.c
+++ b/drivers/dsp/bridge/pmgr/cod.c
@@ -199,7 +199,7 @@ static s32 COD_fRead(void __user *pBuffer, s32 cSize, s32 cCount,
 
 static s32 COD_fSeek(struct file *hFile, s32 lOffset, s32 cOrigin)
 {
-	u32 dwCurPos;
+	loff_t dwCurPos;
 
 	/* check for valid file handle */
 	if (!hFile)
@@ -217,7 +217,7 @@ static s32 COD_fSeek(struct file *hFile, s32 lOffset, s32 cOrigin)
 
 static s32 COD_fTell(struct file *hFile)
 {
-	u32 dwCurPos;
+	loff_t dwCurPos;
 
 	if (!hFile)
 		return DSP_EHANDLE;
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 15/17] DSPBRIDGE: Delete unused files
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
                   ` (13 preceding siblings ...)
  2009-12-15  6:19 ` [PATCH 14/17] DSPBRIDGE: KFILE_Seek & KFILE_Tell, u32 replaced with loff_t Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15  6:19 ` [PATCH 16/17] DSPBRIDGE: Avoid REGistry if pDevContext is available Omar Ramirez Luna
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos, Omar Ramirez Luna

These files seem to be unused, deleting them.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 arch/arm/plat-omap/include/dspbridge/dbl.h  |  354 -------
 arch/arm/plat-omap/include/dspbridge/dbof.h |  117 ---
 drivers/dsp/bridge/dynload/dlclasses_hdr.h  |   41 -
 drivers/dsp/bridge/pmgr/dbl.c               | 1385 ---------------------------
 4 files changed, 0 insertions(+), 1897 deletions(-)
 delete mode 100644 arch/arm/plat-omap/include/dspbridge/dbl.h
 delete mode 100644 arch/arm/plat-omap/include/dspbridge/dbof.h
 delete mode 100644 drivers/dsp/bridge/dynload/dlclasses_hdr.h
 delete mode 100644 drivers/dsp/bridge/pmgr/dbl.c

diff --git a/arch/arm/plat-omap/include/dspbridge/dbl.h b/arch/arm/plat-omap/include/dspbridge/dbl.h
deleted file mode 100644
index 19847f9..0000000
--- a/arch/arm/plat-omap/include/dspbridge/dbl.h
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * dbl.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-
-/*
- *  ======== dbl.h ========
- *
- *! Revision History
- *! ================
- *! 19-Mar-2002 jeh     Pass DBL_Symbol pointer to DBL_getAddr, DBL_getCAddr
- *!                     to accomodate dynamic loader library.
- *! 20-Nov-2001 jeh     Removed DBL_loadArgs().
- *! 24-Sep-2001 jeh     Code review changes.
- *! 07-Sep-2001 jeh     Added DBL_LoadSect(), DBL_UnloadSect().
- *! 05-Jun-2001 jeh     Created based on zl.h.
- */
-
-#ifndef DBL_
-#define DBL_
-
-#include <dspbridge/dbdefs.h>
-#include <dspbridge/dbldefs.h>
-
-/*
- *  ======== DBL_close ========
- *  Close library opened with DBL_open.
- *  Parameters:
- *      lib             - Handle returned from DBL_open().
- *  Returns:
- *  Requires:
- *      DBL initialized.
- *      Valid lib.
- *  Ensures:
- */
-	extern void DBL_close(struct DBL_LibraryObj *lib);
-
-/*
- *  ======== DBL_create ========
- *  Create a target object by specifying the alloc, free, and write
- *  functions for the target.
- *  Parameters:
- *      pTarget         - Location to store target handle on output.
- *      pAttrs          - Attributes.
- *  Returns:
- *      DSP_SOK:        Success.
- *      DSP_EMEMORY:    Memory allocation failed.
- *  Requires:
- *      DBL initialized.
- *      pAttrs != NULL.
- *      pTarget != NULL;
- *  Ensures:
- *      Success:        *pTarget != NULL.
- *      Failure:        *pTarget == NULL.
- */
-	extern DSP_STATUS DBL_create(struct DBL_TargetObj **pTarget,
-				     struct DBL_Attrs *pAttrs);
-
-/*
- *  ======== DBL_delete ========
- *  Delete target object and free resources for any loaded libraries.
- *  Parameters:
- *      target          - Handle returned from DBL_Create().
- *  Returns:
- *  Requires:
- *      DBL initialized.
- *      Valid target.
- *  Ensures:
- */
-	extern void DBL_delete(struct DBL_TargetObj *target);
-
-/*
- *  ======== DBL_exit ========
- *  Discontinue use of DBL module.
- *  Parameters:
- *  Returns:
- *  Requires:
- *      cRefs > 0.
- *  Ensures:
- *      cRefs >= 0.
- */
-	extern void DBL_exit(void);
-
-/*
- *  ======== DBL_getAddr ========
- *  Get address of name in the specified library.
- *  Parameters:
- *      lib             - Handle returned from DBL_open().
- *      name            - Name of symbol
- *      ppSym           - Location to store symbol address on output.
- *  Returns:
- *      TRUE:           Success.
- *      FALSE:          Symbol not found.
- *  Requires:
- *      DBL initialized.
- *      Valid lib.
- *      name != NULL.
- *      pAddr != NULL.
- *  Ensures:
- */
-	extern bool DBL_getAddr(struct DBL_LibraryObj *lib, char *name,
-				struct DBL_Symbol **ppSym);
-
-/*
- *  ======== DBL_getAttrs ========
- *  Retrieve the attributes of the target.
- *  Parameters:
- *      target          - Handle returned from DBL_Create().
- *      pAttrs          - Location to store attributes on output.
- *  Returns:
- *  Requires:
- *      DBL initialized.
- *      Valid target.
- *      pAttrs != NULL.
- *  Ensures:
- */
-	extern void DBL_getAttrs(struct DBL_TargetObj *target,
-				 struct DBL_Attrs *pAttrs);
-
-/*
- *  ======== DBL_getCAddr ========
- *  Get address of "C" name in the specified library.
- *  Parameters:
- *      lib             - Handle returned from DBL_open().
- *      name            - Name of symbol
- *      ppSym           - Location to store symbol address on output.
- *  Returns:
- *      TRUE:           Success.
- *      FALSE:          Symbol not found.
- *  Requires:
- *      DBL initialized.
- *      Valid lib.
- *      name != NULL.
- *      pAddr != NULL.
- *  Ensures:
- */
-	extern bool DBL_getCAddr(struct DBL_LibraryObj *lib, char *name,
-				 struct DBL_Symbol **ppSym);
-
-/*
- *  ======== DBL_getEntry ========
- *  Get program entry point.
- *
- *  Parameters:
- *      lib             - Handle returned from DBL_open().
- *      pEntry          - Location to store entry address on output.
- *  Returns:
- *      TRUE:           Success.
- *      FALSE:          Failure.
- *  Requires:
- *      DBL initialized.
- *      Valid lib.
- *      pEntry != NULL.
- *  Ensures:
- */
-	extern bool DBL_getEntry(struct DBL_LibraryObj *lib, u32 *pEntry);
-
-/*
- *  ======== DBL_getSect ========
- *  Get address and size of a named section.
- *  Parameters:
- *      lib             - Library handle returned from DBL_open().
- *      name            - Name of section.
- *      pAddr           - Location to store section address on output.
- *      pSize           - Location to store section size on output.
- *  Returns:
- *      DSP_SOK:        Success.
- *      DSP_ENOSECT:    Section not found.
- *  Requires:
- *      DBL initialized.
- *      Valid lib.
- *      name != NULL.
- *      pAddr != NULL;
- *      pSize != NULL.
- *  Ensures:
- */
-	extern DSP_STATUS DBL_getSect(struct DBL_LibraryObj *lib, char *name,
-				      u32 *pAddr, u32 *pSize);
-
-/*
- *  ======== DBL_init ========
- *  Initialize DBL module.
- *  Parameters:
- *  Returns:
- *      TRUE:           Success.
- *      FALSE:          Failure.
- *  Requires:
- *      cRefs >= 0.
- *  Ensures:
- *      Success:        cRefs > 0.
- *      Failure:        cRefs >= 0.
- */
-	extern bool DBL_init(void);
-
-/*
- *  ======== DBL_load ========
- *  Add symbols/code/data defined in file to that already present on
- *  the target.
- *
- *  Parameters:
- *      lib             - Library handle returned from DBL_open().
- *      flags           - Specifies whether loading code, data, and/or symbols.
- *      attrs           - May contain write, alloc, and free functions.
- *      pulEntry        - Location to store program entry on output.
- *  Returns:
- *      DSP_SOK:        Success.
- *      DSP_EFREAD:     File read failed.
- *      DSP_EFWRITE:    Write to target failed.
- *  Requires:
- *      DBL initialized.
- *      Valid lib.
- *      pEntry != NULL.
- *  Ensures:
- */
-	extern DSP_STATUS DBL_load(struct DBL_LibraryObj *lib, DBL_Flags flags,
-				   struct DBL_Attrs *attrs, u32 *pEntry);
-
-/*
- *  ======== DBL_loadSect ========
- *  Load a named section from an library (for overlay support).
- *  Parameters:
- *      lib             - Handle returned from DBL_open().
- *      sectName        - Name of section to load.
- *      attrs           - Contains write function and handle to pass to it.
- *  Returns:
- *      DSP_SOK:        Success.
- *      DSP_ENOSECT:    Section not found.
- *      DSP_EFWRITE:    Write function failed.
- *  Requires:
- *      Valid lib.
- *      sectName != NULL.
- *      attrs != NULL.
- *      attrs->write != NULL.
- *  Ensures:
- */
-	extern DSP_STATUS DBL_loadSect(struct DBL_LibraryObj *lib,
-				       char *sectName,
-				       struct DBL_Attrs *attrs);
-
-/*
- *  ======== DBL_open ========
- *  DBL_open() returns a library handle that can be used to load/unload
- *  the symbols/code/data via DBL_load()/DBL_unload().
- *  Parameters:
- *      target          - Handle returned from DBL_create().
- *      file            - Name of file to open.
- *      flags           - Specifies whether to load symbols now.
- *      pLib            - Location to store library handle on output.
- *  Returns:
- *      DSP_SOK:            Success.
- *      DSP_EMEMORY:        Memory allocation failure.
- *      DSP_EFOPEN:         File open failure.
- *      DSP_EFREAD:         File read failure.
- *      DSP_ECORRUPTFILE:   Unable to determine target type.
- *  Requires:
- *      DBL initialized.
- *      Valid target.
- *      file != NULL.
- *      pLib != NULL.
- *      struct DBL_Attrs fopen function non-NULL.
- *  Ensures:
- *      Success:        Valid *pLib.
- *      Failure:        *pLib == NULL.
- */
-	extern DSP_STATUS DBL_open(struct DBL_TargetObj *target, char *file,
-				   DBL_Flags flags,
-				   struct DBL_LibraryObj **pLib);
-
-/*
- *  ======== DBL_readSect ========
- *  Read COFF section into a character buffer.
- *  Parameters:
- *      lib             - Library handle returned from DBL_open().
- *      name            - Name of section.
- *      pBuf            - Buffer to write section contents into.
- *      size            - Buffer size
- *  Returns:
- *      DSP_SOK:        Success.
- *      DSP_ENOSECT:    Named section does not exists.
- *  Requires:
- *      DBL initialized.
- *      Valid lib.
- *      name != NULL.
- *      pBuf != NULL.
- *      size != 0.
- *  Ensures:
- */
-	extern DSP_STATUS DBL_readSect(struct DBL_LibraryObj *lib, char *name,
-				       char *pBuf, u32 size);
-
-/*
- *  ======== DBL_setAttrs ========
- *  Set the attributes of the target.
- *  Parameters:
- *      target          - Handle returned from DBL_create().
- *      pAttrs          - New attributes.
- *  Returns:
- *  Requires:
- *      DBL initialized.
- *      Valid target.
- *      pAttrs != NULL.
- *  Ensures:
- */
-	extern void DBL_setAttrs(struct DBL_TargetObj *target,
-				 struct DBL_Attrs *pAttrs);
-
-/*
- *  ======== DBL_unload ========
- *  Remove the symbols/code/data corresponding to the library lib.
- *  Parameters:
- *      lib             - Handle returned from DBL_open().
- *      attrs           - Contains free() function and handle to pass to it.
- *  Returns:
- *  Requires:
- *      DBL initialized.
- *      Valid lib.
- *  Ensures:
- */
-	extern void DBL_unload(struct DBL_LibraryObj *lib,
-			       struct DBL_Attrs *attrs);
-
-/*
- *  ======== DBL_unloadSect ========
- *  Unload a named section from an library (for overlay support).
- *  Parameters:
- *      lib             - Handle returned from DBL_open().
- *      sectName        - Name of section to load.
- *      attrs           - Contains free() function and handle to pass to it.
- *  Returns:
- *      DSP_SOK:        Success.
- *      DSP_ENOSECT:    Named section not found.
- *  Requires:
- *      DBL initialized.
- *      Valid lib.
- *      sectName != NULL.
- *  Ensures:
- */
-	extern DSP_STATUS DBL_unloadSect(struct DBL_LibraryObj *lib,
-					 char *sectName,
-					 struct DBL_Attrs *attrs);
-
-#endif				/* DBL_ */
diff --git a/arch/arm/plat-omap/include/dspbridge/dbof.h b/arch/arm/plat-omap/include/dspbridge/dbof.h
deleted file mode 100644
index 54f4250..0000000
--- a/arch/arm/plat-omap/include/dspbridge/dbof.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * dbof.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-
-/*
- *  ======== dbof.h ========
- *  Description:
- *      Defines and typedefs for DSP/BIOS Bridge Object File Format (DBOF).
- *
- *! Revision History
- *! ================
- *! 12-Jul-2002 jeh     Added defines for DBOF_SectHdr page.
- *! 12-Oct-2001 jeh     Converted to std.h format.
- *! 07-Sep-2001 jeh     Added overlay support.
- *! 06-Jul-2001 jeh     Created.
- */
-
-#ifndef DBOF_
-#define DBOF_
-
-/* Enough to hold DCD section names: 32 digit ID + underscores */
-#define DBOF_DCDSECTNAMELEN     40
-
-/* Values for DBOF_SectHdr page field. */
-#define         DBOF_PROGRAM    0
-#define         DBOF_DATA       1
-#define         DBOF_CINIT      2
-
-/*
- *  ======== DBOF_FileHdr ========
- */
-	struct DBOF_FileHdr {
-		u32 magic;	/* COFF magic number */
-		u32 entry;	/* Program entry point */
-		u16 numSymbols;	/* Number of bridge symbols */
-		u16 numDCDSects;	/* Number of DCD sections */
-		u16 numSects;	/* Number of sections to load */
-		u16 numOvlySects;	/* Number of overlay sections */
-		u32 symOffset;	/* Offset in file to symbols */
-		u32 dcdSectOffset;	/* Offset to DCD sections */
-		u32 loadSectOffset;	/* Offset to loadable sections */
-		u32 ovlySectOffset;	/* Offset to overlay data */
-		u16 version;	/* DBOF version number */
-		u16 resvd;	/* Reserved for future use */
-	} ;
-
-/*
- *  ======== DBOF_DCDSectHdr ========
- */
-	struct DBOF_DCDSectHdr {
-		u32 size;	/* Sect size (target MAUs) */
-		char name[DBOF_DCDSECTNAMELEN];	/* DCD section name */
-	} ;
-
-/*
- *  ======== DBOF_OvlySectHdr ========
- */
-	struct DBOF_OvlySectHdr {
-		u16 nameLen;	/* Length of section name */
-		u16 numCreateSects;	/* # of sects loaded for create phase */
-		u16 numDeleteSects;	/* # of sects loaded for delete phase */
-		u16 numExecuteSects; /* # of sects loaded for execute phase */
-
-		/*
-		 *  Number of sections where load/unload phase is not specified.
-		 *  These sections will be loaded when create phase sects are
-		 *  loaded, and unloaded when the delete phase is unloaded.
-		 */
-		u16 numOtherSects;
-		u16 resvd;	/* Reserved for future use */
-	};
-
-/*
- *  ======== DBOF_OvlySectData ========
- */
-	struct DBOF_OvlySectData {
-		u32 loadAddr;	/* Section load address */
-		u32 runAddr;	/* Section run address */
-		u32 size;	/* Section size (target MAUs) */
-		u16 page;	/* Memory page number */
-		u16 resvd;	/* Reserved */
-	} ;
-
-/*
- *  ======== DBOF_SectHdr ========
- */
-	struct DBOF_SectHdr {
-		u32 addr;	/* Section address */
-		u32 size;	/* Section size (target MAUs) */
-		u16 page;	/* Page number */
-		u16 resvd;	/* Reserved for future use */
-	} ;
-
-/*
- *  ======== DBOF_SymbolHdr ========
- */
-	struct DBOF_SymbolHdr {
-		u32 value;	/* Symbol value */
-		u16 nameLen;	/* Length of symbol name */
-		u16 resvd;	/* Reserved for future use */
-	} ;
-
-#endif				/* DBOF_ */
-
diff --git a/drivers/dsp/bridge/dynload/dlclasses_hdr.h b/drivers/dsp/bridge/dynload/dlclasses_hdr.h
deleted file mode 100644
index 04f136e..0000000
--- a/drivers/dsp/bridge/dynload/dlclasses_hdr.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * dlclasses_hdr.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-
-
-#ifndef _DLCLASSES_HDR_H
-#define _DLCLASSES_HDR_H
-
-/*****************************************************************************
- *****************************************************************************
- *
- *                          DLCLASSES_HDR.H
- *
- * Sample classes in support of the dynamic loader
- *
- * These are just concrete derivations of the virtual ones in dynamic_loader.h
- * with a few additional interfaces for init, etc.
- *****************************************************************************
- *****************************************************************************/
-
-#include <dspbridge/dynamic_loader.h>
-
-#include "DLstream.h"
-#include "DLsymtab.h"
-#include "DLalloc.h"
-#include "DLinit.h"
-
-#endif				/* _DLCLASSES_HDR_H */
diff --git a/drivers/dsp/bridge/pmgr/dbl.c b/drivers/dsp/bridge/pmgr/dbl.c
deleted file mode 100644
index 641b011..0000000
--- a/drivers/dsp/bridge/pmgr/dbl.c
+++ /dev/null
@@ -1,1385 +0,0 @@
-/*
- * dbl.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-
-/*
- *  ======== dbl.c ========
- *  Dynamic BOF Loader library. Contains functions related to
- *  loading and unloading symbols/code/data on DSP.
- *  Also contains other support functions.
- *
- *! Revision History
- *! ================
- *! 24-Feb-2003 swa 	PMGR Code review comments incorporated.
- *! 24-May-2002 jeh     Free DCD sects in DBL_close().
- *! 19-Mar-2002 jeh     Changes made to match dynamic loader (dbll.c): Pass
- *!		     DBL_Library to DBL_getAddr() instead of DBL_Target,
- *!		     eliminate scope param, use DBL_Symbol. Pass attrs to
- *!		     DBL_load(), DBL_unload().
- *! 20-Nov-2001 jeh     Removed DBL_loadArgs().
- *! 07-Sep-2001 jeh     Added overlay support.
- *! 31-Jul-2001 jeh     Include windows.h.
- *! 06-Jun-2001 jeh     Created.
- */
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/std.h>
-#include <dspbridge/dbdefs.h>
-#include <dspbridge/errbase.h>
-
-/*  ----------------------------------- Trace & Debug */
-#include <dspbridge/dbc.h>
-#include <dspbridge/gt.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/csl.h>
-#include <dspbridge/mem.h>
-#include <dspbridge/kfile.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/dbof.h>
-#include <dspbridge/dbl.h>
-
-#define DBL_TARGSIGNATURE      0x544c4244	/* "TLBD" */
-#define DBL_LIBSIGNATURE       0x4c4c4244	/* "LLBD" */
-
-#define C54TARG	 0
-#define C55TARG	 1
-#define NUMTARGS	2
-
-#define C54MAGIC	0x98	/* Magic number for TI C54 COF  */
-#define C55MAGIC	0x9c	/* Magic number for LEAD3 (C55) COF  */
-
-/* Three task phases */
-#define CREATEPHASE 0
-#define DELETEPHASE 1
-#define EXECUTEPHASE 2
-#define NONE 3		/* For overlay section with phase not specified */
-
-/* Default load buffer size */
-#define LOADBUFSIZE     0x800
-
-#define SWAPLONG(x) ((((x) << 24) & 0xFF000000) | (((x) << 8) & 0xFF0000L) | \
-		      (((x) >> 8) & 0xFF00L) | (((x) >> 24) & 0xFF))
-
-#define SWAPWORD(x) ((((x) << 8) & 0xFF00) | (((x) >> 8) & 0xFF))
-
-/*
- *  Macros for accessing the following types of overlay data within a
- *  structure of type OvlyData:
- *      - Overlay data not associated with a particular phase
- *      - Create phase overlay data
- *      - Delete phase overlay data
- *      - Execute phase overlay data
- */
-#define numOtherSects(pOvlyData)    ((pOvlyData)->hdr.dbofHdr.numOtherSects)
-#define numCreateSects(pOvlyData)   ((pOvlyData)->hdr.dbofHdr.numCreateSects)
-#define numDeleteSects(pOvlyData)   ((pOvlyData)->hdr.dbofHdr.numDeleteSects)
-#define numExecuteSects(pOvlyData)  ((pOvlyData)->hdr.dbofHdr.numExecuteSects)
-#define otherOffset(pOvlyData)      0
-#define createOffset(pOvlyData)     ((pOvlyData)->hdr.dbofHdr.numOtherSects)
-#define deleteOffset(pOvlyData)     (createOffset(pOvlyData) + \
-				     (pOvlyData->hdr.dbofHdr.numCreateSects))
-#define executeOffset(pOvlyData)    (deleteOffset(pOvlyData) + \
-				     (pOvlyData->hdr.dbofHdr.numDeleteSects))
-/*
- *  ======== OvlyHdr ========
- */
-struct OvlyHdr {
-	struct DBOF_OvlySectHdr dbofHdr;
-	char *pName; 		/* Name of overlay section */
-	u16 createRef; 	/* Reference count for create phase */
-	u16 deleteRef; 	/* Reference count for delete phase */
-	u16 executeRef; 	/* Execute phase ref count */
-	u16 otherRef; 		/* Unspecified phase ref count */
-} ;
-
-/*
- *  ======== OvlyData ========
- */
-struct OvlyData {
-	struct OvlyHdr hdr;
-	struct DBOF_OvlySectData data[1];
-} ;
-
-/*
- *  ======== Symbol ========
- */
-struct Symbol {
-	struct DBL_Symbol sym;
-	char *pSymName;
-};
-
-/*
- *  ======== DCDSect ========
- */
-struct DCDSect {
-	struct DBOF_DCDSectHdr sectHdr;
-	char *pData;
-} ;
-
-/*
- *  ======== DBL_TargetObj ========
- */
-struct DBL_TargetObj {
-	u32 dwSignature; 	/* For object validation */
-	struct DBL_Attrs dblAttrs; 	/* file read, write, etc. functions */
-	char *pBuf; 		/* Load buffer */
-};
-
-/*
- *  ======== TargetInfo ========
- */
-struct TargetInfo {
-	u16 dspType; 		/* eg, C54TARG, C55TARG */
-	u32 magic; 		/* COFF magic number, identifies target type */
-	u16 wordSize; 	/* Size of a DSP word */
-	u16 mauSize; 		/* Size of minimum addressable unit */
-	u16 charSize; 	/* For C55x, mausize = 1, but charsize = 2 */
-} ;
-
-/*
- *  ======== DBL_LibraryObj ========
- *  Represents a library loaded on a target.
- */
-struct DBL_LibraryObj {
-	u32 dwSignature; 	/* For object validation */
-	struct DBL_TargetObj *pTarget; 	/* Target for this library */
-	struct KFILE_FileObj *file; 	/* DBOF file handle */
-	bool byteSwapped; 	/* Are bytes swapped? */
-	struct DBOF_FileHdr fileHdr; 	/* Header of DBOF file */
-	u16 nSymbols; 		/* Number of DSP/Bridge symbols */
-	struct Symbol *symbols; 	/* Table of DSP/Bridge symbols */
-	u16 nDCDSects; 	/* Number of DCD sections */
-	u16 nOvlySects; 	/* Number of overlay nodes */
-	struct DCDSect *dcdSects; 	/* DCD section data */
-	struct OvlyData **ppOvlyData; 	/* Array of overlay section data */
-	struct TargetInfo *pTargetInfo; 	/* Entry in targetTab[] below */
-} ;
-
-#if GT_TRACE
-static struct GT_Mask DBL_debugMask = { NULL, NULL }; 	/* GT trace variable */
-#endif
-
-static u32 cRefs; 		/* module reference count */
-
-static u32 magicTab[NUMTARGS] = { C54MAGIC, C55MAGIC };
-
-static struct TargetInfo targetTab[] = {
-	/* targ     magic       wordsize    mausize    charsize */
-	{C54TARG, C54MAGIC, 2, 2, 2}, 	/* C54  */
-	{C55TARG, C55MAGIC, 2, 1, 2}, 	/* C55  */
-};
-
-static void freeSects(struct DBL_TargetObj *dbl, struct OvlyData *pOvlyData,
-		     s32 offset, s32 nSects);
-static DSP_STATUS loadSect(struct DBL_TargetObj *dbl,
-			  struct DBL_LibraryObj *pdblLib);
-static DSP_STATUS readDCDSects(struct DBL_TargetObj *dbl,
-			      struct DBL_LibraryObj *pdblLib);
-static DSP_STATUS readHeader(struct DBL_TargetObj *dbl,
-			    struct DBL_LibraryObj *pdblLib);
-static DSP_STATUS readOvlySects(struct DBL_TargetObj *dbl,
-				struct DBL_LibraryObj *pdblLib);
-static DSP_STATUS readSymbols(struct DBL_TargetObj *dbl,
-			     struct DBL_LibraryObj *pdblLib);
-
-/*
- *  ======== DBL_close ========
- *  Purpose:
- *  	Close library opened with DBL_open.
- */
-void DBL_close(struct DBL_LibraryObj *lib)
-{
-	struct DBL_LibraryObj *pdblLib = (struct DBL_LibraryObj *)lib;
-	u16 i;
-
-	DBC_Require(cRefs > 0);
-	DBC_Require(MEM_IsValidHandle(pdblLib, DBL_LIBSIGNATURE));
-
-	GT_1trace(DBL_debugMask, GT_ENTER, "DBL_close: lib: 0x%x\n", lib);
-
-	/* Free symbols */
-	if (pdblLib->symbols) {
-		for (i = 0; i < pdblLib->nSymbols; i++) {
-			if (pdblLib->symbols[i].pSymName)
-				MEM_Free(pdblLib->symbols[i].pSymName);
-
-		}
-		MEM_Free(pdblLib->symbols);
-	}
-
-	/* Free DCD sects */
-	if (pdblLib->dcdSects) {
-		for (i = 0; i < pdblLib->nDCDSects; i++) {
-			if (pdblLib->dcdSects[i].pData)
-				MEM_Free(pdblLib->dcdSects[i].pData);
-
-		}
-		MEM_Free(pdblLib->dcdSects);
-	}
-
-	/* Free overlay sects */
-	if (pdblLib->ppOvlyData) {
-		for (i = 0;  i < pdblLib->nOvlySects;  i++) {
-			if (pdblLib->ppOvlyData[i]) {
-				if (pdblLib->ppOvlyData[i]->hdr.pName) {
-					MEM_Free(pdblLib->ppOvlyData[i]->
-						hdr.pName);
-				}
-				MEM_Free(pdblLib->ppOvlyData[i]);
-			}
-		}
-		MEM_Free(pdblLib->ppOvlyData);
-	}
-
-	/* Close the file */
-	if (pdblLib->file)
-		(*pdblLib->pTarget->dblAttrs.fclose) (pdblLib->file);
-
-
-	MEM_FreeObject(pdblLib);
-}
-
-/*
- *  ======== DBL_create ========
- *  Purpose:
- *  	Create a target object by specifying the alloc, free, and
- *  	write functions for the target.
- */
-DSP_STATUS DBL_create(struct DBL_TargetObj **pTarget, struct DBL_Attrs *pAttrs)
-{
-	struct DBL_TargetObj *pdblTarget = NULL;
-	DSP_STATUS status = DSP_SOK;
-
-	DBC_Require(cRefs > 0);
-	DBC_Require(pAttrs != NULL);
-	DBC_Require(pTarget != NULL);
-
-	GT_2trace(DBL_debugMask, GT_ENTER,
-		 "DBL_create: pTarget: 0x%x pAttrs: 0x%x\n",
-		 pTarget, pAttrs);
-	/* Allocate DBL target object */
-	MEM_AllocObject(pdblTarget, struct DBL_TargetObj, DBL_TARGSIGNATURE);
-	if (pdblTarget == NULL) {
-		GT_0trace(DBL_debugMask, GT_6CLASS,
-			 "DBL_create: Memory allocation failed\n");
-		status = DSP_EMEMORY;
-	} else {
-		pdblTarget->dblAttrs = *pAttrs;
-		/* Allocate buffer for loading target */
-		pdblTarget->pBuf = MEM_Calloc(LOADBUFSIZE, MEM_PAGED);
-		if (pdblTarget->pBuf == NULL)
-			status = DSP_EMEMORY;
-
-	}
-	if (DSP_SUCCEEDED(status)) {
-		*pTarget = pdblTarget;
-	} else {
-		*pTarget = NULL;
-		if (pdblTarget)
-			DBL_delete(pdblTarget);
-
-	}
-	DBC_Ensure(DSP_SUCCEEDED(status) &&
-		  ((MEM_IsValidHandle((*pTarget), DBL_TARGSIGNATURE)) ||
-		  (DSP_FAILED(status) && *pTarget == NULL)));
-	return status;
-}
-
-/*
- *  ======== DBL_delete ========
- *  Purpose:
- *  	Delete target object and free resources for any loaded libraries.
- */
-void DBL_delete(struct DBL_TargetObj *target)
-{
-	DBC_Require(cRefs > 0);
-	DBC_Require(MEM_IsValidHandle(target, DBL_TARGSIGNATURE));
-
-	GT_1trace(DBL_debugMask, GT_ENTER,
-		 "DBL_delete: target: 0x%x\n", target);
-
-	if (target->pBuf)
-		MEM_Free(target->pBuf);
-
-	MEM_FreeObject(target);
-}
-
-/*
- *  ======== DBL_exit ========
- *  Purpose
- *  	Discontinue usage of DBL module.
- */
-void DBL_exit()
-{
-	DBC_Require(cRefs > 0);
-	cRefs--;
-	GT_1trace(DBL_debugMask, GT_5CLASS,
-		 "DBL_exit() ref count: 0x%x\n", cRefs);
-	DBC_Ensure(cRefs >= 0);
-}
-
-/*
- *  ======== DBL_getAddr ========
- *  Purpose:
- *  	Get address of name in the specified library.
- */
-bool DBL_getAddr(struct DBL_LibraryObj *lib, char *name,
-		struct DBL_Symbol **ppSym)
-{
-	bool retVal = false;
-	struct Symbol *symbol;
-	u16 i;
-
-	DBC_Require(cRefs > 0);
-	DBC_Require(MEM_IsValidHandle(lib, DBL_LIBSIGNATURE));
-	DBC_Require(name != NULL);
-	DBC_Require(ppSym != NULL);
-
-	GT_3trace(DBL_debugMask, GT_ENTER,
-		 "DBL_getAddr: libt: 0x%x name: %s pAddr: "
-		 "0x%x\n", lib, name, ppSym);
-	for (i = 0; i < lib->nSymbols; i++) {
-		symbol = &lib->symbols[i];
-		if (CSL_Strcmp(name, symbol->pSymName) == 0) {
-			/* Found it */
-			*ppSym = &lib->symbols[i].sym;
-			retVal = true;
-			break;
-		}
-	}
-	return retVal;
-}
-
-/*
- *  ======== DBL_getAttrs ========
- *  Purpose:
- *  	Retrieve the attributes of the target.
- */
-void DBL_getAttrs(struct DBL_TargetObj *target, struct DBL_Attrs *pAttrs)
-{
-	DBC_Require(cRefs > 0);
-	DBC_Require(MEM_IsValidHandle(target, DBL_TARGSIGNATURE));
-	DBC_Require(pAttrs != NULL);
-	GT_2trace(DBL_debugMask, GT_ENTER, "DBL_getAttrs: target: 0x%x pAttrs: "
-		  "0x%x\n", target, pAttrs);
-	*pAttrs = target->dblAttrs;
-}
-
-/*
- *  ======== DBL_getCAddr ========
- *  Purpose:
- *  	Get address of "C" name in the specified library.
- */
-bool DBL_getCAddr(struct DBL_LibraryObj *lib, char *name,
-		 struct DBL_Symbol **ppSym)
-{
-	bool retVal = false;
-	struct Symbol *symbol;
-	u16 i;
-
-	DBC_Require(cRefs > 0);
-	DBC_Require(MEM_IsValidHandle(lib, DBL_LIBSIGNATURE));
-	DBC_Require(name != NULL);
-	DBC_Require(ppSym != NULL);
-
-	GT_3trace(DBL_debugMask, GT_ENTER,
-		 "DBL_getCAddr: target: 0x%x name:%s pAddr:"
-		 " 0x%x\n", lib, name, ppSym);
-	for (i = 0;  i < lib->nSymbols;  i++) {
-		symbol = &lib->symbols[i];
-		if ((CSL_Strcmp(name, symbol->pSymName) == 0) ||
-		    (CSL_Strcmp(name, symbol->pSymName + 1) == 0 &&
-		     symbol->pSymName[0] == '_')) {
-			/* Found it */
-			*ppSym = &lib->symbols[i].sym;
-			retVal = true;
-			break;
-		}
-	}
-	return retVal;
-}
-
-/*
- *  ======== DBL_getEntry ========
- *  Purpose:
- *  	Get program entry point.
- *
- */
-bool DBL_getEntry(struct DBL_LibraryObj *lib, u32 *pEntry)
-{
-	struct DBL_LibraryObj *pdblLib = (struct DBL_LibraryObj *)lib;
-
-	DBC_Require(cRefs > 0);
-	DBC_Require(MEM_IsValidHandle(pdblLib, DBL_LIBSIGNATURE));
-	DBC_Require(pEntry != NULL);
-
-	GT_2trace(DBL_debugMask, GT_ENTER,
-		 "DBL_getEntry: lib: 0x%x pEntry: 0x%x\n", lib, pEntry);
-	*pEntry = pdblLib->fileHdr.entry;
-
-	return true;
-}
-
-/*
- *  ======== DBL_getSect ========
- *  Purpose:
- *  	Get address and size of a named section.
- */
-DSP_STATUS DBL_getSect(struct DBL_LibraryObj *lib, char *name, u32 *pAddr,
-		      u32 *pSize)
-{
-	struct DBL_LibraryObj *pdblLib = (struct DBL_LibraryObj *)lib;
-	u16 i;
-	DSP_STATUS status = DSP_ENOSECT;
-
-	DBC_Require(cRefs > 0);
-	DBC_Require(name != NULL);
-	DBC_Require(pAddr != NULL);
-	DBC_Require(pSize != NULL);
-	DBC_Require(MEM_IsValidHandle(pdblLib, DBL_LIBSIGNATURE));
-
-	GT_4trace(DBL_debugMask, GT_ENTER,
-		 "DBL_getSect: lib: 0x%x name: %s pAddr:"
-		 " 0x%x pSize: 0x%x\n", lib, name, pAddr, pSize);
-
-	/*
-	 *  Check for DCD and overlay sections. Overlay loader uses DBL_getSect
-	 *  to determine whether or not a node has overlay sections.
-	 *  DCD section names begin with '.'
-	 */
-	if (name[0] == '.') {
-		/* Get DCD section size (address is 0, since it's a NOLOAD). */
-		for (i = 0; i < pdblLib->nDCDSects; i++) {
-			if (CSL_Strcmp(pdblLib->dcdSects[i].sectHdr.name,
-			   name) == 0) {
-				*pAddr = 0;
-				*pSize = pdblLib->dcdSects[i].sectHdr.size *
-					 pdblLib->pTargetInfo->mauSize;
-				status = DSP_SOK;
-				break;
-			}
-		}
-	} else {
-		/* Check for overlay section */
-		for (i = 0;  i < pdblLib->nOvlySects;  i++) {
-			if (CSL_Strcmp(pdblLib->ppOvlyData[i]->hdr.pName,
-			   name) == 0) {
-				/* Address and size are meaningless */
-				*pAddr = 0;
-				*pSize = 0;
-				status = DSP_SOK;
-				break;
-			}
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== DBL_init ========
- *  Purpose:
- *  	Initialize DBL module.
- */
-bool DBL_init(void)
-{
-	bool retVal = true;
-
-	DBC_Require(cRefs >= 0);
-
-	if (cRefs == 0) {
-		DBC_Assert(!DBL_debugMask.flags);
-		GT_create(&DBL_debugMask, "BL"); 	/* "BL" for dBL */
-
-	}
-
-	if (retVal)
-		cRefs++;
-
-
-	GT_1trace(DBL_debugMask, GT_5CLASS, "DBL_init(), ref count:  0x%x\n",
-		  cRefs);
-
-	DBC_Ensure((retVal && (cRefs > 0)) || (!retVal && (cRefs >= 0)));
-
-	return retVal;
-}
-
-/*
- *  ======== DBL_load ========
- *  Purpose:
- *  	Add symbols/code/data defined in file to that already present
- *  	on the target.
- */
-DSP_STATUS DBL_load(struct DBL_LibraryObj *lib, DBL_Flags flags,
-		   struct DBL_Attrs *attrs, u32 *pEntry)
-{
-	struct DBL_LibraryObj *pdblLib = (struct DBL_LibraryObj *)lib;
-	struct DBL_TargetObj *dbl;
-	u16 i;
-	u16 nSects;
-	DSP_STATUS status = DSP_EFAIL;
-
-	DBC_Require(cRefs > 0);
-	DBC_Require(MEM_IsValidHandle(pdblLib, DBL_LIBSIGNATURE));
-	DBC_Require(pEntry != NULL);
-	DBC_Require(attrs != NULL);
-
-	GT_4trace(DBL_debugMask, GT_ENTER, "DBL_load: lib: 0x%x flags: "
-		 "0x%x attrs: 0x%x pEntry: 0x%x\n", lib, flags, attrs, pEntry);
-
-	dbl = pdblLib->pTarget;
-	*pEntry = pdblLib->fileHdr.entry;
-	nSects = pdblLib->fileHdr.numSects;
-	dbl->dblAttrs = *attrs;
-
-	for (i = 0; i < nSects; i++) {
-		/* Load the section at the current file offset */
-		status = loadSect(dbl, lib);
-		if (DSP_FAILED(status))
-			break;
-
-	}
-
-	/* Done with file, we can close it */
-	if (pdblLib->file) {
-		(*pdblLib->pTarget->dblAttrs.fclose) (pdblLib->file);
-		pdblLib->file = NULL;
-	}
-	return status;
-}
-
-/*
- *  ======== DBL_loadSect ========
- *  Purpose:
- *  	Load a named section from an library (for overlay support).
- */
-DSP_STATUS DBL_loadSect(struct DBL_LibraryObj *lib, char *sectName,
-			struct DBL_Attrs *attrs)
-{
-	struct DBL_TargetObj *dbl;
-	s32 i;
-	s32 phase;
-	s32 offset = -1;
-	s32 nSects = -1;
-	s32 allocdSects = 0;
-	u32 loadAddr;
-	u32 runAddr;
-	u32 size;
-	u32 space;
-	u32 ulBytes;
-	u16 mauSize;
-	u16 wordSize;
-	u16 *phaseRef = NULL;
-	u16 *otherRef = NULL;
-	char *name = NULL;
-	struct OvlyData *pOvlyData;
-	DSP_STATUS status = DSP_ENOSECT;
-
-	DBC_Require(cRefs > 0);
-	DBC_Require(MEM_IsValidHandle(lib, DBL_LIBSIGNATURE));
-	DBC_Require(sectName != NULL);
-	DBC_Require(attrs != NULL);
-	DBC_Require(attrs->write != NULL);
-	GT_3trace(DBL_debugMask, GT_ENTER,
-		 "DBL_loadSect: lib: 0x%x sectName: %s "
-		 "attrs: 0x%x\n", lib, sectName, attrs);
-	dbl = lib->pTarget;
-	mauSize = lib->pTargetInfo->mauSize;
-	wordSize = lib->pTargetInfo->wordSize;
-	/* Check for match of sect name in overlay table */
-	for (i = 0; i < lib->nOvlySects; i++) {
-		name = lib->ppOvlyData[i]->hdr.pName;
-		if (!CSL_Strncmp(name, sectName, CSL_Strlen(name))) {
-			/* Match found */
-			status = DSP_SOK;
-			break;
-		}
-	}
-	if (DSP_SUCCEEDED(status)) {
-		DBC_Assert(i < lib->nOvlySects);
-		pOvlyData = lib->ppOvlyData[i];
-		/*
-		 *  If node overlay, phase will be encoded in name. If not node
-		 *  overlay, set phase to NONE.
-		 */
-		phase = (CSL_Strcmp(name, sectName)) ?
-			CSL_Atoi(sectName + CSL_Strlen(sectName) - 1) : NONE;
-		 /*  Get reference count of node phase to be loaded, offset into
-		 *  overlay data array, and number of sections to overlay.  */
-		switch (phase) {
-		case NONE:
-			/* Not a node overlay */
-			phaseRef = &pOvlyData->hdr.otherRef;
-			nSects = numOtherSects(pOvlyData);
-			offset = otherOffset(pOvlyData);
-			break;
-		case CREATEPHASE:
-			phaseRef = &pOvlyData->hdr.createRef;
-			otherRef = &pOvlyData->hdr.otherRef;
-			if (*otherRef) {
-				/* The overlay sections where node phase was
-				 * not specified, have already been loaded.  */
-				nSects = numCreateSects(pOvlyData);
-				offset = createOffset(pOvlyData);
-			} else {
-				/* Overlay sections where node phase was not
-				 * specified get loaded at create time, along
-				 * with create sects.  */
-				nSects = numCreateSects(pOvlyData) +
-					 numOtherSects(pOvlyData);
-				offset = otherOffset(pOvlyData);
-			}
-			break;
-		case DELETEPHASE:
-			phaseRef = &pOvlyData->hdr.deleteRef;
-			nSects = numDeleteSects(pOvlyData);
-			offset = deleteOffset(pOvlyData);
-			break;
-		case EXECUTEPHASE:
-			phaseRef = &pOvlyData->hdr.executeRef;
-			nSects = numExecuteSects(pOvlyData);
-			offset = executeOffset(pOvlyData);
-			break;
-		default:
-			/* ERROR */
-			DBC_Assert(false);
-			break;
-		}
-		/* Do overlay if reference count is 0 */
-		if (!(*phaseRef)) {
-			/* "Allocate" all sections */
-			for (i = 0; i < nSects; i++) {
-				runAddr = pOvlyData->data[offset + i].runAddr;
-				size = pOvlyData->data[offset + i].size;
-				space = pOvlyData->data[offset + i].page;
-				status = (dbl->dblAttrs.alloc)(dbl->dblAttrs.
-					 rmmHandle, space, size, 0,
-					 &runAddr, true);
-				if (DSP_FAILED(status))
-					break;
-
-				allocdSects++;
-			}
-			if (DSP_SUCCEEDED(status)) {
-				/* Load sections */
-				for (i = 0; i < nSects; i++) {
-					loadAddr = pOvlyData->data[offset + i].
-						   loadAddr;
-					runAddr = pOvlyData->data[offset + i].
-						  runAddr;
-					size = pOvlyData->data[offset + i].
-						size;
-					space = pOvlyData->data[offset + i].
-						page;
-					/* Convert to word address, call
-					 * write function */
-					loadAddr /= (wordSize / mauSize);
-					runAddr /= (wordSize / mauSize);
-					ulBytes = size * mauSize;
-					if ((*attrs->write)(attrs->wHandle,
-					   runAddr, (void *)loadAddr, ulBytes,
-					   space) != ulBytes) {
-						GT_0trace(DBL_debugMask,
-							GT_6CLASS,
-							"DBL_loadSect: write"
-							" failed\n");
-						status = DSP_EFWRITE;
-						break;
-					}
-				}
-			}
-			/* Free sections on failure */
-			if (DSP_FAILED(status))
-				freeSects(dbl, pOvlyData, offset, allocdSects);
-
-		}
-	}
-	if (DSP_SUCCEEDED(status)) {
-		/* Increment reference counts */
-		if (otherRef)
-			*otherRef = *otherRef + 1;
-
-		*phaseRef = *phaseRef + 1;
-	}
-	return status;
-}
-
-/*
- *  ======== DBL_open ========
- *  Purpose:
- *  	DBL_open() returns a library handle that can be used to
- *  	load/unload the symbols/code/data via DBL_load()/DBL_unload().
- */
-DSP_STATUS DBL_open(struct DBL_TargetObj *target, char *file, DBL_Flags flags,
-		   struct DBL_LibraryObj **pLib)
-{
-	struct DBL_LibraryObj *pdblLib = NULL;
-	u16 nSymbols;
-	u16 nDCDSects;
-	DSP_STATUS status = DSP_SOK;
-	DBC_Require(cRefs > 0);
-	DBC_Require(MEM_IsValidHandle(target, DBL_TARGSIGNATURE));
-	DBC_Require(target->dblAttrs.fopen != NULL);
-	DBC_Require(file != NULL);
-	DBC_Require(pLib != NULL);
-
-	GT_3trace(DBL_debugMask, GT_ENTER, "DBL_open: target: 0x%x file: %s "
-		 "pLib: 0x%x\n", target, file, pLib);
-	/* Allocate DBL library object */
-	MEM_AllocObject(pdblLib, struct DBL_LibraryObj, DBL_LIBSIGNATURE);
-	if (pdblLib == NULL)
-		status = DSP_EMEMORY;
-
-	/* Open the file */
-	if (DSP_SUCCEEDED(status)) {
-		pdblLib->pTarget = target;
-		pdblLib->file = (*target->dblAttrs.fopen)(file, "rb");
-		if (pdblLib->file == NULL)
-			status = DSP_EFOPEN;
-
-	}
-	/* Read file header */
-	if (DSP_SUCCEEDED(status)) {
-		status = readHeader(target, pdblLib);
-		if (DSP_FAILED(status)) {
-			GT_0trace(DBL_debugMask, GT_6CLASS,
-				 "DBL_open(): Failed to read file header\n");
-		}
-	}
-	/* Allocate symbol table */
-	if (DSP_SUCCEEDED(status)) {
-		nSymbols = pdblLib->nSymbols = pdblLib->fileHdr.numSymbols;
-		pdblLib->symbols = MEM_Calloc(nSymbols * sizeof(struct Symbol),
-					     MEM_PAGED);
-		if (pdblLib->symbols == NULL)
-			status = DSP_EMEMORY;
-
-	}
-	/* Read all the symbols */
-	if (DSP_SUCCEEDED(status)) {
-		status = readSymbols(target, pdblLib);
-		if (DSP_FAILED(status)) {
-			GT_0trace(DBL_debugMask, GT_6CLASS,
-				 "DBL_open(): Failed to read symbols\n");
-		}
-	}
-	/* Allocate DCD sect table */
-	if (DSP_SUCCEEDED(status)) {
-		nDCDSects = pdblLib->nDCDSects = pdblLib->fileHdr.numDCDSects;
-		pdblLib->dcdSects = MEM_Calloc(nDCDSects *
-					 sizeof(struct DCDSect), MEM_PAGED);
-		if (pdblLib->dcdSects == NULL)
-			status = DSP_EMEMORY;
-
-	}
-	/* Read DCD sections */
-	if (DSP_SUCCEEDED(status)) {
-		status = readDCDSects(target, pdblLib);
-		if (DSP_FAILED(status)) {
-			GT_0trace(DBL_debugMask, GT_6CLASS,
-				 "DBL_open(): Failed to read DCD sections\n");
-		}
-	}
-	/* Read overlay sections */
-	if (DSP_SUCCEEDED(status)) {
-		status = readOvlySects(target, pdblLib);
-		if (DSP_FAILED(status)) {
-			GT_0trace(DBL_debugMask, GT_6CLASS,
-				 "DBL_open(): Failed to read "
-				 "overlay sections\n");
-		}
-	}
-	if (DSP_FAILED(status)) {
-		*pLib = NULL;
-		if (pdblLib != NULL)
-			DBL_close((struct DBL_LibraryObj *) pdblLib);
-
-	} else {
-		*pLib = pdblLib;
-	}
-	DBC_Ensure((DSP_SUCCEEDED(status) &&
-		  (MEM_IsValidHandle((*pLib), DBL_LIBSIGNATURE))) ||
-		  (DSP_FAILED(status) && *pLib == NULL));
-	return status;
-}
-
-/*
- *  ======== DBL_readSect ========
- *  Purpose:
- *  	Read COFF section into a character buffer.
- */
-DSP_STATUS DBL_readSect(struct DBL_LibraryObj *lib, char *name, char *pContent,
-			u32 size)
-{
-	struct DBL_LibraryObj *pdblLib = (struct DBL_LibraryObj *)lib;
-	u16 i;
-	u32 mauSize;
-	u32 max;
-	DSP_STATUS status = DSP_ENOSECT;
-
-	DBC_Require(cRefs > 0);
-	DBC_Require(MEM_IsValidHandle(pdblLib, DBL_LIBSIGNATURE));
-	DBC_Require(name != NULL);
-	DBC_Require(pContent != NULL);
-	DBC_Require(size != 0);
-	GT_4trace(DBL_debugMask, GT_ENTER, "DBL_readSect: lib: 0x%x name: %s "
-		 "pContent: 0x%x size: 0x%x\n", lib, name, pContent, size);
-
-	mauSize = pdblLib->pTargetInfo->mauSize;
-
-	/* Attempt to find match with DCD section names. */
-	for (i = 0; i < pdblLib->nDCDSects; i++) {
-		if (CSL_Strcmp(pdblLib->dcdSects[i].sectHdr.name, name) == 0) {
-			/* Match found */
-			max = pdblLib->dcdSects[i].sectHdr.size * mauSize;
-			max = (max > size) ? size : max;
-			memcpy(pContent, pdblLib->dcdSects[i].pData, max);
-			status = DSP_SOK;
-			break;
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== DBL_setAttrs ========
- *  Purpose:
- *  	Set the attributes of the target.
- */
-void DBL_setAttrs(struct DBL_TargetObj *target, struct DBL_Attrs *pAttrs)
-{
-	DBC_Require(cRefs > 0);
-	DBC_Require(MEM_IsValidHandle(target, DBL_TARGSIGNATURE));
-	DBC_Require(pAttrs != NULL);
-
-	GT_2trace(DBL_debugMask, GT_ENTER, "DBL_setAttrs: target: 0x%x pAttrs: "
-		 "0x%x\n", target, pAttrs);
-
-	target->dblAttrs = *pAttrs;
-}
-
-/*
- *  ======== DBL_unload ========
- *  Purpose:
- *  	Remove the symbols/code/data corresponding to the library lib.
- */
-void DBL_unload(struct DBL_LibraryObj *lib, struct DBL_Attrs *attrs)
-{
-	DBC_Require(cRefs > 0);
-	DBC_Require(MEM_IsValidHandle(lib, DBL_LIBSIGNATURE));
-
-	GT_1trace(DBL_debugMask, GT_ENTER, "DBL_unload: lib: 0x%x\n", lib);
-
-	/* Nothing to do for static loading */
-}
-
-/*
- *  ======== DBL_unloadSect ========
- *  Purpose:
- *  	Unload a named section from an library (for overlay support).
- */
-DSP_STATUS DBL_unloadSect(struct DBL_LibraryObj *lib, char *sectName,
-			  struct DBL_Attrs *attrs)
-{
-	struct DBL_TargetObj *dbl;
-	s32 i;
-	s32 phase;
-	s32 offset = -1;
-	s32 nSects = -1;
-	u16 *phaseRef = NULL;
-	u16 *otherRef = NULL;
-	char *pName = NULL;
-	struct OvlyData *pOvlyData;
-	DSP_STATUS status = DSP_ENOSECT;
-
-	DBC_Require(cRefs > 0);
-	DBC_Require(MEM_IsValidHandle(lib, DBL_LIBSIGNATURE));
-	DBC_Require(sectName != NULL);
-
-	GT_2trace(DBL_debugMask, GT_ENTER,
-		 "DBL_unloadSect: lib: 0x%x sectName: %s\n", lib, sectName);
-	dbl = lib->pTarget;
-	/* Check for match of sect name in overlay table */
-	for (i = 0; i < lib->nOvlySects; i++) {
-		pName = lib->ppOvlyData[i]->hdr.pName;
-		if (!CSL_Strncmp(pName, sectName, CSL_Strlen(pName))) {
-			/* Match found */
-			status = DSP_SOK;
-			break;
-		}
-	}
-	if (DSP_SUCCEEDED(status)) {
-		DBC_Assert(i < lib->nOvlySects);
-		pOvlyData = lib->ppOvlyData[i];
-		/* If node overlay, phase will be encoded in name. */
-		phase = (CSL_Strcmp(pName, sectName)) ?
-			CSL_Atoi(sectName + CSL_Strlen(sectName) - 1) : NONE;
-		switch (phase) {
-		case NONE:
-			nSects = numOtherSects(pOvlyData);
-			phaseRef = &pOvlyData->hdr.otherRef;
-			offset = otherOffset(pOvlyData);
-			break;
-		case CREATEPHASE:
-			nSects = numCreateSects(pOvlyData);
-			offset = createOffset(pOvlyData);
-			phaseRef = &pOvlyData->hdr.createRef;
-			break;
-		case DELETEPHASE:
-			nSects = numDeleteSects(pOvlyData);
-			offset = deleteOffset(pOvlyData);
-			phaseRef = &pOvlyData->hdr.deleteRef;
-			otherRef = &pOvlyData->hdr.otherRef;
-			break;
-		case EXECUTEPHASE:
-			nSects = numExecuteSects(pOvlyData);
-			offset = executeOffset(pOvlyData);
-			phaseRef = &pOvlyData->hdr.executeRef;
-			break;
-		default:
-			/* ERROR */
-			DBC_Assert(false);
-			break;
-		}
-		if (*phaseRef) {
-			*phaseRef = *phaseRef - 1;
-			if (*phaseRef == 0) {
-				/* Unload overlay sections for phase */
-				freeSects(dbl, pOvlyData, offset, nSects);
-			}
-			if (phase == DELETEPHASE) {
-				DBC_Assert(*otherRef);
-				*otherRef = *otherRef - 1;
-				if (*otherRef == 0) {
-					/* Unload other overlay sections */
-					nSects = numOtherSects(pOvlyData);
-					offset = otherOffset(pOvlyData);
-					freeSects(dbl, pOvlyData, offset,
-						 nSects);
-				}
-			}
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== freeSects ========
- *  Purpose:
- *  	Free section
- */
-static void freeSects(struct DBL_TargetObj *dbl, struct OvlyData *pOvlyData,
-		     s32 offset, s32 nSects)
-{
-	u32 runAddr;
-	u32 size;
-	u32 space;
-	s32 i;
-
-	for (i = 0; i < nSects; i++) {
-		runAddr = pOvlyData->data[offset + i].runAddr;
-		size = pOvlyData->data[offset + i].size;
-		space = pOvlyData->data[offset + i].page;
-		if (!(dbl->dblAttrs.free)
-		    (dbl->dblAttrs.rmmHandle, space, runAddr, size, true)) {
-			/*
-			 *  Free function will not fail for overlay, unless
-			 *  address passed in is bad.
-			 */
-			DBC_Assert(false);
-		}
-	}
-}
-
-/*
- *  ======== loadSect ========
- *  Purpose:
- *  	Load section to target
- */
-static DSP_STATUS loadSect(struct DBL_TargetObj *dbl,
-			  struct DBL_LibraryObj *pdblLib)
-{
-	struct DBOF_SectHdr sectHdr;
-	char *pBuf;
-	struct KFILE_FileObj *file;
-	u32 space;
-	u32 addr;
-	u32 total;
-	u32 nWords = 0;
-	u32 nBytes = 0;
-	u16 mauSize;
-	u32 bufSize;
-	DSP_STATUS status = DSP_SOK;
-
-	file = pdblLib->file;
-	mauSize = pdblLib->pTargetInfo->mauSize;
-	bufSize = LOADBUFSIZE / mauSize;
-	pBuf = dbl->pBuf;
-
-	/* Read the section header */
-	if ((*dbl->dblAttrs.fread)(&sectHdr, sizeof(struct DBOF_SectHdr),
-	   1, file) != 1) {
-		GT_0trace(DBL_debugMask, GT_6CLASS,
-			 "Failed to read DCD sect header\n");
-		status = DSP_EFREAD;
-	} else {
-		if (pdblLib->byteSwapped) {
-			sectHdr.size = SWAPLONG(sectHdr.size);
-			sectHdr.addr = SWAPLONG(sectHdr.addr);
-			sectHdr.page = SWAPWORD(sectHdr.page);
-		}
-	}
-	if (DSP_SUCCEEDED(status)) {
-		addr = sectHdr.addr;
-		space = sectHdr.page;
-		for (total = sectHdr.size; total > 0; total -= nWords) {
-			nWords = min(total, bufSize);
-			nBytes = nWords * mauSize;
-			/* Read section data */
-			if ((*dbl->dblAttrs.fread)(pBuf, nBytes, 1,
-			   file) != 1) {
-				GT_0trace(DBL_debugMask, GT_6CLASS,
-					 "Failed to read DCD sect header\n");
-				status = DSP_EFREAD;
-				break;
-			}
-			/* Write section to target */
-			if (!(*dbl->dblAttrs.write)(dbl->dblAttrs.wHandle,
-			   addr, pBuf, nBytes, space)) {
-				GT_0trace(DBL_debugMask, GT_6CLASS,
-					 "Failed to write section data\n");
-				status = DSP_EFWRITE;
-				break;
-			}
-			addr += nWords;
-		}
-	}
-	return status;
-}
-
-/*
- *  ======== readDCDSects ========
- *  Purpose:
- *  	Read DCD sections.
- */
-static DSP_STATUS readDCDSects(struct DBL_TargetObj *dbl,
-			      struct DBL_LibraryObj *pdblLib)
-{
-	struct DBOF_DCDSectHdr *pSectHdr;
-	struct DCDSect *pSect;
-	struct KFILE_FileObj *file;
-	u16 nSects;
-	u16 i;
-	u16 mauSize;
-	DSP_STATUS status = DSP_SOK;
-
-	file = pdblLib->file;
-	mauSize = pdblLib->pTargetInfo->mauSize;
-	nSects = pdblLib->fileHdr.numDCDSects;
-	for (i = 0; i < nSects; i++) {
-		pSect = &pdblLib->dcdSects[i];
-		pSectHdr = &pdblLib->dcdSects[i].sectHdr;
-		/* Read sect header */
-		if ((*dbl->dblAttrs.fread)(pSectHdr,
-		   sizeof(struct DBOF_DCDSectHdr), 1, file) != 1) {
-			GT_0trace(DBL_debugMask, GT_6CLASS,
-				 "Failed to read DCD sect header\n");
-			status = DSP_EFREAD;
-			break;
-		}
-		if (pdblLib->byteSwapped)
-			pSectHdr->size = SWAPLONG(pSectHdr->size);
-
-		pSect->pData = (char *)MEM_Calloc(pSectHdr->size *
-				mauSize, MEM_PAGED);
-		if (pSect->pData == NULL) {
-			GT_2trace(DBL_debugMask, GT_6CLASS,
-				 "Memory allocation for sect %s "
-				 "data failed: Size: 0x%lx\n", pSectHdr->name,
-				 pSectHdr->size);
-			status = DSP_EMEMORY;
-			break;
-		}
-		/* Read DCD sect data */
-		if ((*dbl->dblAttrs.fread)(pSect->pData, mauSize,
-		   pSectHdr->size, file) != pSectHdr->size) {
-			GT_0trace(DBL_debugMask, GT_6CLASS,
-				  "Failed to read DCD sect data\n");
-			status = DSP_EFREAD;
-			break;
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== readHeader ========
- *  Purpose:
- *  	Read Header.
- */
-static DSP_STATUS readHeader(struct DBL_TargetObj *dbl,
-			    struct DBL_LibraryObj *pdblLib)
-{
-	struct KFILE_FileObj *file;
-	s32 i;
-	struct DBOF_FileHdr *pHdr;
-	u32 swapMagic;
-	DSP_STATUS status = DSP_SOK;
-
-	pdblLib->byteSwapped = false;
-	file = pdblLib->file;
-	pHdr = &pdblLib->fileHdr;
-	if ((*dbl->dblAttrs.fread)(pHdr, sizeof(struct DBOF_FileHdr), 1,
-	   file) != 1) {
-		GT_0trace(DBL_debugMask, GT_6CLASS,
-			 "readHeader: Failed to read file header\n");
-		status = DSP_EFREAD;
-	}
-
-	if (DSP_SUCCEEDED(status)) {
-		/* Determine if byte swapped */
-		for (i = 0; i < NUMTARGS; i++) {
-			swapMagic = SWAPLONG(pHdr->magic);
-			if (pHdr->magic == magicTab[i] || swapMagic ==
-			   magicTab[i]) {
-				if (swapMagic == magicTab[i]) {
-					pdblLib->byteSwapped = true;
-					pHdr->magic = SWAPLONG(pHdr->magic);
-					pHdr->entry = SWAPLONG(pHdr->entry);
-					pHdr->symOffset = SWAPLONG(pHdr->
-								symOffset);
-					pHdr->dcdSectOffset = SWAPLONG(pHdr->
-								dcdSectOffset);
-					pHdr->loadSectOffset = SWAPLONG(pHdr->
-								loadSectOffset);
-					pHdr->ovlySectOffset = SWAPLONG(pHdr->
-								ovlySectOffset);
-					pHdr->numSymbols = SWAPWORD(pHdr->
-								numSymbols);
-					pHdr->numDCDSects = SWAPWORD(pHdr->
-								numDCDSects);
-					pHdr->numSects = SWAPWORD(pHdr->
-								numSects);
-					pHdr->numOvlySects = SWAPWORD(pHdr->
-								numOvlySects);
-				}
-				break;
-			}
-		}
-		if (i == NUMTARGS) {
-			GT_0trace(DBL_debugMask, GT_6CLASS,
-				 "readHeader: Failed to determine"
-				 " target type\n");
-			status = DSP_ECORRUPTFILE;
-		} else {
-			pdblLib->pTargetInfo = &targetTab[i];
-			GT_1trace(DBL_debugMask, GT_ENTER,
-				 "COF type: 0x%lx\n", pHdr->magic);
-			GT_1trace(DBL_debugMask, GT_ENTER,
-				 "Entry point:0x%lx\n", pHdr->entry);
-		}
-	}
-	return status;
-}
-
-/*
- *  ======== readOvlySects ========
- *  Purpose:
- *  	Read Overlay Sections
- */
-static DSP_STATUS readOvlySects(struct DBL_TargetObj *dbl,
-				struct DBL_LibraryObj *pdblLib)
-{
-	struct DBOF_OvlySectHdr hdr;
-	struct DBOF_OvlySectData *pData;
-	struct OvlyData *pOvlyData;
-	char *pName;
-	struct KFILE_FileObj *file;
-	u16 i, j;
-	u16 nSects;
-	u16 n;
-	DSP_STATUS status = DSP_SOK;
-
-	pdblLib->nOvlySects = nSects = pdblLib->fileHdr.numOvlySects;
-	file = pdblLib->file;
-	if (nSects > 0) {
-		pdblLib->ppOvlyData = MEM_Calloc(nSects * sizeof(OvlyData *),
-						 MEM_PAGED);
-		if (pdblLib->ppOvlyData == NULL) {
-			GT_0trace(DBL_debugMask, GT_7CLASS,
-				 "Failed to allocatate overlay "
-				 "data memory\n");
-			status = DSP_EMEMORY;
-		}
-	}
-	if (DSP_SUCCEEDED(status)) {
-		/* Read overlay data for each node */
-		for (i = 0; i < nSects; i++) {
-			/* Read overlay section header */
-			if ((*dbl->dblAttrs.fread)(&hdr,
-			   sizeof(struct DBOF_OvlySectHdr), 1, file) != 1) {
-				GT_0trace(DBL_debugMask, GT_6CLASS,
-					 "Failed to read overlay sect"
-					 " header\n");
-				status = DSP_EFREAD;
-				break;
-			}
-			if (pdblLib->byteSwapped) {
-				hdr.nameLen = SWAPWORD(hdr.nameLen);
-				hdr.numCreateSects =
-						SWAPWORD(hdr.numCreateSects);
-				hdr.numDeleteSects =
-						SWAPWORD(hdr.numDeleteSects);
-				hdr.numExecuteSects =
-						SWAPWORD(hdr.numExecuteSects);
-				hdr.numOtherSects =
-						SWAPWORD(hdr.numOtherSects);
-				hdr.resvd = SWAPWORD(hdr.resvd);
-			}
-			n = hdr.numCreateSects + hdr.numDeleteSects +
-			    hdr.numExecuteSects + hdr.numOtherSects;
-
-			/* Allocate memory for node's overlay data */
-			pOvlyData = (struct OvlyData *)MEM_Calloc
-				    (sizeof(struct OvlyHdr) +
-				    n * sizeof(struct DBOF_OvlySectData),
-				    MEM_PAGED);
-			if (pOvlyData == NULL) {
-				GT_0trace(DBL_debugMask, GT_7CLASS,
-					 "Failed to allocatate ovlyay"
-					 " data memory\n");
-				status = DSP_EMEMORY;
-				break;
-			}
-			pOvlyData->hdr.dbofHdr = hdr;
-			pdblLib->ppOvlyData[i] = pOvlyData;
-			/* Allocate memory for section name */
-			pName = (char *)MEM_Calloc(hdr.nameLen + 1, MEM_PAGED);
-			if (pName == NULL) {
-				GT_0trace(DBL_debugMask, GT_7CLASS,
-					 "Failed to allocatate ovlyay"
-					 " section name\n");
-				status = DSP_EMEMORY;
-				break;
-			}
-			pOvlyData->hdr.pName = pName;
-			/* Read the overlay section name */
-			if ((*dbl->dblAttrs.fread)(pName, sizeof(char),
-			   hdr.nameLen, file) != hdr.nameLen) {
-				GT_0trace(DBL_debugMask, GT_7CLASS,
-					 "readOvlySects: Unable to "
-					 "read overlay name.\n");
-				status = DSP_EFREAD;
-				break;
-			}
-			/* Read the overlay section data */
-			pData = pOvlyData->data;
-			if ((*dbl->dblAttrs.fread)(pData,
-			   sizeof(struct DBOF_OvlySectData), n, file) != n) {
-				GT_0trace(DBL_debugMask, GT_7CLASS,
-					 "readOvlySects: Unable to "
-					 "read overlay data.\n");
-				status = DSP_EFREAD;
-				break;
-			}
-			/* Swap overlay data, if necessary */
-			if (pdblLib->byteSwapped) {
-				for (j = 0; j < n; j++) {
-					pData[j].loadAddr =
-						 SWAPLONG(pData[j].loadAddr);
-					pData[j].runAddr =
-						 SWAPLONG(pData[j].runAddr);
-					pData[j].size =
-						 SWAPLONG(pData[j].size);
-					pData[j].page =
-						 SWAPWORD(pData[j].page);
-				}
-			}
-		}
-	}
-	return status;
-}
-
-/*
- *  ======== readSymbols ========
- *  Purpose:
- *  	Read Symbols
- */
-static DSP_STATUS readSymbols(struct DBL_TargetObj *dbl,
-			     struct DBL_LibraryObj *pdblLib)
-{
-	struct DBOF_SymbolHdr symHdr;
-	struct KFILE_FileObj *file;
-	u16 i;
-	u16 nSymbols;
-	u16 len;
-	char *pName = NULL;
-	DSP_STATUS status = DSP_SOK;
-
-	file = pdblLib->file;
-
-	nSymbols = pdblLib->fileHdr.numSymbols;
-
-	for (i = 0; i < nSymbols; i++) {
-		/* Read symbol value */
-		if ((*dbl->dblAttrs.fread)(&symHdr,
-		   sizeof(struct DBOF_SymbolHdr), 1, file) != 1) {
-			GT_0trace(DBL_debugMask, GT_6CLASS,
-				 "Failed to read symbol value\n");
-			status = DSP_EFREAD;
-			break;
-		}
-		if (pdblLib->byteSwapped) {
-			symHdr.nameLen = SWAPWORD(symHdr.nameLen);
-			symHdr.value = SWAPLONG(symHdr.value);
-		}
-		/* Allocate buffer for symbol name */
-		len = symHdr.nameLen;
-		pName = (char *)MEM_Calloc(len + 1, MEM_PAGED);
-		if (pName == NULL) {
-			GT_0trace(DBL_debugMask, GT_6CLASS,
-				 "Memory allocation failed\n");
-			status = DSP_EMEMORY;
-			break;
-		}
-		pdblLib->symbols[i].pSymName = pName;
-		pdblLib->symbols[i].sym.value = symHdr.value;
-		/* Read symbol name */
-		if ((*dbl->dblAttrs.fread) (pName, sizeof(char), len, file) !=
-		   len) {
-			GT_0trace(DBL_debugMask, GT_6CLASS,
-				 "Failed to read symbol value\n");
-			status = DSP_EFREAD;
-			break;
-		} else {
-			pName[len] = '\0';
-			GT_2trace(DBL_debugMask, GT_ENTER,
-				 "Symbol: %s  Value: 0x%lx\n",
-				 pName, symHdr.value);
-		}
-	}
-	return status;
-}
-
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 16/17] DSPBRIDGE: Avoid REGistry if pDevContext is available
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
                   ` (14 preceding siblings ...)
  2009-12-15  6:19 ` [PATCH 15/17] DSPBRIDGE: Delete unused files Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15 18:21   ` Felipe Contreras
  2009-12-15  6:19 ` [PATCH 17/17] DSPBRIDGE: Compilation fixes 2.6.31 Omar Ramirez Luna
  2009-12-15 18:28 ` [PATCH 00/17] First set of unreviewed patches Felipe Contreras
  17 siblings, 1 reply; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos, Omar Ramirez Luna

Avoid calls to read the register if pDevContext is available
to the function, this will save a call to query and hold
a semaphore under registry operations.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 arch/arm/plat-omap/include/dspbridge/cfgdefs.h |    2 +-
 drivers/dsp/bridge/rmgr/drv.c                  |    2 +-
 drivers/dsp/bridge/wmd/_tiomap.h               |    8 +-
 drivers/dsp/bridge/wmd/mmu_fault.c             |   24 +---
 drivers/dsp/bridge/wmd/tiomap3430.c            |  182 +++++++++++-------------
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c        |  106 +++++----------
 drivers/dsp/bridge/wmd/tiomap_sm.c             |   50 +++----
 drivers/dsp/bridge/wmd/ue_deh.c                |   15 +--
 8 files changed, 156 insertions(+), 233 deletions(-)

diff --git a/arch/arm/plat-omap/include/dspbridge/cfgdefs.h b/arch/arm/plat-omap/include/dspbridge/cfgdefs.h
index 0155e13..bce1c5e 100644
--- a/arch/arm/plat-omap/include/dspbridge/cfgdefs.h
+++ b/arch/arm/plat-omap/include/dspbridge/cfgdefs.h
@@ -90,7 +90,7 @@
 		void __iomem *dwPrmBase;
 		void __iomem *dwCmBase;
 		void __iomem *dwPerBase;
-		u32 dwPerPmBase;
+		void __iomem *dwPerPmBase;
 		u32 dwCorePmBase;
 		void __iomem *dwWdTimerDspBase;
 		void __iomem *dwMboxBase;
diff --git a/drivers/dsp/bridge/rmgr/drv.c b/drivers/dsp/bridge/rmgr/drv.c
index 74388d5..a485d03 100644
--- a/drivers/dsp/bridge/rmgr/drv.c
+++ b/drivers/dsp/bridge/rmgr/drv.c
@@ -1807,7 +1807,7 @@ static DSP_STATUS RequestBridgeResourcesDSP(u32 dwContext, s32 bRequest)
 							OMAP_DSP_MEM3_SIZE);
 		pResources->dwPerBase = ioremap(OMAP_PER_CM_BASE,
 							OMAP_PER_CM_SIZE);
-               pResources->dwPerPmBase = (u32)ioremap(OMAP_PER_PRM_BASE,
+		pResources->dwPerPmBase = ioremap(OMAP_PER_PRM_BASE,
                                                        OMAP_PER_PRM_SIZE);
                pResources->dwCorePmBase = (u32)ioremap(OMAP_CORE_PRM_BASE,
                                                        OMAP_CORE_PRM_SIZE);
diff --git a/drivers/dsp/bridge/wmd/_tiomap.h b/drivers/dsp/bridge/wmd/_tiomap.h
index 96bf7d3..186f476 100644
--- a/drivers/dsp/bridge/wmd/_tiomap.h
+++ b/drivers/dsp/bridge/wmd/_tiomap.h
@@ -340,8 +340,12 @@ struct WMD_DEV_CONTEXT {
 	 */
 	u32 dwDspExtBaseAddr;	/* See the comment above        */
 	u32 dwAPIRegBase;	/* API memory mapped registers  */
-	void __iomem *dwDSPMmuBase;	/* DSP MMU Mapped registers     */
-	u32 dwMailBoxBase;	/* Mail box mapped registers    */
+	void __iomem *dwDSPMmuBase;	/* DSP MMU Mapped registers */
+	void __iomem *dwMailBoxBase;	/* Mail box mapped registers */
+	void __iomem *cmbase;			/* CM mapped registers */
+	void __iomem *sysctrlbase;		/* SysCtrl mapped registers */
+	void __iomem *prmbase;			/* PRM mapped registers	*/
+	void __iomem *perbase;			/* PER mapped registers	*/
 	u32 dwAPIClkBase;	/* CLK Registers                */
 	u32 dwDSPClkM2Base;	/* DSP Clock Module m2          */
 	u32 dwPublicRhea;	/* Pub Rhea                     */
diff --git a/drivers/dsp/bridge/wmd/mmu_fault.c b/drivers/dsp/bridge/wmd/mmu_fault.c
index 5585cdb..147e5b3 100644
--- a/drivers/dsp/bridge/wmd/mmu_fault.c
+++ b/drivers/dsp/bridge/wmd/mmu_fault.c
@@ -90,24 +90,13 @@ irqreturn_t  MMU_FaultIsr(int irq, IN void *pRefData)
 {
 	struct DEH_MGR *pDehMgr = (struct DEH_MGR *)pRefData;
 	struct WMD_DEV_CONTEXT *pDevContext;
-	struct CFG_HOSTRES resources;
-	DSP_STATUS status = DSP_SOK;
-
 
 	DBG_Trace(DBG_LEVEL1, "Entering DEH_DspMmuIsr: 0x%x\n", pRefData);
        DBC_Require(irq == INT_DSP_MMU_IRQ);
 	DBC_Require(MEM_IsValidHandle(pDehMgr, SIGNATURE));
 
 	if (MEM_IsValidHandle(pDehMgr, SIGNATURE)) {
-
 		pDevContext = (struct WMD_DEV_CONTEXT *)pDehMgr->hWmdContext;
-		status = CFG_GetHostResources(
-			 (struct CFG_DEVNODE *)DRV_GetFirstDevExtension(),
-			 &resources);
-		if (DSP_FAILED(status))
-			DBG_Trace(DBG_LEVEL7,
-				 "**Failed to get Host Resources "
-				 "in MMU ISR **\n");
 		if (MMU_CheckIfFault(pDevContext)) {
 			printk(KERN_INFO "***** DSPMMU FAULT ***** IRQStatus "
 				"0x%x\n", dmmuEventMask);
@@ -128,13 +117,13 @@ irqreturn_t  MMU_FaultIsr(int irq, IN void *pRefData)
 			pDehMgr->errInfo.dwVal3 = 0L;
 			/* Disable the MMU events, else once we clear it will
 			 * start to raise INTs again */
-			HW_MMU_EventDisable(resources.dwDmmuBase,
+			HW_MMU_EventDisable(pDevContext->dwDSPMmuBase,
 					    HW_MMU_TRANSLATION_FAULT);
 		} else {
 			DBG_Trace(DBG_LEVEL7,
 				 "***** MMU FAULT ***** faultcode 0x%x\n",
 				 dmmuEventMask);
-			HW_MMU_EventDisable(resources.dwDmmuBase,
+			HW_MMU_EventDisable(pDevContext->dwDSPMmuBase,
 					    HW_MMU_ALL_INTERRUPTS);
 		}
 	}
@@ -154,16 +143,15 @@ static bool MMU_CheckIfFault(struct WMD_DEV_CONTEXT *pDevContext)
 	bool retVal = false;
 	DSP_STATUS status = DSP_SOK;
 	HW_STATUS hwStatus;
-	struct CFG_HOSTRES resources;
-	status = CFG_GetHostResources(
-		(struct CFG_DEVNODE *)DRV_GetFirstDevExtension(), &resources);
+
 	if (DSP_FAILED(status))
 		DBG_Trace(DBG_LEVEL7, "**Failed to get Host Resources in "
 			 "MMU_CheckIfFault **\n");
 
-	hwStatus = HW_MMU_EventStatus(resources.dwDmmuBase, &dmmuEventMask);
+	hwStatus = HW_MMU_EventStatus(pDevContext->dwDSPMmuBase,
+								&dmmuEventMask);
 	if (dmmuEventMask  ==  HW_MMU_TRANSLATION_FAULT) {
-		HW_MMU_FaultAddrRead(resources.dwDmmuBase, &faultAddr);
+		HW_MMU_FaultAddrRead(pDevContext->dwDSPMmuBase, &faultAddr);
 		DBG_Trace(DBG_LEVEL1, "WMD_DEH_Notify: DSP_MMUFAULT, fault "
 			 "address = 0x%x\n", faultAddr);
 		retVal = true;
diff --git a/drivers/dsp/bridge/wmd/tiomap3430.c b/drivers/dsp/bridge/wmd/tiomap3430.c
index f41763c..0650a46 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430.c
@@ -275,12 +275,9 @@ static inline void tlb_flush_all(const void __iomem *base)
 
 static inline void flush_all(struct WMD_DEV_CONTEXT *pDevContext)
 {
-	struct CFG_HOSTRES resources;
 	u32 temp = 0;
 
-	CFG_GetHostResources((struct CFG_DEVNODE *)DRV_GetFirstDevExtension(),
-				&resources);
-	HW_PWRST_IVA2RegGet(resources.dwPrmBase, &temp);
+	HW_PWRST_IVA2RegGet(pDevContext->prmbase, &temp);
 
 	if ((temp & HW_PWR_STATE_ON) == HW_PWR_STATE_OFF ||
 	    (temp & HW_PWR_STATE_ON) == HW_PWR_STATE_RET) {
@@ -336,47 +333,42 @@ void WMD_DRV_Entry(OUT struct WMD_DRV_INTERFACE **ppDrvInterface,
  */
 static DSP_STATUS WMD_BRD_Monitor(struct WMD_DEV_CONTEXT *hDevContext)
 {
-	DSP_STATUS status = DSP_SOK;
 	struct WMD_DEV_CONTEXT *pDevContext = hDevContext;
-	struct CFG_HOSTRES resources;
 	u32 temp;
 	enum HW_PwrState_t    pwrState;
 
 	DBG_Trace(DBG_ENTER, "Board in the monitor state  \n");
-	status = CFG_GetHostResources(
-		 (struct CFG_DEVNODE *)DRV_GetFirstDevExtension(), &resources);
-	if (DSP_FAILED(status))
-		goto error_return;
 
-	GetHWRegs(resources.dwPrmBase, resources.dwCmBase);
-	HW_PWRST_IVA2RegGet(resources.dwPrmBase, &temp);
+	GetHWRegs(pDevContext->prmbase, pDevContext->cmbase);
+	HW_PWRST_IVA2RegGet(pDevContext->prmbase, &temp);
 	if ((temp & 0x03) != 0x03 || (temp & 0x03) != 0x02) {
 		/* IVA2 is not in ON state */
 		/* Read and set PM_PWSTCTRL_IVA2  to ON */
-		HW_PWR_IVA2PowerStateSet(resources.dwPrmBase,
+		HW_PWR_IVA2PowerStateSet(pDevContext->prmbase,
 					  HW_PWR_DOMAIN_DSP,
 					  HW_PWR_STATE_ON);
 		/* Set the SW supervised state transition */
-		HW_PWR_CLKCTRL_IVA2RegSet(resources.dwCmBase, HW_SW_SUP_WAKEUP);
+		HW_PWR_CLKCTRL_IVA2RegSet(pDevContext->cmbase,
+							HW_SW_SUP_WAKEUP);
 		/* Wait until the state has moved to ON */
-		HW_PWR_IVA2StateGet(resources.dwPrmBase, HW_PWR_DOMAIN_DSP,
+		HW_PWR_IVA2StateGet(pDevContext->prmbase, HW_PWR_DOMAIN_DSP,
 				     &pwrState);
 		/* Disable Automatic transition */
-		HW_PWR_CLKCTRL_IVA2RegSet(resources.dwCmBase, HW_AUTOTRANS_DIS);
+		HW_PWR_CLKCTRL_IVA2RegSet(pDevContext->cmbase,
+							HW_AUTOTRANS_DIS);
 	}
 	DBG_Trace(DBG_LEVEL6, "WMD_BRD_Monitor - Middle ****** \n");
-	GetHWRegs(resources.dwPrmBase, resources.dwCmBase);
-	HW_RST_UnReset(resources.dwPrmBase, HW_RST2_IVA2);
+	GetHWRegs(pDevContext->prmbase, pDevContext->cmbase);
+	HW_RST_UnReset(pDevContext->prmbase, HW_RST2_IVA2);
 	CLK_Enable(SERVICESCLK_iva2_ck);
 
-	if (DSP_SUCCEEDED(status)) {
-		/* set the device state to IDLE */
-		pDevContext->dwBrdState = BRD_IDLE;
-	}
-error_return:
+	/* set the device state to IDLE */
+	pDevContext->dwBrdState = BRD_IDLE;
+
 	DBG_Trace(DBG_LEVEL6, "WMD_BRD_Monitor - End ****** \n");
-	GetHWRegs(resources.dwPrmBase, resources.dwCmBase);
-	return status;
+	GetHWRegs(pDevContext->prmbase, pDevContext->cmbase);
+
+	return DSP_SOK;
 }
 
 /*
@@ -458,7 +450,6 @@ static DSP_STATUS WMD_BRD_Start(struct WMD_DEV_CONTEXT *hDevContext,
 	u32 ulShmOffsetVirt;	/* offset of ulShmBaseVirt from ulTLBBaseVirt */
 	s32 iEntryNdx;
 	s32 itmpEntryNdx = 0;	/* DSP-MMU TLB entry base address */
-	struct CFG_HOSTRES resources;
 	u32 temp;
 	u32 ulDspClkRate;
 	u32 ulDspClkAddr;
@@ -499,44 +490,36 @@ static DSP_STATUS WMD_BRD_Start(struct WMD_DEV_CONTEXT *hDevContext,
 	} else
 		*((volatile u32 *)dwSyncAddr) = 0xffffffff;
 
+	/* TODO: Reduce indentation as this can goto to end */
 	if (DSP_SUCCEEDED(status)) {
-		status = CFG_GetHostResources(
-			(struct CFG_DEVNODE *)DRV_GetFirstDevExtension(),
-			&resources);
 		/* Assert RST1 i.e only the RST only for DSP megacell  */
-		/* HW_RST_Reset(resources.dwPrcmBase, HW_RST1_IVA2);*/
-		if (DSP_SUCCEEDED(status)) {
-			HW_RST_Reset(resources.dwPrmBase, HW_RST1_IVA2);
-			if (dsp_debug) {
-				/* Set the bootmode to self loop  */
-				DBG_Trace(DBG_LEVEL7,
-						"Set boot mode to self loop"
-						" for IVA2 Device\n");
-				HW_DSPSS_BootModeSet(resources.dwSysCtrlBase,
-					HW_DSPSYSC_SELFLOOPBOOT, dwDSPAddr);
-			} else {
-				/* Set the bootmode to '0' - direct boot */
-				DBG_Trace(DBG_LEVEL7,
-						"Set boot mode to direct"
-						" boot for IVA2 Device \n");
-				HW_DSPSS_BootModeSet(resources.dwSysCtrlBase,
-					HW_DSPSYSC_DIRECTBOOT, dwDSPAddr);
-			}
+		HW_RST_Reset(pDevContext->prmbase, HW_RST1_IVA2);
+		if (dsp_debug) {
+			/* Set the bootmode to self loop  */
+			DBG_Trace(DBG_LEVEL7,
+				"Set boot mode to self loop for IVA2 Device\n");
+			HW_DSPSS_BootModeSet(pDevContext->sysctrlbase,
+				HW_DSPSYSC_SELFLOOPBOOT, dwDSPAddr);
+		} else {
+			/* Set the bootmode to '0' - direct boot */
+			DBG_Trace(DBG_LEVEL7,
+					"Set boot mode to direct"
+					" boot for IVA2 Device \n");
+			HW_DSPSS_BootModeSet(pDevContext->sysctrlbase,
+				HW_DSPSYSC_DIRECTBOOT, dwDSPAddr);
 		}
-	}
-	if (DSP_SUCCEEDED(status)) {
 		/* Reset and Unreset the RST2, so that BOOTADDR is copied to
 		 * IVA2 SYSC register */
-		HW_RST_Reset(resources.dwPrmBase, HW_RST2_IVA2);
+		HW_RST_Reset(pDevContext->prmbase, HW_RST2_IVA2);
 		udelay(100);
-		HW_RST_UnReset(resources.dwPrmBase, HW_RST2_IVA2);
+		HW_RST_UnReset(pDevContext->prmbase, HW_RST2_IVA2);
 		udelay(100);
 		DBG_Trace(DBG_LEVEL6, "WMD_BRD_Start 0 ****** \n");
-		GetHWRegs(resources.dwPrmBase, resources.dwCmBase);
+		GetHWRegs(pDevContext->prmbase, pDevContext->cmbase);
 		/* Disbale the DSP MMU */
-		HW_MMU_Disable(resources.dwDmmuBase);
+		HW_MMU_Disable(pDevContext->dwDSPMmuBase);
 		/* Disable TWL */
-		HW_MMU_TWLDisable(resources.dwDmmuBase);
+		HW_MMU_TWLDisable(pDevContext->dwDSPMmuBase);
 
 		/* Only make TLB entry if both addresses are non-zero */
 		for (iEntryNdx = 0; iEntryNdx < WMDIOCTL_NUMOFMMUTLB;
@@ -562,39 +545,35 @@ static DSP_STATUS WMD_BRD_Start(struct WMD_DEV_CONTEXT *hDevContext,
 				itmpEntryNdx++;
 			}
 		}		/* end for */
-	}
 
-	/* Lock the above TLB entries and get the BIOS and load monitor timer
-	 * information*/
-	if (DSP_SUCCEEDED(status)) {
-		HW_MMU_NumLockedSet(resources.dwDmmuBase, itmpEntryNdx);
-		HW_MMU_VictimNumSet(resources.dwDmmuBase, itmpEntryNdx);
-		HW_MMU_TTBSet(resources.dwDmmuBase,
+		/*
+		 * Lock the above TLB entries and get the BIOS and load monitor
+		 * timer information
+		 */
+		HW_MMU_NumLockedSet(pDevContext->dwDSPMmuBase, itmpEntryNdx);
+		HW_MMU_VictimNumSet(pDevContext->dwDSPMmuBase, itmpEntryNdx);
+		HW_MMU_TTBSet(pDevContext->dwDSPMmuBase,
 				pDevContext->pPtAttrs->L1BasePa);
-		HW_MMU_TWLEnable(resources.dwDmmuBase);
-		/* Enable the SmartIdle and AutoIdle bit for MMU_SYSCONFIG */
+		HW_MMU_TWLEnable(pDevContext->dwDSPMmuBase);
 
-
-		temp = __raw_readl((resources.dwDmmuBase) + 0x10);
+		/* Enable the SmartIdle and AutoIdle bit for MMU_SYSCONFIG */
+		temp = __raw_readl((pDevContext->dwDSPMmuBase) + 0x10);
 		temp = (temp & 0xFFFFFFEF) | 0x11;
-		__raw_writel(temp, (resources.dwDmmuBase) + 0x10);
+		__raw_writel(temp, (pDevContext->dwDSPMmuBase) + 0x10);
 
 		/* Let the DSP MMU run */
-		HW_MMU_Enable(resources.dwDmmuBase);
+		HW_MMU_Enable(pDevContext->dwDSPMmuBase);
 
 		/* Enable the BIOS clock  */
 		(void)DEV_GetSymbol(pDevContext->hDevObject,
-					BRIDGEINIT_BIOSGPTIMER,
-				     &ulBiosGpTimer);
+					BRIDGEINIT_BIOSGPTIMER, &ulBiosGpTimer);
 		DBG_Trace(DBG_LEVEL7, "BIOS GPTimer : 0x%x\n", ulBiosGpTimer);
 		(void)DEV_GetSymbol(pDevContext->hDevObject,
 				BRIDGEINIT_LOADMON_GPTIMER,
-				     &ulLoadMonitorTimer);
+				&ulLoadMonitorTimer);
 		DBG_Trace(DBG_LEVEL7, "Load Monitor Timer : 0x%x\n",
 			  ulLoadMonitorTimer);
-	}
 
-	if (DSP_SUCCEEDED(status)) {
 		if (ulLoadMonitorTimer != 0xFFFF) {
 			uClkCmd = (BPWR_DisableClock << MBX_PM_CLK_CMDSHIFT) |
 						ulLoadMonitorTimer;
@@ -605,7 +584,7 @@ static DSP_STATUS WMD_BRD_Start(struct WMD_DEV_CONTEXT *hDevContext,
 
 			extClkId = uClkCmd & MBX_PM_CLK_IDMASK;
 			for (tmpIndex = 0; tmpIndex < MBX_PM_MAX_RESOURCES;
-				       tmpIndex++) {
+								tmpIndex++) {
 				if (extClkId == BPWR_CLKID[tmpIndex]) {
 					clkIdIndex = tmpIndex;
 					break;
@@ -613,8 +592,8 @@ static DSP_STATUS WMD_BRD_Start(struct WMD_DEV_CONTEXT *hDevContext,
 			}
 
 			if (clkIdIndex < MBX_PM_MAX_RESOURCES)
-				status = CLK_Set_32KHz(
-						BPWR_Clks[clkIdIndex].funClk);
+				status = CLK_Set_32KHz(BPWR_Clks[clkIdIndex].
+									funClk);
 			else
 				status = DSP_EFAIL;
 
@@ -683,9 +662,9 @@ static DSP_STATUS WMD_BRD_Start(struct WMD_DEV_CONTEXT *hDevContext,
 					"_BRIDGEINIT_DSP_FREQ", &ulDspClkAddr);
 		/*Set Autoidle Mode for IVA2 PLL */
 		temp = (u32) *((REG_UWORD32 *)
-			((u32) (resources.dwCmBase) + 0x34));
+			((u32) (pDevContext->cmbase) + 0x34));
 		temp = (temp & 0xFFFFFFFE) | 0x1;
-		*((REG_UWORD32 *) ((u32) (resources.dwCmBase) + 0x34)) =
+		*((REG_UWORD32 *) ((u32) (pDevContext->cmbase) + 0x34)) =
 			(u32) temp;
 		DBG_Trace(DBG_LEVEL5, "WMD_BRD_Start: _BRIDGE_DSP_FREQ Addr:"
 				"0x%x \n", ulDspClkAddr);
@@ -701,29 +680,29 @@ static DSP_STATUS WMD_BRD_Start(struct WMD_DEV_CONTEXT *hDevContext,
 		}
 /*PM_IVA2GRPSEL_PER = 0xC0;*/
 		temp = (u32) *((REG_UWORD32 *)
-			((u32) (resources.dwPerPmBase) + 0xA8));
+			((u32) (pDevContext->perbase) + 0xA8));
 		temp = (temp & 0xFFFFFF30) | 0xC0;
-		*((REG_UWORD32 *) ((u32) (resources.dwPerPmBase) + 0xA8)) =
+		*((REG_UWORD32 *) ((u32) (pDevContext->perbase) + 0xA8)) =
 			(u32) temp;
 
 /*PM_MPUGRPSEL_PER &= 0xFFFFFF3F;*/
 		temp = (u32) *((REG_UWORD32 *)
-			((u32) (resources.dwPerPmBase) + 0xA4));
+			((u32) (pDevContext->perbase) + 0xA4));
 		temp = (temp & 0xFFFFFF3F);
-		*((REG_UWORD32 *) ((u32) (resources.dwPerPmBase) + 0xA4)) =
+		*((REG_UWORD32 *) ((u32) (pDevContext->perbase) + 0xA4)) =
 			(u32) temp;
 /*CM_SLEEPDEP_PER |= 0x04;*/
 		temp = (u32) *((REG_UWORD32 *)
-			((u32) (resources.dwPerBase) + 0x44));
+			((u32) (pDevContext->perbase) + 0x44));
 		temp = (temp & 0xFFFFFFFB) | 0x04;
-		*((REG_UWORD32 *) ((u32) (resources.dwPerBase) + 0x44)) =
+		*((REG_UWORD32 *) ((u32) (pDevContext->perbase) + 0x44)) =
 			(u32) temp;
 
 /*CM_CLKSTCTRL_IVA2 = 0x00000003 -To Allow automatic transitions*/
 		temp = (u32) *((REG_UWORD32 *)
-			((u32) (resources.dwCmBase) + 0x48));
+			((u32) (pDevContext->cmbase) + 0x48));
 		temp = (temp & 0xFFFFFFFC) | 0x03;
-		*((REG_UWORD32 *) ((u32) (resources.dwCmBase) + 0x48)) =
+		*((REG_UWORD32 *) ((u32) (pDevContext->cmbase) + 0x48)) =
 			(u32) temp;
 
 		/* Enable Mailbox events and also drain any pending
@@ -732,25 +711,25 @@ static DSP_STATUS WMD_BRD_Start(struct WMD_DEV_CONTEXT *hDevContext,
 	}
 
 	if (DSP_SUCCEEDED(status)) {
-		HW_RSTCTRL_RegGet(resources.dwPrmBase, HW_RST1_IVA2, &temp);
+		HW_RSTCTRL_RegGet(pDevContext->prmbase, HW_RST1_IVA2, &temp);
 		DBG_Trace(DBG_LEVEL7, "BRD_Start: RM_RSTCTRL_DSP = 0x%x \n",
 				temp);
-		HW_RSTST_RegGet(resources.dwPrmBase, HW_RST1_IVA2, &temp);
+		HW_RSTST_RegGet(pDevContext->prmbase, HW_RST1_IVA2, &temp);
 		DBG_Trace(DBG_LEVEL7, "BRD_Start0: RM_RSTST_DSP = 0x%x \n",
 				temp);
 
 		/* Let DSP go */
 		DBG_Trace(DBG_LEVEL7, "Unreset, WMD_BRD_Start\n");
 		/* Enable DSP MMU Interrupts */
-		HW_MMU_EventEnable(resources.dwDmmuBase,
+		HW_MMU_EventEnable(pDevContext->dwDSPMmuBase,
 				HW_MMU_ALL_INTERRUPTS);
 		/* release the RST1, DSP starts executing now .. */
-		HW_RST_UnReset(resources.dwPrmBase, HW_RST1_IVA2);
+		HW_RST_UnReset(pDevContext->prmbase, HW_RST1_IVA2);
 
-		HW_RSTST_RegGet(resources.dwPrmBase, HW_RST1_IVA2, &temp);
+		HW_RSTST_RegGet(pDevContext->prmbase, HW_RST1_IVA2, &temp);
 		DBG_Trace(DBG_LEVEL7, "BRD_Start: RM_RSTST_DSP = 0x%x \n",
 				temp);
-		HW_RSTCTRL_RegGet(resources.dwPrmBase, HW_RST1_IVA2, &temp);
+		HW_RSTCTRL_RegGet(pDevContext->prmbase, HW_RST1_IVA2, &temp);
 		DBG_Trace(DBG_LEVEL5, "WMD_BRD_Start: CM_RSTCTRL_DSP: 0x%x \n",
 				temp);
 		DBG_Trace(DBG_LEVEL7, "Driver waiting for Sync @ 0x%x \n",
@@ -832,11 +811,11 @@ static DSP_STATUS WMD_BRD_Stop(struct WMD_DEV_CONTEXT *hDevContext)
 		return DSP_EFAIL;
 	}
 
-	HW_PWRST_IVA2RegGet(resources.dwPrmBase, &dspPwrState);
+	HW_PWRST_IVA2RegGet(pDevContext->prmbase, &dspPwrState);
 	if (dspPwrState != HW_PWR_STATE_OFF) {
 		CHNLSM_InterruptDSP2(pDevContext, MBX_PM_DSPIDLE);
 		mdelay(10);
-		GetHWRegs(resources.dwPrmBase, resources.dwCmBase);
+		GetHWRegs(pDevContext->prmbase, pDevContext->cmbase);
 		udelay(50);
 
 		clk_status = CLK_Disable(SERVICESCLK_iva2_ck);
@@ -847,7 +826,7 @@ static DSP_STATUS WMD_BRD_Stop(struct WMD_DEV_CONTEXT *hDevContext)
 		}
 		/* IVA2 is not in OFF state */
 		/* Set PM_PWSTCTRL_IVA2  to OFF */
-		HW_PWR_IVA2PowerStateSet(resources.dwPrmBase,
+		HW_PWR_IVA2PowerStateSet(pDevContext->prmbase,
 					  HW_PWR_DOMAIN_DSP,
 					  HW_PWR_STATE_OFF);
 		/* Set the SW supervised state transition for Sleep */
@@ -877,8 +856,8 @@ static DSP_STATUS WMD_BRD_Stop(struct WMD_DEV_CONTEXT *hDevContext)
 		       (pPtAttrs->L2NumPages * sizeof(struct PageInfo)));
 	}
 	DBG_Trace(DBG_LEVEL6, "WMD_BRD_Stop - End ****** \n");
-	HW_RST_Reset(resources.dwPrmBase, HW_RST1_IVA2);
-	HW_RST_Reset(resources.dwPrmBase, HW_RST2_IVA2);
+	HW_RST_Reset(pDevContext->prmbase, HW_RST1_IVA2);
+	HW_RST_Reset(pDevContext->prmbase, HW_RST2_IVA2);
 
 	return status;
 }
@@ -943,8 +922,8 @@ static DSP_STATUS WMD_BRD_Delete(struct WMD_DEV_CONTEXT *hDevContext)
 			(pPtAttrs->L2NumPages * sizeof(struct PageInfo)));
 	}
 	DBG_Trace(DBG_LEVEL6, "WMD_BRD_Delete - End ****** \n");
-	HW_RST_Reset(resources.dwPrmBase, HW_RST1_IVA2);
-	HW_RST_Reset(resources.dwPrmBase, HW_RST2_IVA2);
+	HW_RST_Reset(pDevContext->prmbase, HW_RST1_IVA2);
+	HW_RST_Reset(pDevContext->prmbase, HW_RST2_IVA2);
 
 	return status;
 }
@@ -1153,9 +1132,14 @@ static DSP_STATUS WMD_DEV_Create(OUT struct WMD_DEV_CONTEXT **ppDevContext,
 				 "enable the clock Fail\n");
 		}
 		udelay(5);
-		/* 24xx-Linux MMU address is obtained from the host
+		/* 34xx-Linux Base addresses are obtained from the host
 		 * resources struct */
 		pDevContext->dwDSPMmuBase = resources.dwDmmuBase;
+		pDevContext->dwMailBoxBase = resources.dwMboxBase;
+		pDevContext->cmbase = resources.dwCmBase;
+		pDevContext->sysctrlbase = resources.dwSysCtrlBase;
+		pDevContext->prmbase = resources.dwPrmBase;
+		pDevContext->perbase = resources.dwPerPmBase;
 	}
 	if (DSP_SUCCEEDED(status)) {
 		pDevContext->hDevObject = hDevObject;
diff --git a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
index ea299a0..1c3bec3 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
@@ -82,11 +82,8 @@ DSP_STATUS handle_constraints_set(struct WMD_DEV_CONTEXT *pDevContext,
 #ifdef CONFIG_BRIDGE_DVFS
 	u32 *pConstraintVal;
 	DSP_STATUS status = DSP_SOK;
-	struct CFG_HOSTRES resources;
 	struct dspbridge_platform_data *pdata =
 		omap_dspbridge_dev->dev.platform_data;
-	status = CFG_GetHostResources(
-		(struct CFG_DEVNODE *)DRV_GetFirstDevExtension(), &resources);
 
 	pConstraintVal = (u32 *)(pArgs);
 	/* Read the target value requested by DSP  */
@@ -111,7 +108,6 @@ DSP_STATUS handle_hibernation_fromDSP(struct WMD_DEV_CONTEXT *pDevContext)
 	DSP_STATUS status = DSP_SOK;
 #ifdef CONFIG_PM
 	u16 timeout = PWRSTST_TIMEOUT / 10;
-	struct CFG_HOSTRES resources;
 	enum HW_PwrState_t pwrState;
 #ifdef CONFIG_BRIDGE_DVFS
 	u32 opplevel;
@@ -120,12 +116,7 @@ DSP_STATUS handle_hibernation_fromDSP(struct WMD_DEV_CONTEXT *pDevContext)
 				omap_dspbridge_dev->dev.platform_data;
 #endif
 
-	status = CFG_GetHostResources(
-		 (struct CFG_DEVNODE *)DRV_GetFirstDevExtension(), &resources);
-	if (DSP_FAILED(status))
-		return status;
-
-	HW_PWR_IVA2StateGet(resources.dwPrmBase, HW_PWR_DOMAIN_DSP,
+	HW_PWR_IVA2StateGet(pDevContext->prmbase, HW_PWR_DOMAIN_DSP,
 			    &pwrState);
 	/* Wait for DSP to move into OFF state */
 	while ((pwrState != HW_PWR_STATE_OFF) && --timeout) {
@@ -133,7 +124,7 @@ DSP_STATUS handle_hibernation_fromDSP(struct WMD_DEV_CONTEXT *pDevContext)
 			pr_err("Waiting for DSP OFF mode interrupted\n");
 			return DSP_EFAIL;
 		}
-		HW_PWR_IVA2StateGet(resources.dwPrmBase, HW_PWR_DOMAIN_DSP,
+		HW_PWR_IVA2StateGet(pDevContext->prmbase, HW_PWR_DOMAIN_DSP,
 				    &pwrState);
 	}
 	if (timeout == 0) {
@@ -141,9 +132,8 @@ DSP_STATUS handle_hibernation_fromDSP(struct WMD_DEV_CONTEXT *pDevContext)
 		status = WMD_E_TIMEOUT;
 		return status;
 	} else {
-
 		/* Save mailbox settings */
-		status = HW_MBOX_saveSettings(resources.dwMboxBase);
+		status = HW_MBOX_saveSettings(pDevContext->dwMailBoxBase);
 		DBG_Trace(DBG_LEVEL6, "MailBoxSettings: SYSCONFIG = 0x%x\n",
 			 mboxsetting.sysconfig);
 		DBG_Trace(DBG_LEVEL6, "MailBoxSettings: IRQENABLE0 = 0x%x\n",
@@ -193,7 +183,6 @@ DSP_STATUS SleepDSP(struct WMD_DEV_CONTEXT *pDevContext, IN u32 dwCmd,
 {
 	DSP_STATUS status = DSP_SOK;
 #ifdef CONFIG_PM
-	struct CFG_HOSTRES resources;
 #ifdef CONFIG_BRIDGE_NTFY_PWRERR
 	struct DEH_MGR *hDehMgr;
 #endif /* CONFIG_BRIDGE_NTFY_PWRERR */
@@ -208,14 +197,9 @@ DSP_STATUS SleepDSP(struct WMD_DEV_CONTEXT *pDevContext, IN u32 dwCmd,
 		return DSP_EINVALIDARG;
 	}
 
-	status = CFG_GetHostResources(
-		 (struct CFG_DEVNODE *)DRV_GetFirstDevExtension(), &resources);
-	if (DSP_FAILED(status))
-		return status;
-
 	switch (pDevContext->dwBrdState) {
 	case BRD_RUNNING:
-		status = HW_MBOX_saveSettings(resources.dwMboxBase);
+		status = HW_MBOX_saveSettings(pDevContext->dwMailBoxBase);
 		if (dsp_test_sleepstate == HW_PWR_STATE_OFF) {
 			CHNLSM_InterruptDSP2(pDevContext,
 					     MBX_PM_DSPHIBERNATE);
@@ -230,7 +214,7 @@ DSP_STATUS SleepDSP(struct WMD_DEV_CONTEXT *pDevContext, IN u32 dwCmd,
 		}
 		break;
 	case BRD_RETENTION:
-		status = HW_MBOX_saveSettings(resources.dwMboxBase);
+		status = HW_MBOX_saveSettings(pDevContext->dwMailBoxBase);
 		if (dsp_test_sleepstate == HW_PWR_STATE_OFF) {
 			CHNLSM_InterruptDSP2(pDevContext,
 					     MBX_PM_DSPHIBERNATE);
@@ -255,7 +239,7 @@ DSP_STATUS SleepDSP(struct WMD_DEV_CONTEXT *pDevContext, IN u32 dwCmd,
 	}
 
 	/* Get the PRCM DSP power domain status */
-	HW_PWR_IVA2StateGet(resources.dwPrmBase, HW_PWR_DOMAIN_DSP,
+	HW_PWR_IVA2StateGet(pDevContext->prmbase, HW_PWR_DOMAIN_DSP,
 			&pwrState);
 
 	/* Wait for DSP to move into target power state */
@@ -264,7 +248,7 @@ DSP_STATUS SleepDSP(struct WMD_DEV_CONTEXT *pDevContext, IN u32 dwCmd,
 			pr_err("Waiting for DSP to Suspend interrupted\n");
 			return DSP_EFAIL;
 		}
-		HW_PWR_IVA2StateGet(resources.dwPrmBase, HW_PWR_DOMAIN_DSP,
+		HW_PWR_IVA2StateGet(pDevContext->prmbase, HW_PWR_DOMAIN_DSP,
 				    &pwrState);
 	}
 
@@ -315,16 +299,9 @@ DSP_STATUS SleepDSP(struct WMD_DEV_CONTEXT *pDevContext, IN u32 dwCmd,
  */
 DSP_STATUS WakeDSP(struct WMD_DEV_CONTEXT *pDevContext, IN void *pArgs)
 {
-	DSP_STATUS status = DSP_SOK;
 #ifdef CONFIG_PM
 #ifdef CONFIG_BRIDGE_DEBUG
 	enum HW_PwrState_t pwrState;
-	struct CFG_HOSTRES resources;
-
-	status = CFG_GetHostResources(
-		 (struct CFG_DEVNODE *)DRV_GetFirstDevExtension(), &resources);
-	if (DSP_FAILED(status))
-		return status;
 #endif /* CONFIG_BRIDGE_DEBUG */
 
 	/* Check the BRD/WMD state, if it is not 'SLEEP' then return failure */
@@ -339,7 +316,7 @@ DSP_STATUS WakeDSP(struct WMD_DEV_CONTEXT *pDevContext, IN void *pArgs)
 	CHNLSM_InterruptDSP2(pDevContext, MBX_PM_DSPWAKEUP);
 
 #ifdef CONFIG_BRIDGE_DEBUG
-	HW_PWR_IVA2StateGet(resources.dwPrmBase, HW_PWR_DOMAIN_DSP,
+	HW_PWR_IVA2StateGet(pDevContext->prmbase, HW_PWR_DOMAIN_DSP,
 			&pwrState);
 	DBG_Trace(DBG_LEVEL7,
 			"\nWakeDSP: Power State After sending Interrupt "
@@ -349,7 +326,7 @@ DSP_STATUS WakeDSP(struct WMD_DEV_CONTEXT *pDevContext, IN void *pArgs)
 	/* Set the device state to RUNNIG */
 	pDevContext->dwBrdState = BRD_RUNNING;
 #endif /* CONFIG_PM */
-	return status;
+	return DSP_SOK;
 }
 
 /*
@@ -367,7 +344,6 @@ DSP_STATUS DSPPeripheralClkCtrl(struct WMD_DEV_CONTEXT *pDevContext,
 	u32 dspPerClksBefore;
 	DSP_STATUS status = DSP_SOK;
 	DSP_STATUS status1 = DSP_SOK;
-	struct CFG_HOSTRES resources;
 	u32 value;
 
 	DBG_Trace(DBG_ENTER, "Entering DSPPeripheralClkCtrl \n");
@@ -377,13 +353,6 @@ DSP_STATUS DSPPeripheralClkCtrl(struct WMD_DEV_CONTEXT *pDevContext,
 
 	extClk = (u32)*((u32 *)pArgs);
 
-	status = CFG_GetHostResources(
-			(struct CFG_DEVNODE *)DRV_GetFirstDevExtension(),
-			&resources);
-
-	if (DSP_FAILED(status))
-		return DSP_EFAIL;
-
 	DBG_Trace(DBG_LEVEL3, "DSPPeripheralClkCtrl : extClk+Cmd = 0x%x \n",
 		 extClk);
 
@@ -416,14 +385,14 @@ DSP_STATUS DSPPeripheralClkCtrl(struct WMD_DEV_CONTEXT *pDevContext,
 		status = CLK_Disable(BPWR_Clks[clkIdIndex].funClk);
 		if (BPWR_CLKID[clkIdIndex] == BPWR_MCBSP1) {
 			/* clear MCBSP1_CLKS, on McBSP1 OFF */
-			value = __raw_readl(resources.dwSysCtrlBase + 0x274);
+			value = __raw_readl(pDevContext->sysctrlbase + 0x274);
 			value &= ~(1 << 2);
-			__raw_writel(value, resources.dwSysCtrlBase + 0x274);
+			__raw_writel(value, pDevContext->sysctrlbase + 0x274);
 		} else if (BPWR_CLKID[clkIdIndex] == BPWR_MCBSP2) {
 			/* clear MCBSP2_CLKS, on McBSP2 OFF */
-			value = __raw_readl(resources.dwSysCtrlBase + 0x274);
+			value = __raw_readl(pDevContext->sysctrlbase + 0x274);
 			value &= ~(1 << 6);
-			__raw_writel(value, resources.dwSysCtrlBase + 0x274);
+			__raw_writel(value, pDevContext->sysctrlbase + 0x274);
 		}
 		DSPClkWakeupEventCtrl(BPWR_Clks[clkIdIndex].clkId, false);
 		if ((DSP_SUCCEEDED(status)) && (DSP_SUCCEEDED(status1))) {
@@ -441,14 +410,14 @@ DSP_STATUS DSPPeripheralClkCtrl(struct WMD_DEV_CONTEXT *pDevContext,
 		status = CLK_Enable(BPWR_Clks[clkIdIndex].funClk);
 		if (BPWR_CLKID[clkIdIndex] == BPWR_MCBSP1) {
 			/* set MCBSP1_CLKS, on McBSP1 ON */
-			value = __raw_readl(resources.dwSysCtrlBase + 0x274);
+			value = __raw_readl(pDevContext->sysctrlbase + 0x274);
 			value |= 1 << 2;
-			__raw_writel(value, resources.dwSysCtrlBase + 0x274);
+			__raw_writel(value, pDevContext->sysctrlbase + 0x274);
 		} else if (BPWR_CLKID[clkIdIndex] == BPWR_MCBSP2) {
 			/* set MCBSP2_CLKS, on McBSP2 ON */
-			value = __raw_readl(resources.dwSysCtrlBase + 0x274);
+			value = __raw_readl(pDevContext->sysctrlbase + 0x274);
 			value |= 1 << 6;
-			__raw_writel(value, resources.dwSysCtrlBase + 0x274);
+			__raw_writel(value, pDevContext->sysctrlbase + 0x274);
 		}
 		DSPClkWakeupEventCtrl(BPWR_Clks[clkIdIndex].clkId, true);
 		if ((DSP_SUCCEEDED(status)) && (DSP_SUCCEEDED(status1))) {
@@ -561,31 +530,26 @@ DSP_STATUS DSP_PeripheralClocks_Disable(struct WMD_DEV_CONTEXT *pDevContext,
 {
 	u32 clkIdx;
 	DSP_STATUS status = DSP_SOK;
-	struct CFG_HOSTRES resources;
 	u32 value;
 
-	status = CFG_GetHostResources(
-			(struct CFG_DEVNODE *)DRV_GetFirstDevExtension(),
-			&resources);
-
 	for (clkIdx = 0; clkIdx < MBX_PM_MAX_RESOURCES; clkIdx++) {
 		if (((pDevContext->uDspPerClks) >> clkIdx) & 0x01) {
 			/* Disables the interface clock of the peripheral */
 			status = CLK_Disable(BPWR_Clks[clkIdx].intClk);
 			if (BPWR_CLKID[clkIdx] == BPWR_MCBSP1) {
 				/* clear MCBSP1_CLKS, on McBSP1 OFF */
-				value = __raw_readl(resources.dwSysCtrlBase
-								+ 0x274);
+				value = __raw_readl(pDevContext->sysctrlbase +
+									0x274);
 				value &= ~(1 << 2);
-				__raw_writel(value, resources.dwSysCtrlBase
-								+ 0x274);
+				__raw_writel(value, pDevContext->sysctrlbase +
+									0x274);
 			} else if (BPWR_CLKID[clkIdx] == BPWR_MCBSP2) {
 				/* clear MCBSP2_CLKS, on McBSP2 OFF */
-				value = __raw_readl(resources.dwSysCtrlBase
-								+ 0x274);
+				value = __raw_readl(pDevContext->sysctrlbase +
+									0x274);
 				value &= ~(1 << 6);
-				__raw_writel(value, resources.dwSysCtrlBase
-								+ 0x274);
+				__raw_writel(value, pDevContext->sysctrlbase +
+									0x274);
 			}
 			if (DSP_FAILED(status)) {
 				DBG_Trace(DBG_LEVEL7,
@@ -613,30 +577,26 @@ DSP_STATUS DSP_PeripheralClocks_Enable(struct WMD_DEV_CONTEXT *pDevContext,
 {
 	u32 clkIdx;
 	DSP_STATUS int_clk_status = DSP_EFAIL, fun_clk_status = DSP_EFAIL;
-	struct CFG_HOSTRES resources;
 	u32 value;
 
-	CFG_GetHostResources((struct CFG_DEVNODE *)DRV_GetFirstDevExtension(),
-			&resources);
-
 	for (clkIdx = 0; clkIdx < MBX_PM_MAX_RESOURCES; clkIdx++) {
 		if (((pDevContext->uDspPerClks) >> clkIdx) & 0x01) {
 			/* Enable the interface clock of the peripheral */
 			int_clk_status = CLK_Enable(BPWR_Clks[clkIdx].intClk);
 			if (BPWR_CLKID[clkIdx] == BPWR_MCBSP1) {
 				/* set MCBSP1_CLKS, on McBSP1 ON */
-				value = __raw_readl(resources.dwSysCtrlBase
-								+ 0x274);
+				value = __raw_readl(pDevContext->sysctrlbase +
+									0x274);
 				value |= 1 << 2;
-				__raw_writel(value, resources.dwSysCtrlBase
-								+ 0x274);
+				__raw_writel(value, pDevContext->sysctrlbase +
+									0x274);
 			} else if (BPWR_CLKID[clkIdx] == BPWR_MCBSP2) {
 				/* set MCBSP2_CLKS, on McBSP2 ON */
-				value = __raw_readl(resources.dwSysCtrlBase
-								+ 0x274);
+				value = __raw_readl(pDevContext->sysctrlbase +
+									0x274);
 				value |= 1 << 6;
-				__raw_writel(value, resources.dwSysCtrlBase
-								+ 0x274);
+				__raw_writel(value, pDevContext->sysctrlbase +
+									0x274);
 			}
 			/* Enable the functional clock of the periphearl */
 			fun_clk_status = CLK_Enable(BPWR_Clks[clkIdx].funClk);
diff --git a/drivers/dsp/bridge/wmd/tiomap_sm.c b/drivers/dsp/bridge/wmd/tiomap_sm.c
index fe4d8b0..fecff54 100644
--- a/drivers/dsp/bridge/wmd/tiomap_sm.c
+++ b/drivers/dsp/bridge/wmd/tiomap_sm.c
@@ -38,7 +38,6 @@ DSP_STATUS CHNLSM_EnableInterrupt(struct WMD_DEV_CONTEXT *pDevContext)
 	DSP_STATUS status = DSP_SOK;
 	u32 numMbxMsg;
 	u32 mbxValue;
-	struct CFG_HOSTRES resources;
 	u32 devType;
 	struct IO_MGR *hIOMgr;
 
@@ -46,34 +45,33 @@ DSP_STATUS CHNLSM_EnableInterrupt(struct WMD_DEV_CONTEXT *pDevContext)
 
 	/* Read the messages in the mailbox until the message queue is empty */
 
-	CFG_GetHostResources((struct CFG_DEVNODE *)DRV_GetFirstDevExtension(),
-			     &resources);
 	DEV_GetDevType(pDevContext->hDevObject, &devType);
 	status = DEV_GetIOMgr(pDevContext->hDevObject, &hIOMgr);
 	if (devType == DSP_UNIT) {
-		HW_MBOX_NumMsgGet(resources.dwMboxBase,
+		HW_MBOX_NumMsgGet(pDevContext->dwMailBoxBase,
 				  MBOX_DSP2ARM, &numMbxMsg);
 		while (numMbxMsg != 0) {
-			HW_MBOX_MsgRead(resources.dwMboxBase,
+			HW_MBOX_MsgRead(pDevContext->dwMailBoxBase,
 					MBOX_DSP2ARM,
 					&mbxValue);
 			numMbxMsg--;
 		}
 		/* clear the DSP mailbox as well...*/
-		HW_MBOX_NumMsgGet(resources.dwMboxBase,
+		HW_MBOX_NumMsgGet(pDevContext->dwMailBoxBase,
 				  MBOX_ARM2DSP, &numMbxMsg);
 		while (numMbxMsg != 0) {
-			HW_MBOX_MsgRead(resources.dwMboxBase,
+			HW_MBOX_MsgRead(pDevContext->dwMailBoxBase,
 					MBOX_ARM2DSP, &mbxValue);
 			numMbxMsg--;
 			udelay(10);
 
-			HW_MBOX_EventAck(resources.dwMboxBase, MBOX_ARM2DSP,
+			HW_MBOX_EventAck(pDevContext->dwMailBoxBase,
+					 MBOX_ARM2DSP,
 					 HW_MBOX_U1_DSP1,
 					 HW_MBOX_INT_NEW_MSG);
 		}
 		/* Enable the new message events on this IRQ line */
-		HW_MBOX_EventEnable(resources.dwMboxBase,
+		HW_MBOX_EventEnable(pDevContext->dwMailBoxBase,
 				    MBOX_DSP2ARM,
 				    MBOX_ARM,
 				    HW_MBOX_INT_NEW_MSG);
@@ -84,13 +82,9 @@ DSP_STATUS CHNLSM_EnableInterrupt(struct WMD_DEV_CONTEXT *pDevContext)
 
 DSP_STATUS CHNLSM_DisableInterrupt(struct WMD_DEV_CONTEXT *pDevContext)
 {
-	struct CFG_HOSTRES resources;
-
 	DBG_Trace(DBG_ENTER, "CHNLSM_DisableInterrupt(0x%x)\n", pDevContext);
 
-	CFG_GetHostResources((struct CFG_DEVNODE *)DRV_GetFirstDevExtension(),
-			     &resources);
-	HW_MBOX_EventDisable(resources.dwMboxBase, MBOX_DSP2ARM,
+	HW_MBOX_EventDisable(pDevContext->dwMailBoxBase, MBOX_DSP2ARM,
 			     MBOX_ARM, HW_MBOX_INT_NEW_MSG);
 	return DSP_SOK;
 }
@@ -103,13 +97,10 @@ DSP_STATUS CHNLSM_InterruptDSP2(struct WMD_DEV_CONTEXT *pDevContext,
 		omap_dspbridge_dev->dev.platform_data;
 	u32 opplevel = 0;
 #endif
-	struct CFG_HOSTRES resources;
 	DSP_STATUS status = DSP_SOK;
 	unsigned long timeout;
 	u32 temp;
 
-	status = CFG_GetHostResources((struct CFG_DEVNODE *)
-			DRV_GetFirstDevExtension(), &resources);
 	if (DSP_FAILED(status))
 		return DSP_EFAIL;
 
@@ -130,22 +121,22 @@ DSP_STATUS CHNLSM_InterruptDSP2(struct WMD_DEV_CONTEXT *pDevContext,
 		 * 2:0 AUTO_IVA2_DPLL - Enabling IVA2 DPLL auto control
 		 *     in CM_AUTOIDLE_PLL_IVA2 register
 		 */
-		*(REG_UWORD32 *)(resources.dwCmBase + 0x34) = 0x1;
+		*(REG_UWORD32 *)(pDevContext->cmbase + 0x34) = 0x1;
 
 		/*
 		 * 7:4 IVA2_DPLL_FREQSEL - IVA2 internal frq set to
 		 *     0.75 MHz - 1.0 MHz
 		 * 2:0 EN_IVA2_DPLL - Enable IVA2 DPLL in lock mode
 		 */
-		temp = *(REG_UWORD32 *)(resources.dwCmBase + 0x4);
+		temp = *(REG_UWORD32 *)(pDevContext->cmbase + 0x4);
 		temp = (temp & 0xFFFFFF08) | 0x37;
-		*(REG_UWORD32 *)(resources.dwCmBase + 0x4) = temp;
+		*(REG_UWORD32 *)(pDevContext->cmbase + 0x4) = temp;
 
 		/* Restore mailbox settings */
-		HW_MBOX_restoreSettings(resources.dwMboxBase);
+		HW_MBOX_restoreSettings(pDevContext->dwMailBoxBase);
 
 		/* Access MMU SYS CONFIG register to generate a short wakeup */
-		temp = *(REG_UWORD32 *)(resources.dwDmmuBase + 0x10);
+		temp = *(REG_UWORD32 *)(pDevContext->dwDSPMmuBase + 0x10);
 
 		pDevContext->dwBrdState = BRD_RUNNING;
 	} else if (pDevContext->dwBrdState == BRD_RETENTION)
@@ -153,7 +144,7 @@ DSP_STATUS CHNLSM_InterruptDSP2(struct WMD_DEV_CONTEXT *pDevContext,
 		DSP_PeripheralClocks_Enable(pDevContext, NULL);
 
 	timeout = jiffies + msecs_to_jiffies(1);
-	while (fifo_full((void __iomem *) resources.dwMboxBase, 0)) {
+	while (fifo_full((void __iomem *) pDevContext->dwMailBoxBase, 0)) {
 		if (time_after(jiffies, timeout)) {
 			pr_err("dspbridge: timed out waiting for mailbox\n");
 			return WMD_E_TIMEOUT;
@@ -161,27 +152,26 @@ DSP_STATUS CHNLSM_InterruptDSP2(struct WMD_DEV_CONTEXT *pDevContext,
 	}
 
 	DBG_Trace(DBG_LEVEL3, "writing %x to Mailbox\n", wMbVal);
-	HW_MBOX_MsgWrite(resources.dwMboxBase, MBOX_ARM2DSP, wMbVal);
+	HW_MBOX_MsgWrite(pDevContext->dwMailBoxBase, MBOX_ARM2DSP, wMbVal);
+
 	return DSP_SOK;
 }
 
 bool CHNLSM_ISR(struct WMD_DEV_CONTEXT *pDevContext, bool *pfSchedDPC,
 		u16 *pwIntrVal)
 {
-	struct CFG_HOSTRES resources;
 	u32 numMbxMsg;
 	u32 mbxValue;
 
 	DBG_Trace(DBG_ENTER, "CHNLSM_ISR(0x%x)\n", pDevContext);
 
-	CFG_GetHostResources((struct CFG_DEVNODE *)DRV_GetFirstDevExtension(), &resources);
-
-	HW_MBOX_NumMsgGet(resources.dwMboxBase, MBOX_DSP2ARM, &numMbxMsg);
+	HW_MBOX_NumMsgGet(pDevContext->dwMailBoxBase, MBOX_DSP2ARM, &numMbxMsg);
 
 	if (numMbxMsg > 0) {
-		HW_MBOX_MsgRead(resources.dwMboxBase, MBOX_DSP2ARM, &mbxValue);
+		HW_MBOX_MsgRead(pDevContext->dwMailBoxBase, MBOX_DSP2ARM,
+				&mbxValue);
 
-		HW_MBOX_EventAck(resources.dwMboxBase, MBOX_DSP2ARM,
+		HW_MBOX_EventAck(pDevContext->dwMailBoxBase, MBOX_DSP2ARM,
 				 HW_MBOX_U0_ARM, HW_MBOX_INT_NEW_MSG);
 
 		DBG_Trace(DBG_LEVEL3, "Read %x from Mailbox\n", mbxValue);
diff --git a/drivers/dsp/bridge/wmd/ue_deh.c b/drivers/dsp/bridge/wmd/ue_deh.c
index d6d6043..c03b816 100644
--- a/drivers/dsp/bridge/wmd/ue_deh.c
+++ b/drivers/dsp/bridge/wmd/ue_deh.c
@@ -205,12 +205,8 @@ void WMD_DEH_Notify(struct DEH_MGR *hDehMgr, u32 ulEventMask,
 	u32 memPhysical = 0;
 	u32 HW_MMU_MAX_TLB_COUNT = 31;
 	u32 extern faultAddr;
-	struct CFG_HOSTRES resources;
 	HW_STATUS hwStatus;
 
-	status = CFG_GetHostResources(
-			(struct CFG_DEVNODE *)DRV_GetFirstDevExtension(),
-			&resources);
 	if (DSP_FAILED(status))
 		DBG_Trace(DBG_LEVEL7,
 			 "**Failed to get Host Resources in MMU ISR **\n");
@@ -268,16 +264,17 @@ DBG_Trace(DBG_LEVEL6, "WMD_DEH_Notify: DSP_MMUFAULT, "
 				 "PA: 0x%x\n", pDevContext->
 				numTLBEntries, faultAddr, memPhysical);
 			if (DSP_SUCCEEDED(status)) {
-				hwStatus = HW_MMU_TLBAdd(resources.dwDmmuBase,
-					memPhysical, faultAddr,
+				hwStatus = HW_MMU_TLBAdd(pDevContext->
+					dwDSPMmuBase, memPhysical, faultAddr,
 					HW_PAGE_SIZE_4KB, 1, &mapAttrs,
 					HW_SET, HW_SET);
 			}
 			/* send an interrupt to DSP */
-			HW_MBOX_MsgWrite(resources.dwMboxBase, MBOX_ARM2DSP,
-					 MBX_DEH_CLASS | MBX_DEH_EMMU);
+			HW_MBOX_MsgWrite(pDevContext->dwMailBoxBase,
+					MBOX_ARM2DSP,
+					MBX_DEH_CLASS | MBX_DEH_EMMU);
 			/* Clear MMU interrupt */
-			HW_MMU_EventAck(resources.dwDmmuBase,
+			HW_MMU_EventAck(pDevContext->dwDSPMmuBase,
 					 HW_MMU_TRANSLATION_FAULT);
 			break;
 #ifdef CONFIG_BRIDGE_NTFY_PWRERR
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 17/17] DSPBRIDGE: Compilation fixes 2.6.31
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
                   ` (15 preceding siblings ...)
  2009-12-15  6:19 ` [PATCH 16/17] DSPBRIDGE: Avoid REGistry if pDevContext is available Omar Ramirez Luna
@ 2009-12-15  6:19 ` Omar Ramirez Luna
  2009-12-15 18:28 ` [PATCH 00/17] First set of unreviewed patches Felipe Contreras
  17 siblings, 0 replies; 24+ messages in thread
From: Omar Ramirez Luna @ 2009-12-15  6:19 UTC (permalink / raw)
  To: linux-omap
  Cc: Hiroshi Doyu, Ameya Palande, Felipe Contreras, Fernando Guzman,
	Ernesto Ramos, Omar Ramirez Luna

Compilation fixes 2.6.31

	board-sdp3430.h not found
	clk_handle undefined because of DVFS flag

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 arch/arm/mach-omap2/dspbridge.c         |    2 ++
 drivers/dsp/bridge/rmgr/drv_interface.c |    8 ++++----
 drivers/dsp/bridge/rmgr/proc.c          |    3 +++
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c |    3 ---
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/dspbridge.c b/arch/arm/mach-omap2/dspbridge.c
index 9724a95..ea109a3 100644
--- a/arch/arm/mach-omap2/dspbridge.c
+++ b/arch/arm/mach-omap2/dspbridge.c
@@ -13,7 +13,9 @@
 
 #include <linux/platform_device.h>
 
+#ifdef CONFIG_BRIDGE_DVFS
 #include <mach/omap-pm.h>
+#endif
 
 #include <dspbridge/host_os.h>
 
diff --git a/drivers/dsp/bridge/rmgr/drv_interface.c b/drivers/dsp/bridge/rmgr/drv_interface.c
index 6415955..16529d8 100644
--- a/drivers/dsp/bridge/rmgr/drv_interface.c
+++ b/drivers/dsp/bridge/rmgr/drv_interface.c
@@ -59,8 +59,6 @@
 #include <linux/moduleparam.h>
 #include <linux/cdev.h>
 
-#include <mach/board-3430sdp.h>
-
 /*  ----------------------------------- DSP/BIOS Bridge */
 #include <dspbridge/std.h>
 #include <dspbridge/dbdefs.h>
@@ -96,8 +94,10 @@
 #include <dspbridge/drv.h>
 #endif
 
+#ifdef CONFIG_BRIDGE_DVFS
 #include <mach/omap-pm.h>
 #include <mach-omap2/omap3-opp.h>
+#endif
 
 #define BRIDGE_NAME "C6410"
 /*  ----------------------------------- Globals */
@@ -458,10 +458,10 @@ static int __devexit omap34xx_bridge_remove(struct platform_device *pdev)
 		driverContext = 0;
 		DBC_Assert(ret == true);
 	}
-
+#ifdef CONFIG_BRIDGE_DVFS
 	clk_put(clk_handle);
 	clk_handle = NULL;
-
+#endif
 func_cont:
 	MEM_ExtPhysPoolRelease();
 
diff --git a/drivers/dsp/bridge/rmgr/proc.c b/drivers/dsp/bridge/rmgr/proc.c
index 89b1ff3..76e39ca 100644
--- a/drivers/dsp/bridge/rmgr/proc.c
+++ b/drivers/dsp/bridge/rmgr/proc.c
@@ -142,7 +142,10 @@
 /*  ----------------------------------- This */
 #include <dspbridge/proc.h>
 #include <dspbridge/pwr.h>
+
+#ifdef CONFIG_BRIDGE_DVFS
 #include <mach-omap2/omap3-opp.h>
+#endif
 
 #ifndef RES_CLEANUP_DISABLE
 #include <dspbridge/resourcecleanup.h>
diff --git a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
index 1c3bec3..d52fdb8 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
@@ -66,9 +66,6 @@
 #include <mach-omap2/prm-regbits-34xx.h>
 #include <mach-omap2/cm-regbits-34xx.h>
 
-#ifdef CONFIG_PM
-#include <mach/board-3430sdp.h>
-#endif
 extern s32 dsp_test_sleepstate;
 extern struct MAILBOX_CONTEXT mboxsetting;
 
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 16/17] DSPBRIDGE: Avoid REGistry if pDevContext is available
  2009-12-15  6:19 ` [PATCH 16/17] DSPBRIDGE: Avoid REGistry if pDevContext is available Omar Ramirez Luna
@ 2009-12-15 18:21   ` Felipe Contreras
  2009-12-15 19:03     ` Ramirez Luna, Omar
  0 siblings, 1 reply; 24+ messages in thread
From: Felipe Contreras @ 2009-12-15 18:21 UTC (permalink / raw)
  To: Omar Ramirez Luna
  Cc: linux-omap, Hiroshi Doyu, Ameya Palande, Felipe Contreras,
	Fernando Guzman, Ernesto Ramos

On Tue, Dec 15, 2009 at 8:19 AM, Omar Ramirez Luna <omar.ramirez@ti.com> wrote:
> Avoid calls to read the register if pDevContext is available
> to the function, this will save a call to query and hold
> a semaphore under registry operations.

[...]

> --- a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
> +++ b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
> @@ -82,11 +82,8 @@ DSP_STATUS handle_constraints_set(struct WMD_DEV_CONTEXT *pDevContext,
>  #ifdef CONFIG_BRIDGE_DVFS
>        u32 *pConstraintVal;
>        DSP_STATUS status = DSP_SOK;
> -       struct CFG_HOSTRES resources;

This breaks the build when DVFS is enabled, because of:
status = HW_MBOX_saveSettings(resources.dwMboxBase);

>        struct dspbridge_platform_data *pdata =
>                omap_dspbridge_dev->dev.platform_data;
> -       status = CFG_GetHostResources(
> -               (struct CFG_DEVNODE *)DRV_GetFirstDevExtension(), &resources);
>
>        pConstraintVal = (u32 *)(pArgs);
>        /* Read the target value requested by DSP  */

BTW. Nobody is checking for errors in the 'status' variable.

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 02/17] DSPBRIDGE: Implemented Trampoline support for dynamic loader
  2009-12-15  6:19 ` [PATCH 02/17] DSPBRIDGE: Implemented Trampoline support for dynamic loader Omar Ramirez Luna
@ 2009-12-15 18:24   ` Felipe Contreras
  2009-12-15 22:14     ` Ramirez Luna, Omar
  0 siblings, 1 reply; 24+ messages in thread
From: Felipe Contreras @ 2009-12-15 18:24 UTC (permalink / raw)
  To: Omar Ramirez Luna
  Cc: linux-omap, Hiroshi Doyu, Ameya Palande, Felipe Contreras,
	Fernando Guzman, Ernesto Ramos

On Tue, Dec 15, 2009 at 8:19 AM, Omar Ramirez Luna <omar.ramirez@ti.com> wrote:
> From: Fernando Guzman Lugo <x0095840@ti.com>
>
> Implemented on dynamic loader automatic generation of
> trampolines when near calls are made to outside of signed
> 21-bit offset available in the C64X+ DSP.

The commit message is not clear: Why do we want this? What problem is
fixed? Is old behavior changed, or is it an independent feature?

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 03/17] DSPBRIDGE: Enable/Disable MCBSP_CLOCKS for MCBSP2
  2009-12-15  6:19 ` [PATCH 03/17] DSPBRIDGE: Enable/Disable MCBSP_CLOCKS for MCBSP2 Omar Ramirez Luna
@ 2009-12-15 18:26   ` Felipe Contreras
  0 siblings, 0 replies; 24+ messages in thread
From: Felipe Contreras @ 2009-12-15 18:26 UTC (permalink / raw)
  To: Omar Ramirez Luna
  Cc: linux-omap, Hiroshi Doyu, Ameya Palande, Felipe Contreras,
	Fernando Guzman, Ernesto Ramos

On Tue, Dec 15, 2009 at 8:19 AM, Omar Ramirez Luna <omar.ramirez@ti.com> wrote:
> From: Fernando Guzman Lugo <x0095840@ti.com>
>
> Enable/Disable McBSP_CLOCKS when McBSP2 is requested
> so DPLL can be gated.

I'm guessing this means you found a bug and this patch fixes it. This
can be clarified on the commit message, right?

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 00/17] First set of unreviewed patches
  2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
                   ` (16 preceding siblings ...)
  2009-12-15  6:19 ` [PATCH 17/17] DSPBRIDGE: Compilation fixes 2.6.31 Omar Ramirez Luna
@ 2009-12-15 18:28 ` Felipe Contreras
  17 siblings, 0 replies; 24+ messages in thread
From: Felipe Contreras @ 2009-12-15 18:28 UTC (permalink / raw)
  To: Omar Ramirez Luna
  Cc: linux-omap, Hiroshi Doyu, Ameya Palande, Felipe Contreras,
	Fernando Guzman, Ernesto Ramos

On Tue, Dec 15, 2009 at 8:19 AM, Omar Ramirez Luna <omar.ramirez@ti.com> wrote:
> These patches need to be reviewed to be included into dspbridge-baseline.

The patches look good to me. Except #16... if I revert it everything
works on the N900, so that's progress :)

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 24+ messages in thread

* RE: [PATCH 16/17] DSPBRIDGE: Avoid REGistry if pDevContext is available
  2009-12-15 18:21   ` Felipe Contreras
@ 2009-12-15 19:03     ` Ramirez Luna, Omar
  0 siblings, 0 replies; 24+ messages in thread
From: Ramirez Luna, Omar @ 2009-12-15 19:03 UTC (permalink / raw)
  To: Felipe Contreras
  Cc: linux-omap, Hiroshi Doyu, Ameya Palande, Felipe Contreras,
	Guzman Lugo, Fernando, Ramos Falcon, Ernesto

>From: Felipe Contreras [mailto:felipe.contreras@gmail.com]
>Sent: Tuesday, December 15, 2009 12:22 PM
>
>On Tue, Dec 15, 2009 at 8:19 AM, Omar Ramirez Luna <omar.ramirez@ti.com> wrote:
>> Avoid calls to read the register if pDevContext is available
>> to the function, this will save a call to query and hold
>> a semaphore under registry operations.
>
>[...]
>
>> --- a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
>> +++ b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
>> @@ -82,11 +82,8 @@ DSP_STATUS handle_constraints_set(struct WMD_DEV_CONTEXT *pDevContext,
>>  #ifdef CONFIG_BRIDGE_DVFS
>>        u32 *pConstraintVal;
>>        DSP_STATUS status = DSP_SOK;
>> -       struct CFG_HOSTRES resources;
>
>This breaks the build when DVFS is enabled, because of:
>status = HW_MBOX_saveSettings(resources.dwMboxBase);

Yes, this was removed in old patches, so patch assumes it is not there. I'll drop from the series for now.

>
>>        struct dspbridge_platform_data *pdata =
>>                omap_dspbridge_dev->dev.platform_data;
>> -       status = CFG_GetHostResources(
>> -               (struct CFG_DEVNODE *)DRV_GetFirstDevExtension(), &resources);
>>
>>        pConstraintVal = (u32 *)(pArgs);
>>        /* Read the target value requested by DSP  */
>
>BTW. Nobody is checking for errors in the 'status' variable.

Will recheck.

- omar
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 24+ messages in thread

* RE: [PATCH 02/17] DSPBRIDGE: Implemented Trampoline support for dynamic loader
  2009-12-15 18:24   ` Felipe Contreras
@ 2009-12-15 22:14     ` Ramirez Luna, Omar
  0 siblings, 0 replies; 24+ messages in thread
From: Ramirez Luna, Omar @ 2009-12-15 22:14 UTC (permalink / raw)
  To: Felipe Contreras
  Cc: linux-omap, Hiroshi Doyu, Ameya Palande, Felipe Contreras,
	Guzman Lugo, Fernando, Ramos Falcon, Ernesto

>From: Felipe Contreras [mailto:felipe.contreras@gmail.com]
>Sent: Tuesday, December 15, 2009 12:25 PM
>
>On Tue, Dec 15, 2009 at 8:19 AM, Omar Ramirez Luna <omar.ramirez@ti.com> wrote:
>> From: Fernando Guzman Lugo <x0095840@ti.com>
>>
>> Implemented on dynamic loader automatic generation of
>> trampolines when near calls are made to outside of signed
>> 21-bit offset available in the C64X+ DSP.
>
>The commit message is not clear: Why do we want this? What problem is
>fixed? Is old behavior changed, or is it an independent feature?
>

New commit message:

"Trampolines" utilize memory space containing a local jump
table to hit external locations. Instead of the "near"
function call directly calling the external location it
"calls" a trampoline entry.

A "near" function call requires the target to be within a
signed, 21-bit offset from the current PC so all calls have
to be within 4MB of the current execution point.

The trampoline entry (location in memory) contains an
unconditional long branch to the external address to be
called. When the called function returns, the PC is returned
to the original calling location since that is where the
link register points, as the trampoline utilizes a branch
instruction.

Utilizing this method removes the 4MB location restriction
as well since the long branch can be done within all of DSP
addressable space.

This doesn't require any change on the dsp side, it is an
enhancement for newer DSP side binaries.

- omar

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2009-12-15 22:15 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-15  6:19 [PATCH 00/17] First set of unreviewed patches Omar Ramirez Luna
2009-12-15  6:19 ` [PATCH 01/17] DSPBRIDGE: Remove preproessor condition that could never work Omar Ramirez Luna
2009-12-15  6:19 ` [PATCH 02/17] DSPBRIDGE: Implemented Trampoline support for dynamic loader Omar Ramirez Luna
2009-12-15 18:24   ` Felipe Contreras
2009-12-15 22:14     ` Ramirez Luna, Omar
2009-12-15  6:19 ` [PATCH 03/17] DSPBRIDGE: Enable/Disable MCBSP_CLOCKS for MCBSP2 Omar Ramirez Luna
2009-12-15 18:26   ` Felipe Contreras
2009-12-15  6:19 ` [PATCH 04/17] DSPBRIDGE: set PWRERROR notifications as an option Omar Ramirez Luna
2009-12-15  6:19 ` [PATCH 05/17] DSPBRIDGE: Enable peripheral clocks on wake up Omar Ramirez Luna
2009-12-15  6:19 ` [PATCH 06/17] DSPBRIDGE: Remove long busy-wait loops on PWRST transitions Omar Ramirez Luna
2009-12-15  6:19 ` [PATCH 07/17] DSPBRIDGE: Rename usCount to timeout Omar Ramirez Luna
2009-12-15  6:19 ` [PATCH 08/17] DSPBRIDGE: Trivial cleanup on DBDCD Omar Ramirez Luna
2009-12-15  6:19 ` [PATCH 09/17] DSPBRIDGE: Do not panic on bad page count Omar Ramirez Luna
2009-12-15  6:19 ` [PATCH 10/17] DSPBRIDGE: support loading 4 dependent DLL Omar Ramirez Luna
2009-12-15  6:19 ` [PATCH 11/17] DSPBRIDGE: Memory leak in Node Register Notify Omar Ramirez Luna
2009-12-15  6:19 ` [PATCH 12/17] DSPBRIDGE: check pointer before calling Proc_Detach Omar Ramirez Luna
2009-12-15  6:19 ` [PATCH 13/17] DSPBRIDGE: check the status of DMM_GetHandle Omar Ramirez Luna
2009-12-15  6:19 ` [PATCH 14/17] DSPBRIDGE: KFILE_Seek & KFILE_Tell, u32 replaced with loff_t Omar Ramirez Luna
2009-12-15  6:19 ` [PATCH 15/17] DSPBRIDGE: Delete unused files Omar Ramirez Luna
2009-12-15  6:19 ` [PATCH 16/17] DSPBRIDGE: Avoid REGistry if pDevContext is available Omar Ramirez Luna
2009-12-15 18:21   ` Felipe Contreras
2009-12-15 19:03     ` Ramirez Luna, Omar
2009-12-15  6:19 ` [PATCH 17/17] DSPBRIDGE: Compilation fixes 2.6.31 Omar Ramirez Luna
2009-12-15 18:28 ` [PATCH 00/17] First set of unreviewed patches Felipe Contreras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox