29.01.2015 Views

Embedded Software for SoC - Grupo de Mecatrônica EESC/USP

Embedded Software for SoC - Grupo de Mecatrônica EESC/USP

Embedded Software for SoC - Grupo de Mecatrônica EESC/USP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Porting a Network Cryptographic Service to the RMC2000 171<br />

protocols inclu<strong>de</strong> timeouts, but Dynamic C does not have a timer), to virtually<br />

impossible (e.g., the iSSL library makes some use of a filesystem,<br />

something not provi<strong>de</strong>d by the RMC2000 environment). Our solutions to these<br />

ranged from creating a new implementation of the library function (e.g.,<br />

writing a random function) to working around the problem (e.g., changing<br />

the program logic so it no longer read a hash value from a file) to abandoning<br />

functionality altogether (e.g., our final port did not implement the RSA cipher<br />

because it relied on a fairly complex bignum library that we consi<strong>de</strong>red too<br />

complicated to rework).<br />

A second class of problem stemmed from differing APIs with similar<br />

functionality. For example, the protocol <strong>for</strong> accessing the RMC2000 s TCP/IP<br />

stack differs quite a bit from the BSD sockets used within iSSL. Figure<br />

13-2 illustrates some of these differences. While solving such problems is<br />

generally much easier than, say, porting a whole library, reworking the co<strong>de</strong><br />

is tedious.<br />

A third class of problem required the most thought. Often, fundamental<br />

assumptions ma<strong>de</strong> in co<strong>de</strong> <strong>de</strong>signed to run on workstations or servers, such<br />

as the existence of a filesystem with nearly unlimited capacity (e.g., <strong>for</strong><br />

keeping a log), are impractical in an embed<strong>de</strong>d systems. Logging and<br />

somewhat sloppy memory management that assumes the program will be<br />

restarted occasionally to cure memory leaks are examples of this. The solutions<br />

to such problems are either to remove the offending functionality at the<br />

expense of features (e.g., remove logging altogether), or a serious reworking<br />

of the co<strong>de</strong> (e.g., to make logging write to a circular buffer rather than a file).<br />

5.1. Interrupts<br />

We used the serial port on the RMC2000 board <strong>for</strong> <strong>de</strong>bugging. We configured<br />

the serial interface to interrupt the processor when a character arrived.<br />

In response, the system either replied with a status messages or reset the application,<br />

possibly maintaining program state. A Unix environment provi<strong>de</strong>s a<br />

high-level mechanism <strong>for</strong> handling software interrupts:<br />

main() {<br />

signal(SIGINT, sigproc); // Register signal handler<br />

}<br />

void sigproc() { /* Handle the signal */ }<br />

In Dynamic C, we had to handle the <strong>de</strong>tails ourselves. For example, to set<br />

up the interrupt from the serial port, we had to enable interrupts from the serial<br />

port, register the interrupt routine, and enable the interrupt receiver.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!