[Tinyos8051wg-commit] SF.net SVN: tinyos8051wg:[1096] trunk/diku/mcs51
Status: Alpha
Brought to you by:
mleopold
From: <mle...@us...> - 2009-10-05 22:42:27
|
Revision: 1096 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1096&view=rev Author: mleopold Date: 2009-10-05 22:42:17 +0000 (Mon, 05 Oct 2009) Log Message: ----------- Attempt to fix reentrant problem automatically using Keil debug information Modified Paths: -------------- trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl trunk/diku/mcs51/tos/chips/cc2430/usart/HalCC2430SimpleUartP.nc trunk/diku/mcs51/tos/chips/mcs51/io8051.h Modified: trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl =================================================================== --- trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl 2009-10-05 19:47:07 UTC (rev 1095) +++ trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl 2009-10-05 22:42:17 UTC (rev 1096) @@ -97,16 +97,60 @@ @input = <FILE>; -# Find names of all reentrant functions. +# +# Reentrant functions +# + +# A crude hack to Keil to mark appropriate functions as reentrant + +my $reentFile = $file; +$reentFile =~ s/app.(?:\w|\.)+/app.reent/; + +if ( $KEIL ){ + my $mapFile = $file; + $mapFile =~ s/app.(?:\w|\.)+/app.map/; + + if (open (RFILE, "<$reentFile")) { + @reentrantFunctions = <RFILE>; + chomp @reentrantFunctions; + close RFILE; + } + + my @mapInput = `grep -A1 \"MULTIPLE CALL TO FUNCTION\" $mapFile`; + @mapInput = grep(/NAME/, @mapInput); + map (s/^.*NAME:\s*_*(\w+)\/.*/$1/, @mapInput); + chomp @mapInput; + + foreach my $fn (@mapInput) { + push(@reentrantFunctions, "$fn"); + } +} + +# First pass of source: find all functions marked as reentrant foreach (@input) { if (/([^\s]+?)\(.*?\).*?\s+__attribute(?:__)?\(\(.*?(?:__)?reentrant(?:__)?.*\)\).*?\;/g) { my $func = $1; $func =~ s/\$/__/g; + chomp ($func); push(@reentrantFunctions, "$func"); printf STDERR "Found reentrant function: '%s'\n",$func; } } +# Eliminate duplicates +@reentrantFunctions = map ( lc, @reentrantFunctions); +my @new_array = (); +my %seen; +foreach my $i (@reentrantFunctions) { + push(@new_array, $i) unless ($seen{$i}++); +} +@reentrantFunctions = @new_array; +if (open (RFILE, ">$reentFile")) { + foreach my $fn (@reentrantFunctions) {print RFILE "$fn\n";} + close RFILE; +} + + # Write header stuff. $output .= "#define MANGLED_NESC_APP_C\n"; @@ -203,6 +247,7 @@ # drawback is that it seems that sometimes CIL (the inliner) seems # to be too clever and replace the typedef'ed type with the original. # *(uint8_t_xdata* 0x??) = xx + # uint8_t_xdata j; # # 2. Use the attribute syntax all the way and create an expression # similar to GCC. This unfortunate seems to clash with the @@ -210,6 +255,7 @@ # that fails in Keil on certain occations (e.g. if an extra (int) is # inserted this becomes (int xdata) which Keil does not accept). # *(uint8_t __attribute((xdata)) *) 0x?? = xx + # uint8_t j; # # 3. As above define a list of global variables these as variables # with absolute locations: @@ -316,20 +362,19 @@ if ($KEIL) { # Append the "reentrant" keyword to function prototypes as well. if (!$braceLevel && !m{reentrant}g) { - # my $i=0; - foreach my $reentrantFunc (@reentrantFunctions) { - my $funcName = quotemeta($reentrantFunc); - if (m{\s+$funcName\s*\(}g) { - if (m{\(} != m{\)}) { - # Paranthesis levels do not match. Wait for ")". - $reentrantWait = 1; - } else { - s{([^\;]*)}{$1 reentrant}; - printf STDERR "Fixed reentrant function prototype: '%s'\n",$funcName; - } + foreach my $reentrantFunc (@reentrantFunctions) { + my $funcName = quotemeta($reentrantFunc); + if (m{$funcName\s*\(}gi) { + if (m{\(} != m{\)}) { + # Paranthesis levels do not match. Wait for ")". + $reentrantWait = 1; + } else { + s{([^\;\{]+)}{$1 reentrant}; + printf STDERR "Fixed reentrant function: '%s'\n",$funcName; + } + } + # $i++; } - # $i++; - } } if ($reentrantWait && m{\);}) { @@ -697,7 +742,6 @@ close(FILE); - sub doneProcessing { my $line = $_[0]; @@ -712,3 +756,4 @@ $output .= $line; } + Modified: trunk/diku/mcs51/tos/chips/cc2430/usart/HalCC2430SimpleUartP.nc =================================================================== --- trunk/diku/mcs51/tos/chips/cc2430/usart/HalCC2430SimpleUartP.nc 2009-10-05 19:47:07 UTC (rev 1095) +++ trunk/diku/mcs51/tos/chips/cc2430/usart/HalCC2430SimpleUartP.nc 2009-10-05 22:42:17 UTC (rev 1096) @@ -48,7 +48,6 @@ } implementation { - //uint8_t volatile UTX0IE __attribute((sbitAT0x9C)); bool busy = FALSE; command error_t Init.init() @@ -86,7 +85,7 @@ return SUCCESS; } - async command error_t uart0.put(uint8_t data) __attribute((reentrant)) + async command error_t uart0.put(uint8_t data) { bool wasBusy; Modified: trunk/diku/mcs51/tos/chips/mcs51/io8051.h =================================================================== --- trunk/diku/mcs51/tos/chips/mcs51/io8051.h 2009-10-05 19:47:07 UTC (rev 1095) +++ trunk/diku/mcs51/tos/chips/mcs51/io8051.h 2009-10-05 22:42:17 UTC (rev 1096) @@ -175,8 +175,8 @@ to vary. On chipcon this register is name IE0EN */ -norace uint8_t volatile IE __attribute((sfrAT0A8)); -norace norace uint8_t volatile EA __attribute((sbitAT0xAF)); +norace uint8_t volatile IE __attribute((sfrAT0A8)); +norace uint8_t volatile EA __attribute((sbitAT0xAF)); /* IP */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |