From: "Øyvind Harboe" <oyvind.harboe@zylin.com>
To: "'Gary Thomas'" <gary@mlbassoc.com>
Cc: "'eCos Discussion'" <ecos-discuss@sources.redhat.com>
Subject: RE: [ECOS] __attribute aligned and objcopy
Date: Thu, 25 Sep 2003 13:51:00 -0000 [thread overview]
Message-ID: <000001c3836c$107fe670$73dea8c0@lair> (raw)
In-Reply-To: <1064487578.1015.2645.camel@hermes>
[-- Attachment #1: Type: text/plain, Size: 992 bytes --]
What irked me about this one was that I had the feeling that
surely someone had done this before me, and that it was just
a matter of finding the right incatation to arm-elf-objcopy. :-)
>What I've done in the past is use GCC to get the magic right. Try
>looking at packages/hal/arm/edb7xxx/current/misc/long*.h
>These are binary data files which I then pass through GCC.
When I got your e-mail I had started work on a Frankenmake.
Modified rom/support/file2c.tcl attached.
# some singing and dancing to get an 4 bytes aligned data.
# raw data
$(OUTPUT)/%.o: %.alignedraw
echo -- Raw data file $*.alignedraw
../scripts/myfile2c.tcl $*.alignedraw $(OUTPUT)/$*.txt
echo >$(OUTPUT)/$*.xxxx "const __attribute__((aligned(4))) char
"
echo $(OUTPUT)/$* | sed -e 's/\//_/g' | sed -e 's/\./_/g'
>>$(OUTPUT)/$*.xxxx
echo []= >>$(OUTPUT)/$*.xxxx
cat $(OUTPUT)/$*.txt >>$(OUTPUT)/$*.xxxx
$(XCC) -o $(OUTPUT)/$*.o $(CFLAGS) -c -x c $(OUTPUT)/$*.xxxx
Øyvind
[-- Attachment #2: myfile2c.tcl --]
[-- Type: application/octet-stream, Size: 4506 bytes --]
#!/bin/bash
# restart using a Tcl shell \
exec sh -c 'for tclshell in tclsh tclsh83 cygtclsh80 ; do \
( echo | $tclshell ) 2> /dev/null && exec $tclshell "`( cygpath -w \"$0\" ) 2> /dev/null || echo $0`" "$@" ; \
done ; \
echo "file2c.tcl: cannot find Tcl shell" ; exit 1' "$0" "$@"
#===============================================================================
#
# file2c.tcl
#
# Convert a file into a header that can be #included from C.
#
#===============================================================================
#####ECOSGPLCOPYRIGHTBEGIN####
## -------------------------------------------
## This file is part of eCos, the Embedded Configurable Operating System.
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
##
## eCos is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free
## Software Foundation; either version 2 or (at your option) any later version.
##
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
## for more details.
##
## You should have received a copy of the GNU General Public License along
## with eCos; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
##
## As a special exception, if other files instantiate templates or use macros
## or inline functions from this file, or you compile this file and link it
## with other works to produce a work based on this file, this file does not
## by itself cause the resulting work to be covered by the GNU General Public
## License. However the source code for this file must still be made available
## in accordance with section (3) of the GNU General Public License.
##
## This exception does not invalidate any other reasons why a work based on
## this file might be covered by the GNU General Public License.
##
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
## at http://sources.redhat.com/ecos/ecos-license/
## -------------------------------------------
#####ECOSGPLCOPYRIGHTEND####
#===============================================================================
######DESCRIPTIONBEGIN####
#
# Author(s): jlarmour,bartv
# Contact(s):
# Date: 2001-07-20
# Purpose:
# Description:
# Usage: file2c.tcl <file to encode> <output C header file>
#
#####DESCRIPTIONEND####
#===============================================================================
if { $argc != 2 } {
puts "Usage: file2c.tcl <file to encode> <output C header file>"
exit 1
}
set infile [lindex $argv 0]
set outfile [lindex $argv 1]
set variablename [lindex $argv 2]
set status [ catch {
set infilefd [open $infile "r"]
fconfigure $infilefd -translation binary
set data [read $infilefd]
close $infilefd
} message]
if { $status != 0 } {
error "Unable to read file $infile: $message"
}
set result ""
set status [ catch {
set outfilefd [ open $outfile "w" ]
} message ]
if { $status != 0 } {
error "Unable to create file $outfile: $message"
}
append result "/* This is a generated file. Do not edit. */\n\n"
append result "{\n"
set datalength [ string length $data ]
set aligned_datalength [expr $datalength - ($datalength % 8)]
for { set i 0 } {$i < $aligned_datalength} {incr i 8} {
binary scan $data "@[set i]H16" var0
append result [format " 0x%2s, 0x%2s, 0x%2s, 0x%2s, 0x%2s, 0x%2s, 0x%2s, 0x%2s,\n" \
[string range $var0 0 1] \
[string range $var0 2 3] \
[string range $var0 4 5] \
[string range $var0 6 7] \
[string range $var0 8 9] \
[string range $var0 10 11] \
[string range $var0 12 13] \
[string range $var0 14 15]]
}
if { $aligned_datalength != $datalength } {
append result " "
for { set i $aligned_datalength } {$i < $datalength} {incr i} {
binary scan $data "@[set i]H2" var0
append result [format "0x%2s, " $var0]
}
}
# Remove either comma+newline or comma+space from the end
set result [string range $result 0 [expr [string length $result] - 3]]
append result "\n};"
puts $outfilefd $result
close $outfilefd
[-- Attachment #3: Type: text/plain, Size: 146 bytes --]
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
prev parent reply other threads:[~2003-09-25 13:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-25 10:37 Øyvind Harboe
2003-09-25 10:59 ` Gary Thomas
2003-09-25 13:51 ` Øyvind Harboe [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='000001c3836c$107fe670$73dea8c0@lair' \
--to=oyvind.harboe@zylin.com \
--cc=ecos-discuss@sources.redhat.com \
--cc=gary@mlbassoc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).