[U-Boot] Struct SoC access

Reinhard Meyer u-boot at emk-elektronik.de
Tue Aug 17 08:58:51 CEST 2010


Dear Scott Wood,
>> Then assign struct soc *soc = (struct soc *)0;
> 
> One snag you might hit is that dereferencing a NULL pointer is undefined,
> and some versions of GCC assume you won't do this when optimizing.  Not sure
> if this simple usage would be affected (it seems to mainly be an issue when
> comparing a pointer to NULL after dereferencing), and
> -fno-delete-null-pointer-checks may help.
Its just an idea anyway...

Certainly the 1st way I proposed is the easiest to go:
#define BLOCK_BASE_ADDR 0xsomething
block_t *block = (block_t *)BLOCK_BASE_ADDR;

>> Whats a IOCCC?
> 
> The International Obfuscated C Code Contest, possibly a more appropriate
> venue for code that defines a 4GB struct. :-)
In that case I am quite sure the current AT91 way of defining the hardware
addresses to the drivers already qualifies for that ;)
(Try to follow the definition of SPI0_BASE...)

arch-at91/memory_map.h:
...
#ifndef __ASM_ARM_ARCH_MEMORYMAP_H__
#define __ASM_ARM_ARCH_MEMORYMAP_H__

#include <asm/arch/hardware.h>

#define USART0_BASE AT91_USART0
#define USART1_BASE AT91_USART1
#define USART2_BASE AT91_USART2
#define USART3_BASE (AT91_BASE_SYS + AT91_DBGU)
#define SPI0_BASE	AT91_BASE_SPI
#define SPI1_BASE	AT91_BASE_SPI1

#endif /* __ASM_ARM_ARCH_MEMORYMAP_H__ */
...

arch-at91/harware.h:
...
#if defined(CONFIG_AT91RM9200)
#include <asm/arch-at91/at91rm9200.h>
#elif defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9G20)
#include <asm/arch/at91sam9260.h>
#define AT91_BASE_SPI	AT91SAM9260_BASE_SPI0
#define AT91_BASE_SPI1	AT91SAM9260_BASE_SPI1
#define AT91_ID_UHP	AT91SAM9260_ID_UHP
#define AT91_PMC_UHP	AT91SAM926x_PMC_UHP
#define AT91_BASE_MMCI	AT91SAM9260_BASE_MCI
#elif defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
#include <asm/arch/at91sam9261.h>
#define AT91_BASE_SPI	AT91SAM9261_BASE_SPI0
#define AT91_ID_UHP	AT91SAM9261_ID_UHP
#define AT91_PMC_UHP	AT91SAM926x_PMC_UHP
#elif defined(CONFIG_AT91SAM9263)
...

arch-at91/at91sam9260.h:
...
#ifdef CONFIG_AT91_LEGACY

/*
  * User Peripheral physical base addresses.
  */
#define AT91SAM9260_BASE_TCB0		0xfffa0000
#define AT91SAM9260_BASE_TC0		0xfffa0000
#define AT91SAM9260_BASE_TC1		0xfffa0040
#define AT91SAM9260_BASE_TC2		0xfffa0080
#define AT91SAM9260_BASE_UDP		0xfffa4000
#define AT91SAM9260_BASE_MCI		0xfffa8000
#define AT91SAM9260_BASE_TWI		0xfffac000
#define AT91SAM9260_BASE_US0		0xfffb0000
#define AT91SAM9260_BASE_US1		0xfffb4000
#define AT91SAM9260_BASE_US2		0xfffb8000
#define AT91SAM9260_BASE_SSC		0xfffbc000
#define AT91SAM9260_BASE_ISI		0xfffc0000
#define AT91SAM9260_BASE_EMAC		0xfffc4000
#define AT91SAM9260_BASE_SPI0		0xfffc8000
#define AT91SAM9260_BASE_SPI1		0xfffcc000
#define AT91SAM9260_BASE_US3		0xfffd0000
#define AT91SAM9260_BASE_US4		0xfffd4000
#define AT91SAM9260_BASE_US5		0xfffd8000
#define AT91SAM9260_BASE_TCB1		0xfffdc000
#define AT91SAM9260_BASE_TC3		0xfffdc000
#define AT91SAM9260_BASE_TC4		0xfffdc040
#define AT91SAM9260_BASE_TC5		0xfffdc080
#define AT91SAM9260_BASE_ADC		0xfffe0000
#define AT91_BASE_SYS			0xffffe800
...

arch-at91/at91sam9261.h:
...
#ifdef CONFIG_AT91_LEGACY

/*
  * User Peripheral physical base addresses.
  */
#define AT91SAM9261_BASE_TCB0		0xfffa0000
#define AT91SAM9261_BASE_TC0		0xfffa0000
#define AT91SAM9261_BASE_TC1		0xfffa0040
#define AT91SAM9261_BASE_TC2		0xfffa0080
#define AT91SAM9261_BASE_UDP		0xfffa4000
#define AT91SAM9261_BASE_MCI		0xfffa8000
#define AT91SAM9261_BASE_TWI		0xfffac000
#define AT91SAM9261_BASE_US0		0xfffb0000
#define AT91SAM9261_BASE_US1		0xfffb4000
#define AT91SAM9261_BASE_US2		0xfffb8000
#define AT91SAM9261_BASE_SSC0		0xfffbc000
#define AT91SAM9261_BASE_SSC1		0xfffc0000
#define AT91SAM9261_BASE_SSC2		0xfffc4000
#define AT91SAM9261_BASE_SPI0		0xfffc8000
#define AT91SAM9261_BASE_SPI1		0xfffcc000
#define AT91_BASE_SYS			0xffffea00
...

isn't that obfuscated enough?

Reinhard


More information about the U-Boot mailing list