Proxmark3 community

Research, development and trades concerning the powerful Proxmark3 device.

Remember; sharing is caring. Bring something back to the community.


"Learn the tools of the trade the hard way." +Fravia

You are not logged in.

Announcement

Time changes and with it the technology
Proxmark3 @ discord

Users of this forum, please be aware that information stored on this site is not private.

#1 2014-05-05 08:35:58

holiman
Contributor
Registered: 2013-05-03
Posts: 566

Arm<->FPGA development

I'm exploring the arm<->fpga interaction and development a bit deeper. I'm comparing the way iclass and iso14443a differs (and they are pretty similar).

But what does this block of code do? Specifically, casting a uint8_t (b) to void in a statement - what is the effect of that?

iclass.c:

	uint8_t b = 0;
[...]
		if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
			volatile uint8_t b = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
			(void)b;
		}

iso14443a.c:

static int EmSendCmd14443aRaw(uint8_t *resp, int respLen, bool correctionNeeded)
{
	uint8_t b;
[...]
 	// clear receiving shift register and holding register
	while(!(AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY));
	b = AT91C_BASE_SSC->SSC_RHR; (void) b;
	while(!(AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY));
	b = AT91C_BASE_SSC->SSC_RHR; (void) b;

And in the later case, b isn't even declared volatile. Isn't that statement optimized removed by the compiler?

Offline

#2 2014-05-05 10:04:52

Enio
Contributor
Registered: 2013-09-24
Posts: 175

Re: Arm<->FPGA development

nvm, i read it wrong.

It looks like some dirty way to clear the content in RHR.

Last edited by Enio (2014-05-05 10:08:23)

Offline

#3 2014-05-05 10:15:59

holiman
Contributor
Registered: 2013-05-03
Posts: 566

Re: Arm<->FPGA development

It looks like some dirty way to clear RHR, yes, but that is a very strange syntactic construction. I don't understand how a cast from uint8_t to void can produce any meaningful effect at all ?

Offline

#4 2014-05-05 14:24:20

Enio
Contributor
Registered: 2013-09-24
Posts: 175

Re: Arm<->FPGA development

The Read on RHR clears RXREADY. So the intention is to empty a full RHR by reading it into that uint8t var. Cast to void -> Compiler then knows you intentionally dont use the variable (prevents warnings).

Offline

#5 2014-05-05 14:42:42

piwi
Contributor
Registered: 2013-06-04
Posts: 704

Re: Arm<->FPGA development

Enio is right.

And regarding the statement being removed by the compiler: it isn't because AT91C_BASE_SSC->SSC_SR (like all ARM registers) is declared volatile.

Offline

Board footer

Powered by FluxBB