public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Reinhard Meyer <u-boot@emk-elektronik.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] Struct SoC access
Date: Tue, 17 Aug 2010 08:58:51 +0200	[thread overview]
Message-ID: <4C6A332B.1050205@emk-elektronik.de> (raw)
In-Reply-To: <20100816202128.GA2016@schlenkerla.am.freescale.net>

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

      reply	other threads:[~2010-08-17  6:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-14  9:07 [U-Boot] Make preparatory patches that initially have no effect? Reinhard Meyer
2010-08-14 14:30 ` Wolfgang Denk
2010-08-14 17:05   ` Reinhard Meyer
2010-08-14 18:46     ` Wolfgang Denk
2010-08-14 19:30       ` [U-Boot] Struct SoC access (was:Make preparatory patches that initially have no effect?) Reinhard Meyer
2010-08-14 19:36         ` Mike Frysinger
2010-08-14 19:40           ` [U-Boot] Struct SoC access Reinhard Meyer
2010-08-14 20:48             ` Mike Frysinger
2010-08-14 19:41         ` [U-Boot] Struct SoC access (was:Make preparatory patches that initially have no effect?) Wolfgang Denk
2010-08-14 19:58           ` [U-Boot] Struct SoC access Reinhard Meyer
2010-08-14 20:47             ` Reinhard Meyer
2010-08-14 21:49               ` Wolfgang Denk
2010-08-14 21:47             ` Wolfgang Denk
2010-08-14 22:15               ` Reinhard Meyer
2010-08-16 20:21                 ` Scott Wood
2010-08-17  6:58                   ` Reinhard Meyer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C6A332B.1050205@emk-elektronik.de \
    --to=u-boot@emk-elektronik.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox