[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#494010: Source for dsp56k firmware



On Thu, Oct 16, 2008 at 12:32:15AM +0100, Ben Hutchings wrote:
> >   - Attached patch fixes a few errors spit by a56.  I think my other two fixes
> >     are correct, but I have no idea what the '<' / '>' candy is supposed to do
> >     (hints?).
> 
> According to the assembler reference manual
> <http://www.freescale.com/files/dsp/doc/ref_manual/DSPASMRM.pdf> they mean:
> 
>     << - I/O short addressing mode force operator
>     <  - Short addressing mode force operator
>     >  - Long addressing mode force operator

Thanks.  This seems to be a non-issue (resulting code is the same, indicating
a56 already makes the same assumptions).

> >   - Resulting offsets doen't match with the blob.  I still haven't figured out
> >     how are program code offsets mapped to the output file, but some parts
> >     don't match.  For example, the blob has a jump (0C 00 40) to 0x40
> >     (and so does a56 output, at offset 0x0 in both cases), but then code
> >     from the blob continues at 0xc0, unlike code from a56 which continues at
> >     0x40.  Is there some trick to this?
>  
> It's a 24-bit processor and uses word-addressing, not byte-addressing.

Ok, fixed that.  I got a 100% code match now.  The only remaining question is
what's the deal with this section that's supposed to start at 0x7ea9 but
actually starts at 0x4f (0xed in the file).  My code adds a workaround for
that:

      if (offset > 0x7000)
        offset -= 0x7e5a;

which is really nasty.  Anyone knows better?

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
  - Remove '<' and '>' candy (they specify explicit addressing modes,
    which a56 don't grok, but uses follows implicitly anyway).

  - Replace 'move' with 'movem' when accessing program memory.

  - Rename a few labels to avoid duplicates (which a56 can't handle).

--- ../bootstrap.asm.old	2008-10-15 18:22:56.000000000 +0200
+++ ../bootstrap.asm	2008-10-16 15:53:29.000000000 +0200
@@ -51,19 +51,19 @@
         ; Copy DSP program control
         move    #real,r0
         move    #upload,r1
-        do      #upload_end-upload,<_copy
-        move    P:(r0)+,x0
-        move    x0,P:(r1)+
-_copy   movep   #>4,X:<<M_HCR
-        movep   #>$c00,X:<<M_IPR
+        do      #upload_end-upload,_copy
+        movem    P:(r0)+,x0
+        movem    x0,P:(r1)+
+_copy   movep   #4,X:<<M_HCR
+        movep   #$c00,X:<<M_IPR
         and     #<$fe,mr
         jmp     upload
 
 real
         org     P:$7ea9
 upload
-        movep   #>1,X:<<M_PBC
-        movep   #>0,X:<<M_BCR
+        movep   #1,X:<<M_PBC
+        movep   #0,X:<<M_BCR
 
 next    jclr    #0,X:<<M_HSR,*
         movep   X:<<M_HRX,A
@@ -81,18 +81,18 @@
         cmp     x0,A
         jeq     load_Y
 
-load_P  do      y0,_load
+load_P  do      y0,_load_P
         jclr    #0,X:<<M_HSR,*
         movep   X:<<M_HRX,P:(r0)+
-_load   jmp     next
-load_X  do      y0,_load
+_load_P jmp     next
+load_X  do      y0,_load_X
         jclr    #0,X:<<M_HSR,*
         movep   X:<<M_HRX,X:(r0)+
-_load   jmp     next
-load_Y  do      y0,_load
+_load_X jmp     next
+load_Y  do      y0,_load_Y
         jclr    #0,X:<<M_HSR,*
         movep   X:<<M_HRX,Y:(r0)+
-_load   jmp     next
+_load_Y jmp     next
 
 upload_end
         end
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>

main (int argc, char *argv[])
{
  unsigned int offset;
  unsigned int native_value;
  int fd;
  uint8_t value[3];
  char type;
  char *line = NULL;
  size_t zero = 0;

  if (argc != 2)
    {
      fprintf (stderr, "Usage: %s output < input\n", argv[0]);
      exit (1);
    }

  fd = open (argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0644);

  while (getline (&line, &zero, stdin) != -1)
    {
      sscanf (line, "%c ", &type);

      if (type != 'P')
	continue;

      sscanf (line + 2, "%x %x\n", &offset, &native_value);

      value[0] = (native_value >> 16) & 0xff;
      value[1] = (native_value >> 8) & 0xff;
      value[2] = native_value & 0xff;

      // FIXME
      if (offset > 0x7000)
        offset -= 0x7e5a;
      
      pwrite (fd, value, 3, (off_t) (offset * 3));
    }

  close (fd);

  exit (0);
}

Reply to: