From mboxrd@z Thu Jan 1 00:00:00 1970 From: Reinhard Meyer Date: Tue, 17 Aug 2010 08:58:51 +0200 Subject: [U-Boot] Struct SoC access In-Reply-To: <20100816202128.GA2016@schlenkerla.am.freescale.net> References: <4C665CB9.2040406@emk-elektronik.de> <20100814143009.A18461606A5@gemini.denx.de> <4C66CCCF.9080303@emk-elektronik.de> <20100814184641.981AC1606A5@gemini.denx.de> <4C66EECA.5020509@emk-elektronik.de> <20100814194117.982C71606A5@gemini.denx.de> <4C66F54D.2060701@emk-elektronik.de> <20100814214738.0BEC81606A5@gemini.denx.de> <4C671581.9040804@emk-elektronik.de> <20100816202128.GA2016@schlenkerla.am.freescale.net> Message-ID: <4C6A332B.1050205@emk-elektronik.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 #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 #elif defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9G20) #include #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 #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